shiue2000 commited on
Commit
68edcfe
·
verified ·
1 Parent(s): 58a8eb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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} 的貼文 {i}"])),
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))