Spaces:
Running
Running
Upload with huggingface_hub
Browse files- DESCRIPTION.md +1 -0
- README.md +6 -7
- __pycache__/run.cpython-36.pyc +0 -0
- requirements.txt +1 -0
- run.py +38 -0
- screenshot.png +0 -0
- setup.sh +1 -0
DESCRIPTION.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
This simple demo takes advantage of Gradio's HighlightedText, JSON and HTML outputs to create a clear NER segmentation.
|
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.6
|
8 |
-
app_file:
|
9 |
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: text_analysis_main
|
4 |
+
emoji: 🔥
|
5 |
+
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.6
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
---
|
|
|
|
__pycache__/run.cpython-36.pyc
ADDED
Binary file (1.02 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
spacyhttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
|
run.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
os.system('python -m spacy download en_core_web_sm')
|
4 |
+
import spacy
|
5 |
+
from spacy import displacy
|
6 |
+
|
7 |
+
nlp = spacy.load("en_core_web_sm")
|
8 |
+
|
9 |
+
def text_analysis(text):
|
10 |
+
doc = nlp(text)
|
11 |
+
html = displacy.render(doc, style="dep", page=True)
|
12 |
+
html = (
|
13 |
+
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
|
14 |
+
+ html
|
15 |
+
+ "</div>"
|
16 |
+
)
|
17 |
+
pos_count = {
|
18 |
+
"char_count": len(text),
|
19 |
+
"token_count": 0,
|
20 |
+
}
|
21 |
+
pos_tokens = []
|
22 |
+
|
23 |
+
for token in doc:
|
24 |
+
pos_tokens.extend([(token.text, token.pos_), (" ", None)])
|
25 |
+
|
26 |
+
return pos_tokens, pos_count, html
|
27 |
+
|
28 |
+
demo = gr.Interface(
|
29 |
+
text_analysis,
|
30 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
31 |
+
["highlight", "json", "html"],
|
32 |
+
examples=[
|
33 |
+
["What a beautiful morning for a walk!"],
|
34 |
+
["It was the best of times, it was the worst of times."],
|
35 |
+
],
|
36 |
+
)
|
37 |
+
|
38 |
+
demo.launch()
|
screenshot.png
ADDED
setup.sh
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
python -m spacy download en_core_web_sm
|