Spaces:
Sleeping
Sleeping
Update tweet_analyzer.py
Browse files- tweet_analyzer.py +9 -2
tweet_analyzer.py
CHANGED
@@ -120,14 +120,21 @@ class TweetDatasetProcessor:
|
|
120 |
]
|
121 |
|
122 |
# Extract historical topics and add them to additional contexts
|
123 |
-
historical_topics = self.analyze_topics()
|
124 |
additional_contexts.extend(historical_topics)
|
125 |
|
126 |
# Randomly select multiple contexts to increase diversity
|
127 |
selected_contexts = random.sample(additional_contexts, min(3, len(additional_contexts)))
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
generation_prompt = f"""Based on this personality profile:
|
130 |
-
{
|
131 |
Current context or topic (if any):
|
132 |
{context}
|
133 |
Additionally, consider these contexts to increase diversity:
|
|
|
120 |
]
|
121 |
|
122 |
# Extract historical topics and add them to additional contexts
|
123 |
+
historical_topics = self.analyze_topics(n_topics=10) # Consider more topics for greater diversity
|
124 |
additional_contexts.extend(historical_topics)
|
125 |
|
126 |
# Randomly select multiple contexts to increase diversity
|
127 |
selected_contexts = random.sample(additional_contexts, min(3, len(additional_contexts)))
|
128 |
|
129 |
+
# Randomly sample tweets across different time periods to avoid repetition of topics
|
130 |
+
tweet_sample = random.sample(self.tweets, min(30, len(self.tweets))) # Increase sample size for diversity
|
131 |
+
all_tweets = [tweet['content'] for tweet in tweet_sample]
|
132 |
+
|
133 |
+
# If personality profile is too long, truncate it (adjust length as needed)
|
134 |
+
personality_profile_excerpt = self.personality_profile[:1000] # Truncate profile to first 1000 characters
|
135 |
+
|
136 |
generation_prompt = f"""Based on this personality profile:
|
137 |
+
{personality_profile_excerpt}
|
138 |
Current context or topic (if any):
|
139 |
{context}
|
140 |
Additionally, consider these contexts to increase diversity:
|