Spaces:
Runtime error
Runtime error
ben-epstein
commited on
Commit
•
9d57d89
1
Parent(s):
beb602e
Create app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,3 @@
|
|
1 |
-
import
|
2 |
-
from json import JSONDecodeError
|
3 |
|
4 |
-
|
5 |
-
from datasets import Dataset
|
6 |
-
|
7 |
-
from spacy_to_hf import spacy_to_hf
|
8 |
-
|
9 |
-
demo_option = [
|
10 |
-
{
|
11 |
-
"text": "Planned to go to the Apple Storefront on Tuesday",
|
12 |
-
"spans": [
|
13 |
-
{"start": 0, "end": 7, "label": "Action"},
|
14 |
-
{"start": 21, "end": 37, "label": "Loc"},
|
15 |
-
{"start": 41, "end": 48, "label": "Date"},
|
16 |
-
],
|
17 |
-
}
|
18 |
-
]
|
19 |
-
|
20 |
-
tokenizers = [
|
21 |
-
"bert-base-uncased",
|
22 |
-
"bert-base-cased",
|
23 |
-
"distilbert-base-uncased",
|
24 |
-
"distilbert-base-cased",
|
25 |
-
"roberta-base",
|
26 |
-
]
|
27 |
-
tok = st.selectbox("Pick a tokenizer", tokenizers)
|
28 |
-
spacy_data = st.text_area("Input your NER Span data here")
|
29 |
-
|
30 |
-
if spacy_data or st.button("Or try an example"):
|
31 |
-
run_data = None
|
32 |
-
if spacy_data:
|
33 |
-
try:
|
34 |
-
run_data = json.loads(spacy_data)
|
35 |
-
except JSONDecodeError as e:
|
36 |
-
st.warning(f"Invalid JSON data, try again\n{str(e)}")
|
37 |
-
else:
|
38 |
-
run_data = demo_option
|
39 |
-
if run_data:
|
40 |
-
st.write("Spacy input data:")
|
41 |
-
st.json(run_data)
|
42 |
-
hf_data = spacy_to_hf(run_data, tok)
|
43 |
-
df = Dataset.from_dict(hf_data).to_pandas()
|
44 |
-
st.write("Output huggingface format:")
|
45 |
-
st.dataframe(df)
|
|
|
1 |
+
import streamlit as st
|
|
|
2 |
|
3 |
+
st.write("Hello World!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|