Spaces:
Paused
Paused
adhvaithprasad
commited on
Commit
·
1cae9bb
1
Parent(s):
226a40e
new modules added
Browse files- calculator.py +2 -0
- sentimentAnalysis.py +16 -0
calculator.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
def calculate(operation, x, y):
|
2 |
+
return x/y
|
sentimentAnalysis.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
# x = st.slider('Select a value')
|
4 |
+
# st.write(x, 'squared is', x * x)
|
5 |
+
def sentimentAnalysis(user_input):
|
6 |
+
sentiment_pipeline = pipeline("sentiment-analysis")
|
7 |
+
#st.title("Sentiment Analysis with HuggingFace Spaces")
|
8 |
+
#st.write("Enter a sentence to analyze its sentiment:")
|
9 |
+
#user_input = st.text_input("")
|
10 |
+
if user_input:
|
11 |
+
result = sentiment_pipeline(user_input)
|
12 |
+
sentiment = result[0]["label"]
|
13 |
+
confidence = result[0]["score"]
|
14 |
+
return {"Sentiment": sentiment, "Confidence":confidence }
|
15 |
+
#st.write(f"Sentiment: {sentiment}")
|
16 |
+
#st.write(f"Confidence: {confidence:.2f}")
|