Spaces:
Build error
Build error
limit
Browse files- .vscode/settings.json +7 -0
- app.py +7 -3
- utils.py +1 -1
.vscode/settings.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"workbench.colorCustomizations": {
|
3 |
+
"activityBar.background": "#09323E",
|
4 |
+
"titleBar.activeBackground": "#0C4656",
|
5 |
+
"titleBar.activeForeground": "#F6FCFE"
|
6 |
+
}
|
7 |
+
}
|
app.py
CHANGED
@@ -10,8 +10,10 @@ from streamlit.type_util import Key
|
|
10 |
import rebel
|
11 |
import wikipedia
|
12 |
from utils import clip_text
|
|
|
|
|
13 |
|
14 |
-
GRAPH_FILENAME = "
|
15 |
|
16 |
wiki_state_variables = {
|
17 |
'has_run':False,
|
@@ -71,6 +73,8 @@ def wiki_show_text(page_title):
|
|
71 |
st.session_state['wiki_suggestions'] = list(set(temp))
|
72 |
|
73 |
def wiki_add_text(term):
|
|
|
|
|
74 |
try:
|
75 |
extra_text = clip_text(wikipedia.page(title=term, auto_suggest=False).summary)
|
76 |
st.session_state['wiki_text'].append(extra_text)
|
@@ -88,7 +92,7 @@ def wiki_reset_session():
|
|
88 |
del st.session_state[k]
|
89 |
|
90 |
def free_text_generate():
|
91 |
-
text = st.session_state['free_text']
|
92 |
rebel.generate_knowledge_graph([text], GRAPH_FILENAME)
|
93 |
st.session_state['has_run'] = True
|
94 |
|
@@ -186,7 +190,7 @@ def show_free_text_hub_page():
|
|
186 |
HtmlFile = open(GRAPH_FILENAME, 'r', encoding='utf-8')
|
187 |
source_code = HtmlFile.read()
|
188 |
components.html(source_code, width=720, height=600)
|
189 |
-
|
190 |
|
191 |
if st.session_state['input_method'] == "wikipedia":
|
192 |
wiki_init_state_variables()
|
|
|
10 |
import rebel
|
11 |
import wikipedia
|
12 |
from utils import clip_text
|
13 |
+
from datetime import datetime as dt
|
14 |
+
import os
|
15 |
|
16 |
+
GRAPH_FILENAME = str(dt.now().timestamp) + ".html"
|
17 |
|
18 |
wiki_state_variables = {
|
19 |
'has_run':False,
|
|
|
73 |
st.session_state['wiki_suggestions'] = list(set(temp))
|
74 |
|
75 |
def wiki_add_text(term):
|
76 |
+
if len(st.session_state['topics']) > 4:
|
77 |
+
return
|
78 |
try:
|
79 |
extra_text = clip_text(wikipedia.page(title=term, auto_suggest=False).summary)
|
80 |
st.session_state['wiki_text'].append(extra_text)
|
|
|
92 |
del st.session_state[k]
|
93 |
|
94 |
def free_text_generate():
|
95 |
+
text = st.session_state['free_text'][0:500]
|
96 |
rebel.generate_knowledge_graph([text], GRAPH_FILENAME)
|
97 |
st.session_state['has_run'] = True
|
98 |
|
|
|
190 |
HtmlFile = open(GRAPH_FILENAME, 'r', encoding='utf-8')
|
191 |
source_code = HtmlFile.read()
|
192 |
components.html(source_code, width=720, height=600)
|
193 |
+
os.remove(GRAPH_FILENAME)
|
194 |
|
195 |
if st.session_state['input_method'] == "wikipedia":
|
196 |
wiki_init_state_variables()
|
utils.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
def clip_text(t, lenght =
|
2 |
return ".".join(t.split(".")[:lenght]) + "."
|
|
|
1 |
+
def clip_text(t, lenght = 5):
|
2 |
return ".".join(t.split(".")[:lenght]) + "."
|