Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
from tweet_analyzer import TweetDatasetProcessor
|
|
@@ -26,21 +25,6 @@ class TwitterCloneApp:
|
|
| 26 |
except Exception as e:
|
| 27 |
return f"Error processing file: {str(e)}"
|
| 28 |
|
| 29 |
-
def analyze_topics(self, n_topics=5):
|
| 30 |
-
"""Analyze topics in the dataset"""
|
| 31 |
-
if not self.processor:
|
| 32 |
-
return "Please upload and analyze a dataset first."
|
| 33 |
-
|
| 34 |
-
# Check if the analyze_topics method exists
|
| 35 |
-
if hasattr(self.processor, 'analyze_topics'):
|
| 36 |
-
try:
|
| 37 |
-
topics = self.processor.analyze_topics(n_topics=n_topics)
|
| 38 |
-
return f"Identified Topics:\n{topics}"
|
| 39 |
-
except Exception as e:
|
| 40 |
-
return f"Error analyzing topics: {str(e)}"
|
| 41 |
-
else:
|
| 42 |
-
return "Topic analysis is not available in this version of TweetDatasetProcessor."
|
| 43 |
-
|
| 44 |
def generate_tweet(self, context):
|
| 45 |
"""Generate a new tweet based on the analyzed personality"""
|
| 46 |
if not self.processor:
|
|
@@ -68,16 +52,6 @@ class TwitterCloneApp:
|
|
| 68 |
inputs=file_input,
|
| 69 |
outputs=analysis_output
|
| 70 |
)
|
| 71 |
-
|
| 72 |
-
with gr.Tab("Analyze Topics"):
|
| 73 |
-
topic_button = gr.Button("Analyze Topics")
|
| 74 |
-
topic_output = gr.Textbox(label="Identified Topics")
|
| 75 |
-
|
| 76 |
-
topic_button.click(
|
| 77 |
-
fn=self.analyze_topics,
|
| 78 |
-
inputs=[],
|
| 79 |
-
outputs=topic_output
|
| 80 |
-
)
|
| 81 |
|
| 82 |
with gr.Tab("Generate Tweets"):
|
| 83 |
context_input = gr.Textbox(label="Context (optional)", placeholder="Enter topic or context for the tweet")
|
|
@@ -99,3 +73,4 @@ def main():
|
|
| 99 |
|
| 100 |
if __name__ == "__main__":
|
| 101 |
main()
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
from tweet_analyzer import TweetDatasetProcessor
|
|
|
|
| 25 |
except Exception as e:
|
| 26 |
return f"Error processing file: {str(e)}"
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
def generate_tweet(self, context):
|
| 29 |
"""Generate a new tweet based on the analyzed personality"""
|
| 30 |
if not self.processor:
|
|
|
|
| 52 |
inputs=file_input,
|
| 53 |
outputs=analysis_output
|
| 54 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
with gr.Tab("Generate Tweets"):
|
| 57 |
context_input = gr.Textbox(label="Context (optional)", placeholder="Enter topic or context for the tweet")
|
|
|
|
| 73 |
|
| 74 |
if __name__ == "__main__":
|
| 75 |
main()
|
| 76 |
+
|