cn91 commited on
Commit
aaab29f
·
1 Parent(s): 0a6e4e2

Update app.py

Browse files

Catch error when target word is not used

Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -116,6 +116,8 @@ st.subheader("Form your sentence and input below!")
116
  sentence = st.text_input('Enter your sentence here', placeholder="Enter your sentence here!")
117
 
118
  if st.button("Grade"):
 
 
119
  top_k_prediction, score = assess_sentence(target_word, sentence)
120
  with open('./result01.json', 'w') as outfile:
121
  outfile.write(str(top_k_prediction))
 
116
  sentence = st.text_input('Enter your sentence here', placeholder="Enter your sentence here!")
117
 
118
  if st.button("Grade"):
119
+ if sentence.find(target_word) == -1:
120
+ st.error("Error: Sentence must include the target word!")
121
  top_k_prediction, score = assess_sentence(target_word, sentence)
122
  with open('./result01.json', 'w') as outfile:
123
  outfile.write(str(top_k_prediction))