Aman30577 commited on
Commit
f69810f
1 Parent(s): 5d7d144
Files changed (1) hide show
  1. app.js +7 -45
app.js CHANGED
@@ -1,47 +1,9 @@
1
- import React, { useState } from 'react';
 
2
 
3
- const SentimentAnalysis = () => {
4
- const [text, setText] = useState('');
5
- const [result, setResult] = useState(null);
6
 
7
- const handleTextChange = (event) => {
8
- setText(event.target.value);
9
- };
10
-
11
- const handleAnalysis = async () => {
12
- try {
13
- const response = await fetch('/sentiment-analysis', {
14
- method: 'POST',
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- },
18
- body: JSON.stringify({ text }),
19
- });
20
-
21
- if (!response.ok) {
22
- throw new Error('Request failed');
23
- }
24
-
25
- const data = await response.json();
26
- setResult(data);
27
- } catch (error) {
28
- console.error(error);
29
- }
30
- };
31
-
32
- return (
33
- <div>
34
- <textarea value={text} onChange={handleTextChange} />
35
- <button onClick={handleAnalysis}>Analyze</button>
36
-
37
- {result && (
38
- <div>
39
- <h3>Result:</h3>
40
- <pre>{JSON.stringify(result, null, 2)}</pre>
41
- </div>
42
- )}
43
- </div>
44
- );
45
- };
46
-
47
- export default SentimentAnalysis;
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
 
4
+ pipe = pipeline('sentiment-analysis')
5
+ text = st.text_area('Enter Some Text!')
 
6
 
7
+ if text:
8
+ out = pipe(text)
9
+ st.json(out)