kambris commited on
Commit
42e3060
·
verified ·
1 Parent(s): dd726de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -189,7 +189,10 @@ if uploaded_file is not None:
189
  char_bigrams[bigram] += 1
190
 
191
  char_bigram_df = pd.DataFrame([
192
- {'Bigram': ''.join(bigram), 'Char1': bigram[0], 'Char2': bigram[1], 'Count': count}
 
 
 
193
  for bigram, count in char_bigrams.most_common(30)
194
  ])
195
  st.dataframe(char_bigram_df)
@@ -205,7 +208,7 @@ if uploaded_file is not None:
205
  char_trigrams[trigram] += 1
206
 
207
  char_trigram_df = pd.DataFrame([
208
- {'Trigram': ''.join(trigram), 'Count': count}
209
  for trigram, count in char_trigrams.most_common(30)
210
  ])
211
  st.dataframe(char_trigram_df)
@@ -218,7 +221,7 @@ if uploaded_file is not None:
218
  word_bigrams[bigram] += 1
219
 
220
  word_bigram_df = pd.DataFrame([
221
- {'Word1': bigram[0], 'Word2': bigram[1], 'Count': count}
222
  for bigram, count in word_bigrams.most_common(20)
223
  ])
224
  st.dataframe(word_bigram_df)
@@ -231,7 +234,10 @@ if uploaded_file is not None:
231
  word_trigrams[trigram] += 1
232
 
233
  word_trigram_df = pd.DataFrame([
234
- {'Word1': trigram[0], 'Word2': trigram[1], 'Word3': trigram[2], 'Count': count}
 
 
 
235
  for trigram, count in word_trigrams.most_common(20)
236
  ])
237
  st.dataframe(word_trigram_df)
@@ -492,7 +498,9 @@ if uploaded_file is not None:
492
  ngrams[ngram] += 1
493
 
494
  ngram_df = pd.DataFrame([
495
- {'Pattern': ''.join(ngram), 'Count': count, 'Percentage': f"{count/len(chars_list)*100:.2f}%"}
 
 
496
  for ngram, count in ngrams.most_common(30)
497
  ])
498
  st.dataframe(ngram_df)
 
189
  char_bigrams[bigram] += 1
190
 
191
  char_bigram_df = pd.DataFrame([
192
+ {'Bigram': ''.join(str(c) for c in bigram),
193
+ 'Char1': str(bigram[0]),
194
+ 'Char2': str(bigram[1]),
195
+ 'Count': int(count)}
196
  for bigram, count in char_bigrams.most_common(30)
197
  ])
198
  st.dataframe(char_bigram_df)
 
208
  char_trigrams[trigram] += 1
209
 
210
  char_trigram_df = pd.DataFrame([
211
+ {'Trigram': ''.join(str(c) for c in trigram), 'Count': int(count)}
212
  for trigram, count in char_trigrams.most_common(30)
213
  ])
214
  st.dataframe(char_trigram_df)
 
221
  word_bigrams[bigram] += 1
222
 
223
  word_bigram_df = pd.DataFrame([
224
+ {'Word1': str(bigram[0]), 'Word2': str(bigram[1]), 'Count': int(count)}
225
  for bigram, count in word_bigrams.most_common(20)
226
  ])
227
  st.dataframe(word_bigram_df)
 
234
  word_trigrams[trigram] += 1
235
 
236
  word_trigram_df = pd.DataFrame([
237
+ {'Word1': str(trigram[0]),
238
+ 'Word2': str(trigram[1]),
239
+ 'Word3': str(trigram[2]),
240
+ 'Count': int(count)}
241
  for trigram, count in word_trigrams.most_common(20)
242
  ])
243
  st.dataframe(word_trigram_df)
 
498
  ngrams[ngram] += 1
499
 
500
  ngram_df = pd.DataFrame([
501
+ {'Pattern': ''.join(str(c) for c in ngram),
502
+ 'Count': int(count),
503
+ 'Percentage': f"{count/len(chars_list)*100:.2f}%"}
504
  for ngram, count in ngrams.most_common(30)
505
  ])
506
  st.dataframe(ngram_df)