Spaces:
Runtime error
Runtime error
Atharva
commited on
Commit
•
d716414
1
Parent(s):
732bfc1
downgrade streamlit
Browse files- app.py +5 -3
- requirements.txt +0 -1
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
|
|
3 |
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
|
4 |
|
5 |
from src import GBRT, wikipedia_search, google_search
|
@@ -67,9 +68,9 @@ def get_candidates(mentions_tags):
|
|
67 |
def display_tag(text, typ, label):
|
68 |
if label != 'NIL':
|
69 |
label = "https://en.wikipedia.org/wiki/" + label
|
70 |
-
return f'<a style="margin: 0px 5px 0px 0px; padding:
|
71 |
else:
|
72 |
-
return f'<span style="margin: 0px 5px 0px 0px; padding:
|
73 |
|
74 |
|
75 |
|
@@ -96,7 +97,8 @@ def main(text):
|
|
96 |
|
97 |
with col2:
|
98 |
st.write("### Disambiguated Text")
|
99 |
-
|
|
|
100 |
|
101 |
df = pd.DataFrame(data=preditions, columns=['Mention', 'Prediction', 'Confidence'])
|
102 |
st.write("**Additional Information**")
|
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
+
import streamlit.components.v1 as components
|
4 |
from transformers import AutoModelForTokenClassification, AutoTokenizer, pipeline
|
5 |
|
6 |
from src import GBRT, wikipedia_search, google_search
|
|
|
68 |
def display_tag(text, typ, label):
|
69 |
if label != 'NIL':
|
70 |
label = "https://en.wikipedia.org/wiki/" + label
|
71 |
+
return f'<a style="margin: 0px 5px 0px 0px; padding: 2px 4px; border-radius: 4px; text-decoration:none; background-color:{COLOR[typ]}; color: white; cursor:pointer; white-space: nowrap; font-weight:400" href={label} target="_blank"><span style="margin-right:2px;">{text}</span><span style="background-color: white; color: {COLOR[typ]}; padding: 1px 2px; border-radius: 4px; font-size: 0.8em">{typ}</span></a>'
|
72 |
else:
|
73 |
+
return f'<span style="margin: 0px 5px 0px 0px; padding: 2px 4px; border-radius: 4px; text-decoration:none; background-color: #EF4444; color: white; cursor:not-allowed; white-space: nowrap;"><span style="margin-right:2px">{text}</span><span style="background-color: white; color: #EF4444; padding: 1px 2px; border-radius: 4px; font-size: 0.8em">{typ}</span></span>'
|
74 |
|
75 |
|
76 |
|
|
|
97 |
|
98 |
with col2:
|
99 |
st.write("### Disambiguated Text")
|
100 |
+
components.html(f'<div style="white-space: pre-line; line-height: 1.65; font-family: sans-serif">{tagged}</div>',
|
101 |
+
height=700, scrolling=True)
|
102 |
|
103 |
df = pd.DataFrame(data=preditions, columns=['Mention', 'Prediction', 'Confidence'])
|
104 |
st.write("**Additional Information**")
|
requirements.txt
CHANGED
@@ -4,6 +4,5 @@ pandas
|
|
4 |
wikipedia2vec
|
5 |
scikit-learn
|
6 |
transformers
|
7 |
-
streamlit==1.8.1
|
8 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
9 |
torch
|
|
|
4 |
wikipedia2vec
|
5 |
scikit-learn
|
6 |
transformers
|
|
|
7 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
8 |
torch
|