Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ sentiment_analysis = pipeline("sentiment-analysis", model=model, tokenizer=token
|
|
14 |
st.title("GPT-2 Movie Sentiment Analysis")
|
15 |
|
16 |
# Input text for sentiment analysis
|
17 |
-
input_text = st.text_area("Enter movie
|
18 |
|
19 |
# Choose analysis type
|
20 |
analysis_type = st.radio("Select analysis type:", ["Zero-shot", "One-shot", "Few-shot"])
|
@@ -22,18 +22,23 @@ analysis_type = st.radio("Select analysis type:", ["Zero-shot", "One-shot", "Few
|
|
22 |
if st.button("Analyze Sentiment"):
|
23 |
# Perform sentiment analysis based on the selected type
|
24 |
if analysis_type == "Zero-shot":
|
|
|
|
|
25 |
results = sentiment_analysis(input_text)
|
26 |
elif analysis_type == "One-shot":
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
elif analysis_type == "Few-shot":
|
30 |
-
# Use multiple examples for few-shot analysis
|
31 |
examples = [
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
]
|
36 |
-
|
|
|
37 |
results = sentiment_analysis(input_text)
|
38 |
|
39 |
# Display results
|
|
|
14 |
st.title("GPT-2 Movie Sentiment Analysis")
|
15 |
|
16 |
# Input text for sentiment analysis
|
17 |
+
input_text = st.text_area("Enter movie review:", "")
|
18 |
|
19 |
# Choose analysis type
|
20 |
analysis_type = st.radio("Select analysis type:", ["Zero-shot", "One-shot", "Few-shot"])
|
|
|
22 |
if st.button("Analyze Sentiment"):
|
23 |
# Perform sentiment analysis based on the selected type
|
24 |
if analysis_type == "Zero-shot":
|
25 |
+
prompt = "Label the text as either 'positive', 'negative', or 'mixed' related to a movie:"
|
26 |
+
input_text = prompt + "\n\n" + input_text
|
27 |
results = sentiment_analysis(input_text)
|
28 |
elif analysis_type == "One-shot":
|
29 |
+
prompt = "Label the sentence as either 'positive', 'negative', or 'mixed' related to a movie:\n\n" \
|
30 |
+
"Sentence: This movie exceeded my expectations.\nLabel: positive"
|
31 |
+
input_text = prompt + " " + input_text
|
32 |
+
results = sentiment_analysis(input_text)
|
33 |
elif analysis_type == "Few-shot":
|
|
|
34 |
examples = [
|
35 |
+
"Sentence: The cinematography in this movie is outstanding.\nLabel: positive",
|
36 |
+
"Sentence: I didn't enjoy the plot twists in the movie.\nLabel: negative",
|
37 |
+
"Sentence: The acting was great, but the pacing felt off.\nLabel: mixed",
|
38 |
+
"Sentence: This movie didn't live up to the hype.\nLabel: negative",
|
39 |
]
|
40 |
+
prompt = "Label the sentences as either 'positive', 'negative', or 'mixed' related to a movie:\n\n" + "\n".join(examples)
|
41 |
+
input_text = prompt + "\n\n" + input_text
|
42 |
results = sentiment_analysis(input_text)
|
43 |
|
44 |
# Display results
|