khaerens commited on
Commit
717cbd4
1 Parent(s): c10ba2f

added credits

Browse files
.vscode/settings.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "workbench.colorCustomizations": {
3
- "activityBar.background": "#09323E",
4
- "titleBar.activeBackground": "#0C4656",
5
- "titleBar.activeForeground": "#F6FCFE"
6
  }
7
  }
 
1
  {
2
  "workbench.colorCustomizations": {
3
+ "activityBar.background": "#630018",
4
+ "titleBar.activeBackground": "#8A0121",
5
+ "titleBar.activeForeground": "#FFFBFC"
6
  }
7
  }
__pycache__/utils.cpython-38.pyc CHANGED
Binary files a/__pycache__/utils.cpython-38.pyc and b/__pycache__/utils.cpython-38.pyc differ
 
app.py CHANGED
@@ -13,14 +13,13 @@ 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,
20
  'wiki_suggestions': [],
21
  'wiki_text' : [],
22
  'nodes':[],
23
- "topics":[]
24
  }
25
 
26
  free_text_state_variables = {
@@ -33,6 +32,8 @@ def wiki_init_state_variables():
33
  st.session_state[k] = v
34
 
35
  def wiki_generate_graph():
 
 
36
  if 'wiki_text' not in st.session_state:
37
  return
38
  if len(st.session_state['wiki_text']) == 0:
@@ -41,7 +42,7 @@ def wiki_generate_graph():
41
  with st.spinner(text="Generating graph..."):
42
  texts = st.session_state['wiki_text']
43
  st.session_state['nodes'] = []
44
- nodes = rebel.generate_knowledge_graph(texts, GRAPH_FILENAME)
45
  print("gen_graph", nodes)
46
  for n in nodes:
47
  n = n.lower()
@@ -92,8 +93,10 @@ def wiki_reset_session():
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
 
99
  def free_text_layout():
@@ -153,10 +156,10 @@ def show_wiki_hub_page():
153
  """
154
  )
155
 
156
- HtmlFile = open(GRAPH_FILENAME, 'r', encoding='utf-8')
157
  source_code = HtmlFile.read()
158
  components.html(source_code, width=720, height=600)
159
-
160
  num_buttons = len(st.session_state["nodes"])
161
  num_cols = num_buttons if 0 < num_buttons < 7 else 7
162
  columns = st.columns([1] * num_cols + [1])
@@ -175,22 +178,29 @@ def show_free_text_hub_page():
175
  - Click generate!
176
  """
177
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  st.sidebar.button("Reset", key="reset_key")
179
  free_text_layout()
180
  if st.session_state['has_run']:
181
- st.sidebar.markdown(
182
- """
183
- # How to expand the graph
184
- - Click a button on the right to expand that node
185
- - Only nodes that have wiki pages will be expanded
186
- - Hit the Generate button again to expand your graph!
187
- """
188
- )
189
-
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()
 
13
  from datetime import datetime as dt
14
  import os
15
 
 
16
 
17
  wiki_state_variables = {
18
  'has_run':False,
19
  'wiki_suggestions': [],
20
  'wiki_text' : [],
21
  'nodes':[],
22
+ "topics":[],
23
  }
24
 
25
  free_text_state_variables = {
 
32
  st.session_state[k] = v
33
 
34
  def wiki_generate_graph():
35
+ st.session_state["GRAPH_FILENAME"] = str(dt.now().timestamp()*1000) + ".html"
36
+
37
  if 'wiki_text' not in st.session_state:
38
  return
39
  if len(st.session_state['wiki_text']) == 0:
 
42
  with st.spinner(text="Generating graph..."):
43
  texts = st.session_state['wiki_text']
44
  st.session_state['nodes'] = []
45
+ nodes = rebel.generate_knowledge_graph(texts, st.session_state["GRAPH_FILENAME"])
46
  print("gen_graph", nodes)
47
  for n in nodes:
48
  n = n.lower()
 
93
  del st.session_state[k]
94
 
95
  def free_text_generate():
96
+ st.session_state["GRAPH_FILENAME"] = str(dt.now().timestamp()*1000) + ".html"
97
+
98
  text = st.session_state['free_text'][0:500]
99
+ rebel.generate_knowledge_graph([text], st.session_state["GRAPH_FILENAME"])
100
  st.session_state['has_run'] = True
101
 
102
  def free_text_layout():
 
156
  """
157
  )
158
 
159
+ HtmlFile = open(st.session_state["GRAPH_FILENAME"], 'r', encoding='utf-8')
160
  source_code = HtmlFile.read()
161
  components.html(source_code, width=720, height=600)
162
+ os.remove(st.session_state["GRAPH_FILENAME"])
163
  num_buttons = len(st.session_state["nodes"])
164
  num_cols = num_buttons if 0 < num_buttons < 7 else 7
165
  columns = st.columns([1] * num_cols + [1])
 
178
  - Click generate!
179
  """
180
  )
181
+ st.sidebar.markdown(
182
+ """
183
+ # How to expand the graph
184
+ - Click a button on the right to expand that node
185
+ - Only nodes that have wiki pages will be expanded
186
+ - Hit the Generate button again to expand your graph!
187
+ """
188
+ )
189
+
190
+ st.sidebar.markdown(
191
+ """
192
+ Credits for the REBEL model go out to Pere-Lluís Huguet Cabot and Roberto Navigli.
193
+ The code can be found [here](https://github.com/Babelscape/rebel),
194
+ and the original paper [here](https://github.com/Babelscape/rebel/blob/main/docs/EMNLP_2021_REBEL__Camera_Ready_.pdf)
195
+ """
196
+ )
197
  st.sidebar.button("Reset", key="reset_key")
198
  free_text_layout()
199
  if st.session_state['has_run']:
200
+ HtmlFile = open(st.session_state["GRAPH_FILENAME"], 'r', encoding='utf-8')
 
 
 
 
 
 
 
 
 
201
  source_code = HtmlFile.read()
202
  components.html(source_code, width=720, height=600)
203
+ os.remove(st.session_state["GRAPH_FILENAME"])
204
 
205
  if st.session_state['input_method'] == "wikipedia":
206
  wiki_init_state_variables()