wannaphong
commited on
Commit
•
eb75c2d
1
Parent(s):
0024ab7
Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,14 @@ default = "แกว่าเราเข้มแข็งมากพอที
|
|
13 |
def corefer(text):
|
14 |
preds = model.predict(texts=[text])
|
15 |
clusters = preds[0].get_clusters(as_strings=False)
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
for i,
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
|
24 |
|
25 |
iface = gr.Interface(fn=corefer,
|
|
|
13 |
def corefer(text):
|
14 |
preds = model.predict(texts=[text])
|
15 |
clusters = preds[0].get_clusters(as_strings=False)
|
16 |
+
title=None
|
17 |
+
dic_ents = {"text":text,"ents":[],"title":title}
|
18 |
+
_tag=[str(i) for i in list(range(len(clusters)))]
|
19 |
+
for i,tag in enumerate(tags):
|
20 |
+
for s,e in tag:
|
21 |
+
dic_ents["ents"].append({"start": s, "end": e, "label": _tag[i]})
|
22 |
+
colors={i:"#"+''.join([random.choice('0123456789ABCDEF') for j in range(6)]) for i in _tag} # thank https://stackoverflow.com/a/50218895
|
23 |
+
return displacy.render(dic_ents, manual=True, style="ent",options=colors)
|
24 |
|
25 |
|
26 |
iface = gr.Interface(fn=corefer,
|