Hamda commited on
Commit
e7bd68e
·
1 Parent(s): 28b7f46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -23,20 +23,21 @@ def next_word(text, pipe):
23
  st.title("Predict Next Word")
24
  st.write("Expand your query by leveraging various models")
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
 
35
- chart_data = pd.DataFrame(
36
- np.random.randn(50, 3),
37
- columns=["a", "b", "c"])
38
-
39
- st.bar_chart(chart_data)
40
  #st.dataframe(df)
41
 
42
  #st.bar_chart(df)
 
23
  st.title("Predict Next Word")
24
  st.write("Expand your query by leveraging various models")
25
  default_value = "التاريخ هو تحليل و"
26
+ # sent is the variable holding the user's input
27
+ sent = st.text_area("Input", default_value, height=30)
28
+ if len(sent)>20:
29
+ text_st = sent[-20:]
30
+ text_st += ' <mask>'
31
+ else:
32
+ text_st = sent+ ' <mask>'
33
 
34
  pipe = pipeline("fill-mask", tokenizer=tokenizer, model=model)
35
+ dict_next_words = next_word(text_st, pipe)
36
  df = pd.DataFrame.from_dict(dict_next_words)
37
+ #df.reset_index(drop=True, inplace=True)
38
 
39
+ st.dataframe(df)
40
+ st.bar_chart(df)
 
 
 
41
  #st.dataframe(df)
42
 
43
  #st.bar_chart(df)