File size: 1,180 Bytes
00b4909
b68fffa
00b4909
 
d24b2fb
00b4909
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
from pyvis.network import Network
from functions import *
import streamlit.components.v1 as components
import pickle, math

st.set_page_config(page_title="Earnings Knowledge Graph", page_icon="πŸ“ˆ")
st.sidebar.header("Knowledge Graph")
st.markdown("## Earnings Knowledge Graph")

filename = "earnings_network.html"

if "earnings_passages" in st.session_state:

    with st.spinner(text='Loading Babelscape/rebel-large which can take a few minutes to generate the graph..'):
    
        st.session_state.kb_text = from_text_to_kb(st.session_state['earnings_passages'], kg_model, kg_tokenizer, "", verbose=True)
        save_network_html(st.session_state.kb_text, filename=filename)
        st.session_state.kb_chart = filename

    with st.container():
        st.subheader("Generated Knowledge Graph")
        st.markdown("*You can interact with the graph and zoom.*")
        html_source_code = open(st.session_state.kb_chart, 'r', encoding='utf-8').read()
        components.html(html_source_code, width=700, height=700)
        st.markdown(st.session_state.kb_text)

else:

    st.write('No earnings text detected, please regenerate from Home page..')