samiNCL commited on
Commit
ba6e3c0
1 Parent(s): 9dfa08e

Final final

Browse files
Files changed (1) hide show
  1. app.py +36 -23
app.py CHANGED
@@ -1,34 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pandas as pd
2
  from transformers import pipeline
3
  import gradio as gr
4
- import io
5
 
6
  # Initialize sentiment analysis pipeline
7
  sentiment_pipeline = pipeline('sentiment-analysis')
8
 
9
- def process_csv(file):
10
- df = pd.read_csv(io.StringIO(file))
11
- sentiments = []
12
- for _, row in df.iterrows():
13
- text = row['Content']
14
- sentiment = analyze_sentiment(text)
15
- sentiments.append(sentiment)
16
-
17
- df['sentiment'] = sentiments
18
-
19
- return df.to_csv(index=False)
20
-
21
- def analyze_sentiment(text):
22
- result = sentiment_pipeline(text)[0]
23
- sentiment = result['label']
24
- return sentiment
25
-
26
  def analyze_text(text):
27
- sentiment = analyze_sentiment(text)
28
- return sentiment
29
 
30
  iface = gr.Interface(fn=analyze_text, inputs=gr.inputs.Textbox(lines=13, label="Enter Text"), outputs="text")
31
  iface.launch(share=True)
32
-
33
-
34
-
 
1
+ # import pandas as pd
2
+ # from transformers import pipeline
3
+ # import gradio as gr
4
+ # import io
5
+
6
+ # # Initialize sentiment analysis pipeline
7
+ # sentiment_pipeline = pipeline('sentiment-analysis')
8
+
9
+ # def process_csv(file):
10
+ # df = pd.read_csv(io.StringIO(file))
11
+ # sentiments = []
12
+ # for _, row in df.iterrows():
13
+ # text = row['Content']
14
+ # sentiment = analyze_sentiment(text)
15
+ # sentiments.append(sentiment)
16
+
17
+ # df['sentiment'] = sentiments
18
+
19
+ # return df.to_csv(index=False)
20
+
21
+ # def analyze_sentiment(text):
22
+ # result = sentiment_pipeline(text)[0]
23
+ # sentiment = result['label']
24
+ # return sentiment
25
+
26
+ # def analyze_text(text):
27
+ # sentiment = analyze_sentiment(text)
28
+ # return sentiment
29
+
30
+ # iface = gr.Interface(fn=analyze_text, inputs=gr.inputs.Textbox(lines=13, label="Enter Text"), outputs="text")
31
+ # iface.launch(share=True)
32
+
33
+
34
+
35
  import pandas as pd
36
  from transformers import pipeline
37
  import gradio as gr
 
38
 
39
  # Initialize sentiment analysis pipeline
40
  sentiment_pipeline = pipeline('sentiment-analysis')
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  def analyze_text(text):
43
+ sentiment = sentiment_pipeline(text)[0]
44
+ return sentiment['label']
45
 
46
  iface = gr.Interface(fn=analyze_text, inputs=gr.inputs.Textbox(lines=13, label="Enter Text"), outputs="text")
47
  iface.launch(share=True)