Update pages/4_Earnings_Knowledge_Graph_π_.py
Browse files
pages/4_Earnings_Knowledge_Graph_π_.py
CHANGED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from functions import *
|
3 |
+
import streamlit.components.v1 as components
|
4 |
+
|
5 |
+
st.set_page_config(page_title="Earnings Knowledge Graph", page_icon="π")
|
6 |
+
st.sidebar.header("Knowledge Graph")
|
7 |
+
st.markdown("## Earnings Knowledge Graph")
|
8 |
+
|
9 |
+
filename = "earnings_network.html"
|
10 |
+
|
11 |
+
if "earnings_passages" in st.session_state:
|
12 |
+
|
13 |
+
with st.spinner(text='Loading Babelscape/rebel-large which can take a few minutes to generate the graph..'):
|
14 |
+
|
15 |
+
st.session_state.kb_text = from_text_to_kb(st.session_state['earnings_passages'], kg_model, kg_tokenizer, "", verbose=True)
|
16 |
+
save_network_html(st.session_state.kb_text, filename=filename)
|
17 |
+
st.session_state.kb_chart = filename
|
18 |
+
|
19 |
+
with st.container():
|
20 |
+
st.subheader("Generated Knowledge Graph")
|
21 |
+
st.markdown("*You can interact with the graph and zoom.*")
|
22 |
+
html_source_code = open(st.session_state.kb_chart, 'r', encoding='utf-8').read()
|
23 |
+
components.html(html_source_code, width=700, height=700)
|
24 |
+
st.markdown(st.session_state.kb_text)
|
25 |
+
|
26 |
+
else:
|
27 |
+
|
28 |
+
st.write('No earnings text detected, please regenerate from Home page..')
|