khaerens commited on
Commit
837b4d7
1 Parent(s): c7f7675
Files changed (2) hide show
  1. app.py +5 -5
  2. utils.py +1 -1
app.py CHANGED
@@ -13,7 +13,7 @@ from utils import clip_text
13
  from datetime import datetime as dt
14
  import os
15
 
16
-
17
 
18
  wiki_state_variables = {
19
  'has_run_wiki':False,
@@ -60,7 +60,7 @@ def wiki_generate_graph():
60
  for n in nodes:
61
  n = n.lower()
62
  if n not in st.session_state['topics']:
63
- possible_topics = wikipedia.search(n, results = 3)
64
  st.session_state['nodes'].extend(possible_topics)
65
  st.session_state['nodes'] = list(set(st.session_state['nodes']))
66
  st.session_state['has_run_wiki'] = True
@@ -72,7 +72,7 @@ def wiki_show_suggestion():
72
  if st.session_state['input_method'] == "wikipedia":
73
  text = st.session_state.text
74
  if (text is not None) and (text is not ""):
75
- subjects = text.split(",")[:5]
76
  for subj in subjects:
77
  st.session_state['wiki_suggestions'] += wikipedia.search(subj, results = 3)
78
 
@@ -93,7 +93,7 @@ def wiki_show_text(page_title):
93
  st.session_state['wiki_suggestions'].remove(page_title)
94
 
95
  def wiki_add_text(term):
96
- if len(st.session_state['wiki_text']) > 4:
97
  return
98
  try:
99
  page = wikipedia.page(title=term, auto_suggest=False)
@@ -123,7 +123,7 @@ def free_reset_session():
123
 
124
  def free_text_generate():
125
  st.session_state["GRAPH_FILENAME"] = str(dt.now().timestamp()*1000) + ".html"
126
- text = st.session_state['free_text'][0:500]
127
  rebel.generate_knowledge_graph([text], st.session_state["GRAPH_FILENAME"])
128
  HtmlFile = open(st.session_state["GRAPH_FILENAME"], 'r', encoding='utf-8')
129
  source_code = HtmlFile.read()
 
13
  from datetime import datetime as dt
14
  import os
15
 
16
+ MAX_TOPICS = 3
17
 
18
  wiki_state_variables = {
19
  'has_run_wiki':False,
 
60
  for n in nodes:
61
  n = n.lower()
62
  if n not in st.session_state['topics']:
63
+ possible_topics = wikipedia.search(n, results = 2)
64
  st.session_state['nodes'].extend(possible_topics)
65
  st.session_state['nodes'] = list(set(st.session_state['nodes']))
66
  st.session_state['has_run_wiki'] = True
 
72
  if st.session_state['input_method'] == "wikipedia":
73
  text = st.session_state.text
74
  if (text is not None) and (text is not ""):
75
+ subjects = text.split(",")[:MAX_TOPICS]
76
  for subj in subjects:
77
  st.session_state['wiki_suggestions'] += wikipedia.search(subj, results = 3)
78
 
 
93
  st.session_state['wiki_suggestions'].remove(page_title)
94
 
95
  def wiki_add_text(term):
96
+ if len(st.session_state['wiki_text']) > MAX_TOPICS:
97
  return
98
  try:
99
  page = wikipedia.page(title=term, auto_suggest=False)
 
123
 
124
  def free_text_generate():
125
  st.session_state["GRAPH_FILENAME"] = str(dt.now().timestamp()*1000) + ".html"
126
+ text = st.session_state['free_text'][0:100]
127
  rebel.generate_knowledge_graph([text], st.session_state["GRAPH_FILENAME"])
128
  HtmlFile = open(st.session_state["GRAPH_FILENAME"], 'r', encoding='utf-8')
129
  source_code = HtmlFile.read()
utils.py CHANGED
@@ -1,2 +1,2 @@
1
- def clip_text(t, lenght = 5):
2
  return ".".join(t.split(".")[:lenght]) + "."
 
1
+ def clip_text(t, lenght = 3):
2
  return ".".join(t.split(".")[:lenght]) + "."