820nam commited on
Commit
c87048f
ยท
verified ยท
1 Parent(s): 61b8502

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -24,9 +24,9 @@ st.markdown(
24
  unsafe_allow_html=True
25
  )
26
 
27
- # matplotlib ํ•œ๊ธ€ ํฐํŠธ ์„ค์ • (๋‹ค๋ฅธ ํฐํŠธ๋ฅผ ์‹œ๋„)
28
  import matplotlib
29
- matplotlib.rcParams['font.family'] = 'Malgun Gothic' # ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
30
  matplotlib.rcParams['axes.unicode_minus'] = False # ๋งˆ์ด๋„ˆ์Šค ๊ธฐํ˜ธ ๊นจ์ง ๋ฐฉ์ง€
31
 
32
  # ๋„ค์ด๋ฒ„ ๋‰ด์Šค API๋ฅผ ํ†ตํ•ด ์‹ค์ œ ๋‰ด์Šค ๊ธฐ์‚ฌ ๊ฐ€์ ธ์˜ค๊ธฐ
@@ -69,7 +69,7 @@ def generate_article_gpt4(prompt):
69
  {"role": "system", "content": "You are a helpful assistant that generates articles."},
70
  {"role": "user", "content": prompt} # ์‚ฌ์šฉ์ž๊ฐ€ ์ œ๊ณตํ•œ ํ”„๋กฌํ”„ํŠธ
71
  ],
72
- max_tokens=1024, # ์ƒ์„ฑํ•  ํ…์ŠคํŠธ์˜ ์ตœ๋Œ€ ๊ธธ์ด
73
  temperature=0.7 # ์ฐฝ์˜์„ฑ ์ •๋„
74
  )
75
  return response['choices'][0]['message']['content'] # GPT์˜ ์‘๋‹ต ํ…์ŠคํŠธ ๋ฐ˜ํ™˜
@@ -133,11 +133,13 @@ def visualize_sentiment_distribution(sentiment_counts):
133
  labels = list(sentiment_counts.keys())
134
  sizes = list(sentiment_counts.values())
135
 
136
- # ์˜์–ด๋กœ ์ฐจํŠธ ํ…์ŠคํŠธ ์„ค์ •
137
- ax.bar(labels, sizes, color=sns.color_palette("pastel")[0:len(sizes)])
138
- ax.set_xlabel('Political Leaning', fontsize=14)
139
- ax.set_ylabel('Count', fontsize=14)
140
- ax.set_title('News Sentiment Distribution', fontsize=16)
 
 
141
  st.pyplot(fig)
142
 
143
  # Streamlit ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜
 
24
  unsafe_allow_html=True
25
  )
26
 
27
+ # matplotlib ํ•œ๊ธ€ ํฐํŠธ ์„ค์ •
28
  import matplotlib
29
+ matplotlib.rcParams['font.family'] = 'NanumGothic' # ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
30
  matplotlib.rcParams['axes.unicode_minus'] = False # ๋งˆ์ด๋„ˆ์Šค ๊ธฐํ˜ธ ๊นจ์ง ๋ฐฉ์ง€
31
 
32
  # ๋„ค์ด๋ฒ„ ๋‰ด์Šค API๋ฅผ ํ†ตํ•ด ์‹ค์ œ ๋‰ด์Šค ๊ธฐ์‚ฌ ๊ฐ€์ ธ์˜ค๊ธฐ
 
69
  {"role": "system", "content": "You are a helpful assistant that generates articles."},
70
  {"role": "user", "content": prompt} # ์‚ฌ์šฉ์ž๊ฐ€ ์ œ๊ณตํ•œ ํ”„๋กฌํ”„ํŠธ
71
  ],
72
+ max_tokens=1024, # ๊ธ€์ž ์ˆ˜ ์ œํ•œ ํ•ด์ œ (์ตœ๋Œ€ 1024 ํ† ํฐ)
73
  temperature=0.7 # ์ฐฝ์˜์„ฑ ์ •๋„
74
  )
75
  return response['choices'][0]['message']['content'] # GPT์˜ ์‘๋‹ต ํ…์ŠคํŠธ ๋ฐ˜ํ™˜
 
133
  labels = list(sentiment_counts.keys())
134
  sizes = list(sentiment_counts.values())
135
 
136
+ # ์ƒ‰์ƒ ์„ค์ • (๋ถ€๋“œ๋Ÿฌ์šด ํŒ”๋ ˆํŠธ)
137
+ color_palette = sns.color_palette("pastel")[0:len(sizes)]
138
+
139
+ ax.bar(labels, sizes, color=color_palette)
140
+ ax.set_xlabel('์„ฑํ–ฅ', fontsize=14)
141
+ ax.set_ylabel('๊ฑด์ˆ˜', fontsize=14)
142
+ ax.set_title('๋‰ด์Šค ์„ฑํ–ฅ ๋ถ„ํฌ', fontsize=16)
143
  st.pyplot(fig)
144
 
145
  # Streamlit ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜