Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from annotated_text import annotated_text
|
|
4 |
from io import StringIO
|
5 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
6 |
from text_extractor import *
|
|
|
7 |
import os
|
8 |
from streamlit_text_annotation import text_annotation
|
9 |
|
@@ -178,65 +179,24 @@ elif selected_menu == "Get Answers":
|
|
178 |
result = pipeline_qa(question=question_text, context=context)
|
179 |
st.subheader('Answer')
|
180 |
st.text(result['answer'])
|
|
|
181 |
elif selected_menu == "Annotation Tool":
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
{"text": "loves"},
|
186 |
-
{"text": "his"},
|
187 |
-
{"text": "dog", "labels": ["Animal", "Pet"]},
|
188 |
-
],
|
189 |
-
"labels": [
|
190 |
-
{"text": "Person"},
|
191 |
-
{"text": "Action"},
|
192 |
-
{"text": "Animal"},
|
193 |
-
]
|
194 |
-
}
|
195 |
|
196 |
st.subheader("Display Mode:")
|
197 |
left, right = st.columns(2)
|
198 |
with left:
|
199 |
st.text("Vertical labels:")
|
200 |
-
text_annotation(
|
201 |
with right:
|
202 |
st.text("Horizontal labels:")
|
203 |
data1["labelOrientation"] = "horizontal"
|
204 |
-
text_annotation(
|
205 |
-
|
206 |
-
|
207 |
-
data2 = {
|
208 |
-
"allowEditing": True,
|
209 |
-
"tokens": [
|
210 |
-
{"text": "He", "labels": ["Pronoun", "Person"]},
|
211 |
-
{"text": "loves", "labels": ["Action"]},
|
212 |
-
{"text": "his"},
|
213 |
-
{"text": "dog", "labels": ["Animal"]},
|
214 |
-
],
|
215 |
-
"labels": [
|
216 |
-
{"text": "Pronoun", "style": {
|
217 |
-
"color": "red",
|
218 |
-
"background-color": "white",
|
219 |
-
"font-size": "8px",
|
220 |
-
"border": "3px dashed red",
|
221 |
-
}},
|
222 |
-
{"text": "Verb", "style": {
|
223 |
-
"color": "green",
|
224 |
-
"background-color": "white",
|
225 |
-
"font-size": "8px",
|
226 |
-
"font-weight": "900",
|
227 |
-
}},
|
228 |
-
{"text": "Noun", "style": {
|
229 |
-
"color": "blue",
|
230 |
-
"background-color": "white",
|
231 |
-
"font-size": "8px",
|
232 |
-
}},
|
233 |
-
{"text": "Person"},
|
234 |
-
{"text": "Animal"},
|
235 |
-
]
|
236 |
-
}
|
237 |
-
|
238 |
st.subheader("Edit Mode:")
|
239 |
-
data = text_annotation(
|
240 |
if data:
|
241 |
-
"Returned data:", data
|
242 |
-
|
|
|
4 |
from io import StringIO
|
5 |
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
6 |
from text_extractor import *
|
7 |
+
from text_annotatator import *
|
8 |
import os
|
9 |
from streamlit_text_annotation import text_annotation
|
10 |
|
|
|
179 |
result = pipeline_qa(question=question_text, context=context)
|
180 |
st.subheader('Answer')
|
181 |
st.text(result['answer'])
|
182 |
+
|
183 |
elif selected_menu == "Annotation Tool":
|
184 |
+
|
185 |
+
display_only_data = get_display_only_data()
|
186 |
+
editable_data = get_editable_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
st.subheader("Display Mode:")
|
189 |
left, right = st.columns(2)
|
190 |
with left:
|
191 |
st.text("Vertical labels:")
|
192 |
+
text_annotation(display_only_data )
|
193 |
with right:
|
194 |
st.text("Horizontal labels:")
|
195 |
data1["labelOrientation"] = "horizontal"
|
196 |
+
text_annotation(display_only_data )
|
197 |
+
|
198 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
st.subheader("Edit Mode:")
|
200 |
+
data = text_annotation(editable_data)
|
201 |
if data:
|
202 |
+
"Returned data:", data
|
|