MAli7319 commited on
Commit
4df79e9
·
1 Parent(s): ab2e1ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -35,14 +35,15 @@ def user_interaction(comment, model):
35
  compound_score = analyzer.polarity_scores(comment)["compound"]
36
  rate_pred = model.predict([[negative_score, neutral_score, positive_score, compound_score]])
37
 
38
- return (f"\nYour Comment: {comment}\n" +
 
39
  "*"*10 + "Analysis of the Comment" + "*"*10 + "\n" +
40
  "-"*10 + f"Negativity Score: {negative_score:.2f}" + "-"*10 + "\n" +
41
  "-"*10 + f"Neutrality Score: {neutral_score:.2f}" + "-"*10 + "\n" +
42
  "-"*10 + f"Positivity Score: {positive_score:.2f}" + "-"*10 + "\n" +
43
  "-"*10 + f"Compound Score: {compound_score:.2f}" + "-"*10 + "\n" +
44
  "*"*43 + "\n"), ("\nThe estimated rating this comment can give" + "\n" +
45
- "*"*20 + str(round(rate_pred[0], 2)) + "*"*20 + "\n")
46
 
47
 
48
  def take_input(model):
@@ -58,12 +59,17 @@ with gr.Blocks() as demo:
58
  gr.Markdown("# AIN311 Project P05 - MOOC Recommendation")
59
  gr.Markdown("## Generating a Rating from User Comment")
60
  with gr.Column():
61
- comment = gr.Textbox(label="Thanks for your interest and taking your time.\n"+
62
- "Tell us about your personal experience enrolling in this course. Was it the right match for you?\n"+
63
- "(Note: Comment should be written in English and be longer than 20 characters)\n")
 
64
  button = gr.Button("What is the Rating I Gave? Click me to Learn")
65
- comment_scores = gr.Textbox(label="Sentiment Scores of Your Comment")
66
- rating = gr.Textbox(label="Generated Rating from Your Comment")
67
- button.click(fn=take_input, inputs=comment, outputs=[comment_scores, rating])
 
 
 
 
68
 
69
  demo.launch()
 
35
  compound_score = analyzer.polarity_scores(comment)["compound"]
36
  rate_pred = model.predict([[negative_score, neutral_score, positive_score, compound_score]])
37
 
38
+ return round(negative_score,2), round(neutral_score,2), round(positive_score,2), round(compound_score,2), round(rate_pred[0],2)
39
+ """return (f"\nYour Comment: {comment}\n" +
40
  "*"*10 + "Analysis of the Comment" + "*"*10 + "\n" +
41
  "-"*10 + f"Negativity Score: {negative_score:.2f}" + "-"*10 + "\n" +
42
  "-"*10 + f"Neutrality Score: {neutral_score:.2f}" + "-"*10 + "\n" +
43
  "-"*10 + f"Positivity Score: {positive_score:.2f}" + "-"*10 + "\n" +
44
  "-"*10 + f"Compound Score: {compound_score:.2f}" + "-"*10 + "\n" +
45
  "*"*43 + "\n"), ("\nThe estimated rating this comment can give" + "\n" +
46
+ "*"*20 + str(round(rate_pred[0], 2)) + "*"*20 + "\n")"""
47
 
48
 
49
  def take_input(model):
 
59
  gr.Markdown("# AIN311 Project P05 - MOOC Recommendation")
60
  gr.Markdown("## Generating a Rating from User Comment")
61
  with gr.Column():
62
+ comment = gr.Textbox(label="### Thanks for your interest and taking your time." +
63
+ "#### Tell us about your personal experience enrolling in this course. Was it the right match for you?\n"+
64
+ "#### (Note: Comment should be written in English and be longer than 20 characters)\n",
65
+ placeholder="Write your comment here...")
66
  button = gr.Button("What is the Rating I Gave? Click me to Learn")
67
+ gr.Markdown("#### Sentiment Scores of Your Comment")
68
+ negscore = gr.Number(label="Negativity Score")
69
+ neuscore = gr.Number(label="Neutrality Score")
70
+ posscore = gr.Number(label="Positivity Score")
71
+ compscore = gr.Number(label="Compound Score")
72
+ rating = gr.Number(label="Generated Rating from Your Comment")
73
+ button.click(fn=take_input, inputs=comment, outputs=[negscore, neuscore, posscore, compscore, rating])
74
 
75
  demo.launch()