Skip to content

Commit

Permalink
try catch error
Browse files Browse the repository at this point in the history
  • Loading branch information
iyoubee committed Jun 9, 2024
1 parent 24203f6 commit 8755f3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ def predict():
# statements: list of reviews
report = {'Positive': 0, 'Negative': 0}
for statement in statements:
sentiment = predict_sentiment(statement, tokenizer, model, MAX_LENGTH)
report[sentiment] += 1
try:
sentiment = predict_sentiment(statement, tokenizer, model, MAX_LENGTH)
report[sentiment] += 1
except Exception as e:
# If an error occurs, continue to the next statement
print(f"Error occurred: {e}")
continue
return jsonify(report)

if __name__ == "__main__":
Expand Down

0 comments on commit 8755f3b

Please sign in to comment.