Spaces:
Runtime error
Runtime error
Commit
β’
97217cb
0
Parent(s):
Duplicate from pythiccoder/FastCoref
Browse filesCo-authored-by: Ari Bornstein <[email protected]>
- .gitattributes +31 -0
- README.md +16 -0
- app.py +28 -0
- requirements.txt +2 -0
.gitattributes
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: FastCoref
|
3 |
+
models:
|
4 |
+
- biu-nlp/lingmess-coref
|
5 |
+
emoji: π
|
6 |
+
colorFrom: pink
|
7 |
+
colorTo: blue
|
8 |
+
sdk: gradio
|
9 |
+
sdk_version: 3.2
|
10 |
+
app_file: app.py
|
11 |
+
pinned: false
|
12 |
+
license: mit
|
13 |
+
duplicated_from: pythiccoder/FastCoref
|
14 |
+
---
|
15 |
+
|
16 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spacy
|
3 |
+
from spacy import displacy
|
4 |
+
from spacy.tokens import Span
|
5 |
+
from random import randint
|
6 |
+
from fastcoref import LingMessCoref
|
7 |
+
|
8 |
+
model = LingMessCoref()
|
9 |
+
nlp = spacy.blank("en")
|
10 |
+
|
11 |
+
default = "Lionel Messi has won a record seven Ballon d'Or awards. He signed for Paris Saint-Germain in August 2021. βI would like to thank my familyβ said the Argentinian footballer. Messi holds the records for most goals in La Liga. Paris Saint-Germain hopes he will do the same in Ligue 1."
|
12 |
+
|
13 |
+
def corefer(text):
|
14 |
+
preds = model.predict(texts=[text])
|
15 |
+
clusters = preds[0].get_clusters(as_strings=False)
|
16 |
+
doc = nlp(text)
|
17 |
+
doc.spans["sc"] = []
|
18 |
+
colors = {"Cluster {}".format(i):'#%06X' % randint(0, 0xFFFFFF) for i in range(len(clusters))}
|
19 |
+
for i, cluster in enumerate(clusters):
|
20 |
+
for sp in cluster:
|
21 |
+
doc.spans["sc"] += [doc.char_span(sp[0], sp[1], "Cluster {}".format(i))]
|
22 |
+
return displacy.render(doc, style="span", options= {"colors":colors }, page=True )
|
23 |
+
|
24 |
+
|
25 |
+
iface = gr.Interface(fn=corefer,
|
26 |
+
inputs=gr.Textbox(label="Enter Text To Corefer with FastCoref", lines=2, value=default),
|
27 |
+
outputs="html")
|
28 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
spacy==3.4.1
|
2 |
+
fastcoref==1.7.1
|