AIEcosystem commited on
Commit
72681a3
·
verified ·
1 Parent(s): 3162f3d

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +8 -5
src/streamlit_app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  os.environ['HF_HOME'] = '/tmp'
3
  import time
@@ -395,14 +396,17 @@ def generate_html_report(df, text_input, elapsed_time, df_topic_data):
395
  <p><strong>Generated At:</strong> {time.strftime('%Y-%m-%d %H:%M:%S')}</p>
396
  <p><strong>Processing Time:</strong> {elapsed_time:.2f} seconds</p>
397
  </div>
 
398
  <h2>1. Analyzed Text & Extracted Entities</h2>
399
  <h3>Original Text with Highlighted Entities</h3>
400
  <div class="highlighted-text-container">
401
  {highlighted_text_html}
402
  </div>
403
 
 
404
  <h2>2. Full Extracted Entities Table</h2>
405
  {entity_table_html}
 
406
  <h2>3. Data Visualizations</h2>
407
 
408
  <h3>3.1 Entity Distribution Treemap</h3>
@@ -416,6 +420,7 @@ def generate_html_report(df, text_input, elapsed_time, df_topic_data):
416
  <h3>3.3 Entity Co-occurrence Network (Edges = Same Sentence)</h3>
417
  <div class="chart-box">{network_html}</div>
418
 
 
419
  <h2>4. Topic Modeling (LDA on Entities)</h2>
420
  {topic_charts_html}
421
 
@@ -577,17 +582,18 @@ if st.button("Results"):
577
  st.session_state.topic_results = perform_topic_modeling(
578
  df,
579
  num_topics=2,
580
- num_top_words=N_TOP_WORDS_TO_USE
581
  )
582
 
583
  if comet_initialized:
 
584
  experiment = Experiment(api_key=COMET_API_KEY, workspace=COMET_WORKSPACE, project_name=COMET_PROJECT_NAME)
585
  experiment.log_parameter("input_text", text)
586
  experiment.log_table("predicted_entities", df)
587
  experiment.end()
588
  else:
589
  st.session_state.results_df = pd.DataFrame()
590
- st.session_state.topic_results = None
591
 
592
  end_time = time.time()
593
  st.session_state.elapsed_time = end_time - start_time
@@ -740,6 +746,3 @@ if st.session_state.show_results:
740
  file_name=f"entity_topic_report_{time.strftime('%Y%m%d_%H%M%S')}.html",
741
  mime="text/html",
742
  )
743
-
744
-
745
-
 
1
+
2
  import os
3
  os.environ['HF_HOME'] = '/tmp'
4
  import time
 
396
  <p><strong>Generated At:</strong> {time.strftime('%Y-%m-%d %H:%M:%S')}</p>
397
  <p><strong>Processing Time:</strong> {elapsed_time:.2f} seconds</p>
398
  </div>
399
+ <!-- Section 1: Original Text & Highlighted Entities -->
400
  <h2>1. Analyzed Text & Extracted Entities</h2>
401
  <h3>Original Text with Highlighted Entities</h3>
402
  <div class="highlighted-text-container">
403
  {highlighted_text_html}
404
  </div>
405
 
406
+ <!-- Section 2: Full Extracted Entities Table -->
407
  <h2>2. Full Extracted Entities Table</h2>
408
  {entity_table_html}
409
+ <!-- Section 3: Visualizations (Treemap, Pie, Bar Charts) -->
410
  <h2>3. Data Visualizations</h2>
411
 
412
  <h3>3.1 Entity Distribution Treemap</h3>
 
420
  <h3>3.3 Entity Co-occurrence Network (Edges = Same Sentence)</h3>
421
  <div class="chart-box">{network_html}</div>
422
 
423
+ <!-- Section 4: Topic Modeling -->
424
  <h2>4. Topic Modeling (LDA on Entities)</h2>
425
  {topic_charts_html}
426
 
 
582
  st.session_state.topic_results = perform_topic_modeling(
583
  df,
584
  num_topics=2,
585
+ num_top_words=N_TOP_WORDS_TO_USE
586
  )
587
 
588
  if comet_initialized:
589
+ # FIX APPLIED HERE: Corrected indentation for the following lines
590
  experiment = Experiment(api_key=COMET_API_KEY, workspace=COMET_WORKSPACE, project_name=COMET_PROJECT_NAME)
591
  experiment.log_parameter("input_text", text)
592
  experiment.log_table("predicted_entities", df)
593
  experiment.end()
594
  else:
595
  st.session_state.results_df = pd.DataFrame()
596
+ st.session_state.topic_results = None
597
 
598
  end_time = time.time()
599
  st.session_state.elapsed_time = end_time - start_time
 
746
  file_name=f"entity_topic_report_{time.strftime('%Y%m%d_%H%M%S')}.html",
747
  mime="text/html",
748
  )