Hamda commited on
Commit
454fde7
1 Parent(s): a09216c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -11,23 +11,24 @@ model = AutoModelForMaskedLM.from_pretrained("moussaKam/AraBART")
11
 
12
  def next_word(text, pipe):
13
  res_dict= {
14
- 'token_str':[],
15
- 'score':[],
16
  }
17
  res=pipe(text)
18
  for e in res:
19
- res_dict['token_str'].append(e['token_str'])
20
- res_dict['score'].append(e['score'])
21
  return res_dict
22
 
23
  st.title("Predict Next Word")
24
  st.write("Use our model to expand your query based on the DB content")
25
  default_value = "التاريخ هو تحليل و"
26
  # sent is the the variable holding the user's input
27
- sent = st.text_area("Text", default_value, height = 60)
28
  sent += ' <mask>'
29
 
30
  pipe = pipeline("fill-mask", tokenizer = tokenizer, model = model)
31
  dict_next_words = next_word(sent, pipe)
32
  df = pd.DataFrame.from_dict(dict_next_words)
33
- st.write(df)
 
 
11
 
12
  def next_word(text, pipe):
13
  res_dict= {
14
+ 'Word':[],
15
+ 'Score':[],
16
  }
17
  res=pipe(text)
18
  for e in res:
19
+ res_dict['Word'].append(e['token_str'])
20
+ res_dict['Score'].append(e['score'])
21
  return res_dict
22
 
23
  st.title("Predict Next Word")
24
  st.write("Use our model to expand your query based on the DB content")
25
  default_value = "التاريخ هو تحليل و"
26
  # sent is the the variable holding the user's input
27
+ sent = st.text_area("Text", default_value, height = 30)
28
  sent += ' <mask>'
29
 
30
  pipe = pipeline("fill-mask", tokenizer = tokenizer, model = model)
31
  dict_next_words = next_word(sent, pipe)
32
  df = pd.DataFrame.from_dict(dict_next_words)
33
+ df.reset_index(drop=True, inplace=True)
34
+ st.table(df)