Spaces:
Runtime error
Runtime error
kandysh
commited on
Commit
•
d06d573
1
Parent(s):
06924e0
added app file
Browse files
app.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import spacy_streamlit
|
2 |
+
import streamlit as st
|
3 |
+
import json
|
4 |
+
import pyautogui
|
5 |
+
from normalizer import process_df
|
6 |
+
from process_tags import list_ents, no_of_tags, color_creator, scatter_document
|
7 |
+
|
8 |
+
tags_data = {
|
9 |
+
"_dtags_": [],
|
10 |
+
"DEP": [],
|
11 |
+
"dep_explain": {},
|
12 |
+
"_ptags_": [],
|
13 |
+
"POS": [],
|
14 |
+
"pos_explain": {},
|
15 |
+
"_ntags_": ["concept", "tool", "framework", "crew", "position", "measurement", "artifact", "datasheet", "briefing", "standard", "insight", "client", "output", "output_component", "system", "challenge", "environment", "process", "process_component", "activity", "business_need", "third_party", "agreement", "raw_data", "authority", "resource_pool", "field_of_study", "geo_loc", "TBD"],
|
16 |
+
"NER": ["concept", "#e3648a", "tool", "#d56b2e", "framework", "#ff0000", "crew", "#ffafcc", "position", "#a2cd5a", "measurement", "#779be7", "artifact", "#bee1e6", "datasheet", "#7e7d61", "briefing", "#4b8d76", "standard", "#9381ff", "insight", "#ffc125", "client", "#ffc6ff", "output", "#ffcfd2", "output_component", "#fde4cf", "system", "#656e1b", "challenge", "#ff5400", "environment", "#affc41", "process", "#adc178", "process_component", "#dde5b6", "activity", "#cfbaf0", "business_need", "#ced4da", "third_party", "#ee00ee", "agreement", "#484676", "raw_data", "#cdad00", "authority", "#d689c4", "resource_pool", "#8ea44c", "field_of_study", "#c39fe9", "geo_loc", "#c0ff3e", "TBD", "#ccdbfd"],
|
17 |
+
"ner_explain": {},
|
18 |
+
"_ctags_": [],
|
19 |
+
"CAT": [],
|
20 |
+
"cat_explain": {}
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
st.set_page_config(layout='wide')
|
26 |
+
st.title("My Tag Visualizer")
|
27 |
+
if st.button("Reset"):
|
28 |
+
pyautogui.hotkey("ctrl", "F5")
|
29 |
+
with st.sidebar:
|
30 |
+
uploaded_file = st.file_uploader("Upload the sentence Json", type="json")
|
31 |
+
# uploaded_color = st.file_uploader("Upload the tag Json", type="json")
|
32 |
+
if uploaded_file and uploaded_color is not None:
|
33 |
+
raw_data = json.load(uploaded_file)
|
34 |
+
# tags_data = json.load(uploaded_color)
|
35 |
+
df_list = []
|
36 |
+
key = 0
|
37 |
+
for data in raw_data:
|
38 |
+
df_list.append(process_df(data))
|
39 |
+
st.plotly_chart(scatter_document(df_list, tags_data), use_container_width=False)
|
40 |
+
tags = []
|
41 |
+
ent = []
|
42 |
+
for df in df_list:
|
43 |
+
ent = list_ents(df)
|
44 |
+
tags = list(no_of_tags(df).keys())
|
45 |
+
doc = [{
|
46 |
+
"text": ' '.join(df['words']),
|
47 |
+
"ents": ent,
|
48 |
+
"title": None
|
49 |
+
}]
|
50 |
+
spacy_streamlit.visualize_ner(
|
51 |
+
doc,
|
52 |
+
labels=tags,
|
53 |
+
show_table=False,
|
54 |
+
title=None,
|
55 |
+
manual=True,
|
56 |
+
displacy_options={
|
57 |
+
"colors": color_creator(tags_data["NER"])
|
58 |
+
},
|
59 |
+
key=f"{key}"
|
60 |
+
)
|
61 |
+
key += 1
|