Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ plt.style.use("seaborn-v0_8")
|
|
| 25 |
# ===== Logging =====
|
| 26 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 27 |
# ===== Parameters =====
|
| 28 |
-
candidates = ["
|
| 29 |
days_back = 7
|
| 30 |
max_tweets_per_candidate = 20
|
| 31 |
news_file = "news_sample.csv"
|
|
@@ -48,17 +48,17 @@ except:
|
|
| 48 |
# ===== Simulate Post Fetching =====
|
| 49 |
def fetch_tweets(candidate):
|
| 50 |
sample_texts = {
|
| 51 |
-
"
|
| 52 |
-
"
|
| 53 |
-
"
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
}
|
| 57 |
return pd.DataFrame([
|
| 58 |
{
|
| 59 |
"Date": datetime.now() - timedelta(days=random.randint(0, days_back - 1)),
|
| 60 |
"User": f"user{random.randint(1, 100)}",
|
| 61 |
-
"Content": random.choice(sample_texts.get(candidate, [f"{candidate}
|
| 62 |
"Candidate": candidate
|
| 63 |
}
|
| 64 |
for i in range(random.randint(5, max_tweets_per_candidate))
|
|
|
|
| 25 |
# ===== Logging =====
|
| 26 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 27 |
# ===== Parameters =====
|
| 28 |
+
candidates = ["Hsu Chih-chieh", "Chiu Yi-ying", "Lai Jui-lung", "Lin Dai-hua", "Ko Chih-en"]
|
| 29 |
days_back = 7
|
| 30 |
max_tweets_per_candidate = 20
|
| 31 |
news_file = "news_sample.csv"
|
|
|
|
| 48 |
# ===== Simulate Post Fetching =====
|
| 49 |
def fetch_tweets(candidate):
|
| 50 |
sample_texts = {
|
| 51 |
+
"Hsu Chih-chieh": ["Hsu Chih-chieh actively participates in local activities", "Hsu Chih-chieh criticized for empty policies", "Support Hsu Chih-chieh, build a new future for Kaohsiung!"],
|
| 52 |
+
"Chiu Yi-ying": ["Chiu Yi-ying strongly states intention to run for mayor", "Chiu Yi-ying criticizes Lin Dai-hua", "Chiu Yi-ying promotes Hakka culture"],
|
| 53 |
+
"Lai Jui-lung": ["Lai Jui-lung promotes marine economy", "Lai Jui-lung leads in polls", "Lai Jui-lung questioned for lack of experience"],
|
| 54 |
+
"Lin Dai-hua": ["Lin Dai-hua actively engages with grassroots", "Lin Dai-hua involved in assistant fee controversy", "Lin Dai-hua receives support from Zheng Guohui"],
|
| 55 |
+
"Ko Chih-en": ["Ko Chih-en leads significantly in polls", "Ko Chih-en criticized for missing disaster inspection", "Ko Chih-en promotes youth policies"]
|
| 56 |
}
|
| 57 |
return pd.DataFrame([
|
| 58 |
{
|
| 59 |
"Date": datetime.now() - timedelta(days=random.randint(0, days_back - 1)),
|
| 60 |
"User": f"user{random.randint(1, 100)}",
|
| 61 |
+
"Content": random.choice(sample_texts.get(candidate, [f"{candidate}'s post {i}"])),
|
| 62 |
"Candidate": candidate
|
| 63 |
}
|
| 64 |
for i in range(random.randint(5, max_tweets_per_candidate))
|