Spaces:
Sleeping
Sleeping
Download sentiment_script.py from vchandraiitk/Thugs_Of_AI: direct link, hf CLI and curl.
- Browser
- Download file 599 Bytes
-
https://huggingface.co/spaces/vchandraiitk/Thugs_Of_AI/resolve/main/sentiment_script.py
- Command line
-
hf download hf://spaces/vchandraiitk/Thugs_Of_AI/sentiment_script.py
-
curl -L -o sentiment_script.py https://huggingface.co/spaces/vchandraiitk/Thugs_Of_AI/resolve/main/sentiment_script.py
599 Bytes
| from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer | |
| import sys | |
| analyzer = SentimentIntensityAnalyzer() | |
| def get_sentiment_score(text): | |
| score = analyzer.polarity_scores(text) | |
| compound = score['compound'] | |
| sentiment = "Positive" if compound > 0.05 else "Negative" if compound < -0.05 else "Neutral" | |
| return compound | |
| if __name__ == "__main__": | |
| if len(sys.argv) > 1: | |
| input_text = sys.argv[1] | |
| score = get_sentiment_score(input_text) | |
| print(score) # <-- print this so the shell can capture it | |
| else: | |
| print("No input text provided.") | |