entropy25 commited on
Commit
f2a9ccf
Β·
verified Β·
1 Parent(s): a990dc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -1950,6 +1950,19 @@ def create_gradio_interface():
1950
  placeholder="Enter review text (one per line) or upload file...",
1951
  label="Review Text"
1952
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
1953
  sentiment_file = gr.File(
1954
  label="Upload CSV/Excel File",
1955
  file_types=[".csv", ".xlsx", ".xls"]
@@ -1966,21 +1979,6 @@ def create_gradio_interface():
1966
  sentiment_chart1 = gr.Plot(label="Sentiment Distribution")
1967
  sentiment_chart2 = gr.Plot(label="Confidence Distribution")
1968
 
1969
- # Example reviews section
1970
- gr.Markdown("### Sample Reviews - Click to use:")
1971
-
1972
- examples = [
1973
- ("Positive Review", "This wireless speaker has amazing sound quality and battery life. The bass is deep and clear, lasting over 8 hours on a single charge. Setup was incredibly easy - just paired instantly with my phone. Build quality feels premium and durable. Customer service was helpful with my questions. Perfect for outdoor gatherings and travel. Highly recommend this product to anyone looking for portable audio. Worth every penny and exceeded my expectations!"),
1974
-
1975
- ("Negative Review", "Very disappointed with this purchase. The product looks nothing like the photos and feels cheaply made. Sizing is completely wrong - ordered Large but fits like Medium. After one week the zipper started sticking and threads came loose. Customer service is slow to respond and unhelpful. Return process has been a nightmare. Save your money and buy elsewhere. Not recommended at all."),
1976
-
1977
- ("Mixed Review", "This coffee maker has good and bad points. Makes decent coffee with good temperature control and the timer works well. Keeps coffee warm without burning. However, water reservoir is too small and needs constant refilling. Some plastic parts feel cheap. Instructions could be clearer. For the price it's adequate but not exceptional. Gets the job done but better options might exist.")
1978
- ]
1979
-
1980
- for title, review in examples:
1981
- example_btn = gr.Button(f"πŸ“ {title}")
1982
- example_btn.click(lambda r=review: r, outputs=sentiment_text)
1983
-
1984
  sentiment_btn.click(
1985
  sentiment_analysis_interface,
1986
  inputs=[sentiment_text, sentiment_file, sentiment_lang],
 
1950
  placeholder="Enter review text (one per line) or upload file...",
1951
  label="Review Text"
1952
  )
1953
+
1954
+ # Sample reviews right under the text box
1955
+ gr.Markdown("**Sample Reviews:**")
1956
+
1957
+ positive_btn = gr.Button("πŸ“ Positive: Amazing product! Sound quality is excellent, battery lasts all day. Easy setup and great build quality. Highly recommend for anyone looking for reliable wireless speaker. Worth the money!", size="sm")
1958
+ positive_btn.click(lambda: "Amazing product! Sound quality is excellent, battery lasts all day. Easy setup and great build quality. Highly recommend for anyone looking for reliable wireless speaker. Worth the money!", outputs=sentiment_text)
1959
+
1960
+ negative_btn = gr.Button("πŸ“ Negative: Terrible purchase. Product broke after two days, looks nothing like photos. Poor quality materials and unhelpful customer service. Complete waste of money, do not buy!", size="sm")
1961
+ negative_btn.click(lambda: "Terrible purchase. Product broke after two days, looks nothing like photos. Poor quality materials and unhelpful customer service. Complete waste of money, do not buy!", outputs=sentiment_text)
1962
+
1963
+ mixed_btn = gr.Button("πŸ“ Mixed: Coffee maker works okay. Good temperature control but small water reservoir. Some parts feel cheap. Decent for the price but not exceptional quality.", size="sm")
1964
+ mixed_btn.click(lambda: "Coffee maker works okay. Good temperature control but small water reservoir. Some parts feel cheap. Decent for the price but not exceptional quality.", outputs=sentiment_text)
1965
+
1966
  sentiment_file = gr.File(
1967
  label="Upload CSV/Excel File",
1968
  file_types=[".csv", ".xlsx", ".xls"]
 
1979
  sentiment_chart1 = gr.Plot(label="Sentiment Distribution")
1980
  sentiment_chart2 = gr.Plot(label="Confidence Distribution")
1981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1982
  sentiment_btn.click(
1983
  sentiment_analysis_interface,
1984
  inputs=[sentiment_text, sentiment_file, sentiment_lang],