Spaces:
Runtime error
Runtime error
Stefan Dumitrescu
commited on
Commit
·
13c6076
1
Parent(s):
543d322
Update
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import roner
|
|
6 |
|
7 |
example_list = [
|
8 |
"Ana merge în București.",
|
9 |
-
"""
|
10 |
]
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
@@ -62,7 +62,8 @@ if Run_Button == True:
|
|
62 |
"word": word["text"],
|
63 |
"entity": word["tag"],
|
64 |
"start_char": word["start_char"],
|
65 |
-
"end_char": word["end_char"]
|
|
|
66 |
})
|
67 |
df = pd.DataFrame.from_dict(data)
|
68 |
st.subheader("Recognized Entities")
|
@@ -75,9 +76,23 @@ if Run_Button == True:
|
|
75 |
spacy_display["text"] = output["text"]
|
76 |
spacy_display["title"] = None
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
entity_list = ['PERSON', 'ORG', 'GPE', 'LOC', 'NAT_REL_POL',
|
83 |
'EVENT', 'LANGUAGE', 'WORK_OF_ART', 'DATETIME',
|
|
|
6 |
|
7 |
example_list = [
|
8 |
"Ana merge în București.",
|
9 |
+
"""Președintele Statelor Unite, Joe Biden, a spus, vineri, că va trimite un număr de militari americani în Europa de Est „în curând”, ca urmare a situației tot mai tensionate din Ucraina. Președintele american a spus că „nu va trimite foarte mult” și a exclus din nou posibilitatea desfășurării de trupe în Ucraina, care nu face parte din Alianța Nord-Atlantică. """
|
10 |
]
|
11 |
|
12 |
st.set_page_config(layout="wide")
|
|
|
62 |
"word": word["text"],
|
63 |
"entity": word["tag"],
|
64 |
"start_char": word["start_char"],
|
65 |
+
"end_char": word["end_char"],
|
66 |
+
"multi-word-entity": word["multi_word_entity"]
|
67 |
})
|
68 |
df = pd.DataFrame.from_dict(data)
|
69 |
st.subheader("Recognized Entities")
|
|
|
76 |
spacy_display["text"] = output["text"]
|
77 |
spacy_display["title"] = None
|
78 |
|
79 |
+
i = 0
|
80 |
+
words = output["words"]
|
81 |
+
while i < len(words):
|
82 |
+
if words[i]["tag"]!="O":
|
83 |
+
start = words[i]["start_char"]
|
84 |
+
end = words[i]["end_char"]
|
85 |
+
label = words[i]["tag"]
|
86 |
+
|
87 |
+
for j in range(i+1,len(words)):
|
88 |
+
if words[j]["tag"] == words[i]["tag"] and words[j]["multi_word_entity"] is True:
|
89 |
+
end = words[j]["end_char"]
|
90 |
+
i = j
|
91 |
+
|
92 |
+
spacy_display["ents"].append({"start": start, "end": end, "label": label})
|
93 |
+
i += 1
|
94 |
+
|
95 |
+
|
96 |
|
97 |
entity_list = ['PERSON', 'ORG', 'GPE', 'LOC', 'NAT_REL_POL',
|
98 |
'EVENT', 'LANGUAGE', 'WORK_OF_ART', 'DATETIME',
|