loubnabnl HF staff commited on
Commit
c2c2487
·
1 Parent(s): 2d9be28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import json
3
+ from datasets import load_dataset
4
+
5
+ st.set_page_config(page_title="Bot Issues", layout="wide")
6
+ st.title("Bot Issues")
7
+
8
+ @st.cache()
9
+ def load_data():
10
+ ds = load_dataset("loubnabnl/bot_issues", split="train")
11
+ return ds
12
+
13
+ def print_issue(events):
14
+ for event in events:
15
+ print("-" * 75)
16
+ masked_author = f"masked as {event['masked_author']}" if "masked_author" in event else ""
17
+ st.write(f"author: {event['author']} {masked_author}, {event['action']} {event['type']}: {event['title']}")
18
+ st.write(f"text: {event['text']}")
19
+
20
+ samples = load_data()
21
+ col1, _ = st.columns([2, 4])
22
+ with col1:
23
+ index_example = st.number_input(f"Index of the chosen example from the existing {len(samples)}", min_value=0, max_value=max_docs-1, value=0, step=1)
24
+
25
+ st.write(f"Issue size: {samples[index_example]['text_size_bots']}\n\n")
26
+ print_issue(samples[index_example]["old_events"])
27
+