Update app.py
Browse files
app.py
CHANGED
@@ -11,23 +11,24 @@ model = AutoModelForMaskedLM.from_pretrained("moussaKam/AraBART")
|
|
11 |
|
12 |
def next_word(text, pipe):
|
13 |
res_dict= {
|
14 |
-
'
|
15 |
-
'
|
16 |
}
|
17 |
res=pipe(text)
|
18 |
for e in res:
|
19 |
-
res_dict['
|
20 |
-
res_dict['
|
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 =
|
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 |
-
|
|
|
|
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)
|