Spaces:
Runtime error
Runtime error
Create ap.py
Browse files
ap.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from llmware_module import (
|
| 4 |
+
classify_sentiment,
|
| 5 |
+
detect_emotions,
|
| 6 |
+
generate_tags,
|
| 7 |
+
identify_topics,
|
| 8 |
+
perform_intent,
|
| 9 |
+
get_ratings,
|
| 10 |
+
get_category,
|
| 11 |
+
perform_ner,
|
| 12 |
+
perform_nli,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
# Streamlit app layout
|
| 16 |
+
st.title("Perform NLP Tasks on CPU")
|
| 17 |
+
|
| 18 |
+
# Text input
|
| 19 |
+
text = st.text_area("Enter text here:")
|
| 20 |
+
|
| 21 |
+
# Analysis tools selection
|
| 22 |
+
analysis_tools = st.multiselect(
|
| 23 |
+
"Select the analysis tools to use:",
|
| 24 |
+
["Sentiment Analysis", "Emotion Detection", "Generate Tags", "Identify Topics",
|
| 25 |
+
"Perform Intent", "Get Ratings", "Get Category",
|
| 26 |
+
"Perform NER", "Perform NLI"],
|
| 27 |
+
["Sentiment Analysis"] # Default selection
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# Execute analysis and display results
|
| 31 |
+
if st.button("Analyze"):
|
| 32 |
+
results = {}
|
| 33 |
+
|
| 34 |
+
if "Sentiment Analysis" in analysis_tools:
|
| 35 |
+
results["Sentiment Analysis"] = classify_sentiment(text)
|
| 36 |
+
if "Emotion Detection" in analysis_tools:
|
| 37 |
+
results["Emotion Detection"] = detect_emotions(text)
|
| 38 |
+
if "Generate Tags" in analysis_tools:
|
| 39 |
+
results["Generate Tags"] = generate_tags(text)
|
| 40 |
+
if "Identify Topics" in analysis_tools:
|
| 41 |
+
results["Identify Topics"] = identify_topics(text)
|
| 42 |
+
if "Perform Intent" in analysis_tools:
|
| 43 |
+
results["Perform Intent"] = perform_intent(text)
|
| 44 |
+
if "Get Ratings" in analysis_tools:
|
| 45 |
+
results["Get Ratings"] = get_ratings(text)
|
| 46 |
+
if "Get Category" in analysis_tools:
|
| 47 |
+
results["Get Category"] = get_category(text)
|
| 48 |
+
if "Perform NER" in analysis_tools:
|
| 49 |
+
results["Perform NER"] = perform_ner(text)
|
| 50 |
+
if "Perform NLI" in analysis_tools:
|
| 51 |
+
results["Perform NLI"] = perform_nli(text)
|
| 52 |
+
|
| 53 |
+
for tool, response in results.items():
|
| 54 |
+
st.subheader(tool)
|
| 55 |
+
st.json(response)
|