DanyaalMajid commited on
Commit
472673f
1 Parent(s): ea9d295

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -24
app.py CHANGED
@@ -31,22 +31,12 @@ def main():
31
 
32
  if user_text:
33
  # Available Models
34
- # Sentiment Analysis
35
- sentiment_checkbox = st.checkbox("Sentiment Analysis")
36
-
37
- # Emotion Analysis
38
- emotion_checkbox = st.checkbox("Emotion Analysis")
39
-
40
- # Named Entity Recognition
41
- ner_checkbox = st.checkbox("Named Entity Recognition")
42
-
43
- # Toxicity Analysis
44
- toxicity_checkbox = st.checkbox("Toxicity Analysis")
45
-
46
  # Run custom and display outputs
47
- st.header("Function Outputs:")
48
 
49
- if sentiment_checkbox:
50
  st.subheader("Sentiment Analysis:")
51
 
52
  # Parse JSON data
@@ -60,7 +50,7 @@ def main():
60
  st.write(f"Label: {label}, Score: {score}")
61
 
62
 
63
- if emotion_checkbox:
64
  st.subheader("Emotion Analysis:")
65
 
66
  # Parse JSON data
@@ -73,7 +63,7 @@ def main():
73
  score = entry["score"]
74
  st.write(f"Label: {label}, Score: {score}")
75
 
76
- if ner_checkbox:
77
  st.subheader("Named Entity Recognition:")
78
 
79
  # Parse JSON data
@@ -81,14 +71,15 @@ def main():
81
 
82
  # Extract and display data
83
  for entry in data:
84
- entity_group = entry["entity_group"]
85
- score = entry["score"]
86
- word = entry["word"]
87
- start = entry["start"]
88
- end = entry["end"]
89
- st.write(f"Word: {word}, Entity Group: {entity_group}, Score: {score}, Start: {start}, End: {end}")
90
-
91
- if toxicity_checkbox:
 
92
  st.subheader("Toxicity Analysis:")
93
 
94
  # Parse JSON data
@@ -103,3 +94,5 @@ def main():
103
 
104
  if __name__ == "__main__":
105
  main()
 
 
 
31
 
32
  if user_text:
33
  # Available Models
34
+ analysis_type = st.selectbox("Select Analysis Type", ["", "Sentiment Analysis", "Emotion Analysis", "Named Entity Recognition", "Toxicity Analysis"])
35
+
 
 
 
 
 
 
 
 
 
 
36
  # Run custom and display outputs
37
+ st.header("Function Output:")
38
 
39
+ if analysis_type == "Sentiment Analysis":
40
  st.subheader("Sentiment Analysis:")
41
 
42
  # Parse JSON data
 
50
  st.write(f"Label: {label}, Score: {score}")
51
 
52
 
53
+ if analysis_type == "Emotion Analysis":
54
  st.subheader("Emotion Analysis:")
55
 
56
  # Parse JSON data
 
63
  score = entry["score"]
64
  st.write(f"Label: {label}, Score: {score}")
65
 
66
+ if analysis_type == "Named Entity Recognition":
67
  st.subheader("Named Entity Recognition:")
68
 
69
  # Parse JSON data
 
71
 
72
  # Extract and display data
73
  for entry in data:
74
+ for entry in entry:
75
+ entity_group = entry["entity_group"]
76
+ score = entry["score"]
77
+ word = entry["word"]
78
+ start = entry["start"]
79
+ end = entry["end"]
80
+ st.write(f"Word: {word}, Entity Group: {entity_group}, Score: {score}, Start: {start}, End: {end}")
81
+
82
+ if analysis_type == "Toxicity Analysis":
83
  st.subheader("Toxicity Analysis:")
84
 
85
  # Parse JSON data
 
94
 
95
  if __name__ == "__main__":
96
  main()
97
+
98
+