Dr. Khushter Kaifi commited on
Commit
9c853b2
·
unverified ·
1 Parent(s): 32e41f6

Delete add.py

Browse files
Files changed (1) hide show
  1. add.py +0 -39
add.py DELETED
@@ -1,39 +0,0 @@
1
- # Finacial Sentiment Analysis Using Huggingface App
2
- # Team Name :- Free Thinkers
3
- # Authors:- Lalit Chaudhary and Khushter Kaifi
4
- # Update On- 2 Jan 2024
5
-
6
- # streamlit is a Python library used for creating web applications with minimal effort.
7
- # pipeline is a class from the Hugging Face Transformers library that allows you to easily use pre-trained models for various natural language processing (NLP) tasks
8
-
9
- import streamlit as st
10
- from transformers import pipeline
11
-
12
- # This line creates a sentiment analysis pipeline using the Hugging Face Transformers library.
13
- # The pipeline is pre-configured to perform sentiment analysis on input text.
14
- # # Load sentiment analysis pipeline
15
- sentiment_pipeline = pipeline("sentiment-analysis")
16
-
17
- # Sets the title of the Streamlit web application
18
- st.title("Financial Sentiment Analysis Using HuggingFace \n Team Name:- Free Thinkers")
19
-
20
- # Displays a text input box where the user can enter a sentence for sentiment analysis.
21
- st.write("Enter a Sentence to Analyze the Sentiment:")
22
- user_input = st.text_input("")
23
- st.write("Press the Enter key")
24
-
25
- # Performing Sentiment Analysis:
26
- # Checks if the user has entered some text. If yes,
27
- # it uses the sentiment_pipeline to analyze the sentiment of the input text and stores the result in the result variable.
28
-
29
- if user_input:
30
- result = sentiment_pipeline(user_input)
31
- sentiment = result[0]["label"]
32
- confidence = result[0]["score"]
33
-
34
-
35
- # Displaying Results:
36
- #If there is user input, it displays the sentiment and confidence score.
37
- # The sentiment is extracted from the "label" field in the result, and the confidence score is extracted from the "score" field.
38
- st.write(f"Sentiment: {sentiment}")
39
- st.write(f"Confidence: {confidence:.2%}")