darkproger commited on
Commit
4f9f819
·
1 Parent(s): d02038d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -17,12 +17,18 @@ with st.echo():
17
  eng_num_tokens = dataset.map(lambda x: {'num_tokens':len(tokenizer(x['sentence_eng_Latn'])['input_ids'])})['num_tokens']
18
  ukr_num_tokens = dataset.map(lambda x: {'num_tokens':len(tokenizer(x['sentence_ukr_Cyrl'])['input_ids'])})['num_tokens']
19
 
20
- fig, (axl, axr) = plt.subplots(1, 2, figsize=(10,3))
21
- axl.hist(eng_num_tokens)
22
- axl.set_title(f'eng mistral tokens ({np.sum(eng_num_tokens)} total)')
23
- axr.hist(ukr_num_tokens)
24
- axr.set_title(f'ukr mistral tokens ({np.sum(ukr_num_tokens)} total)')
25
- st.pyplot(fig)
 
 
 
26
 
27
- st.dataframe(pd.DataFrame(dataset))
 
 
 
28
 
 
17
  eng_num_tokens = dataset.map(lambda x: {'num_tokens':len(tokenizer(x['sentence_eng_Latn'])['input_ids'])})['num_tokens']
18
  ukr_num_tokens = dataset.map(lambda x: {'num_tokens':len(tokenizer(x['sentence_ukr_Cyrl'])['input_ids'])})['num_tokens']
19
 
20
+ with st.sidebar:
21
+ fig, (axl, axr) = plt.subplots(2, 1, figsize=(3,10))
22
+ axl.hist(eng_num_tokens)
23
+ axl.set_title(f'eng mistral tokens ({np.sum(eng_num_tokens)} total)')
24
+ axr.hist(ukr_num_tokens)
25
+ axr.set_title(f'ukr mistral tokens ({np.sum(ukr_num_tokens)} total)')
26
+ st.pyplot(fig)
27
+
28
+ keyword = st.text_input("Filter by text", value="")
29
 
30
+ if not keyword:
31
+ st.dataframe(pd.DataFrame(dataset))
32
+ else:
33
+ st.dataframe(pd.DataFrame(dataset.filter(lambda x: keyword in x['sentence_eng_Latn'] or keyword in x['sentence_ukr_Cyrl'])))
34