Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,12 @@ import pandas as pd
|
|
| 3 |
from collections import Counter
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def extract_keywords(product_name):
|
| 8 |
# ๋ชจ๋ธ๋ช
์ ๊ฑฐ๋ฅผ ์ํ ์ ๊ทํํ์ ํจํด ์ค์
|
|
@@ -47,13 +53,16 @@ def process_file(file):
|
|
| 47 |
# ๊ทธ๋ํ๋ฅผ ์ ์ฅํ๊ณ ๋ฐํ
|
| 48 |
plt.savefig('keyword_frequency.png')
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
| 53 |
demo = gr.Interface(
|
| 54 |
fn=process_file,
|
| 55 |
inputs=gr.File(label="Upload Excel File"),
|
| 56 |
-
outputs=[gr.
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
|
|
|
| 3 |
from collections import Counter
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
import re
|
| 6 |
+
from matplotlib import font_manager, rc
|
| 7 |
+
|
| 8 |
+
# ํ๊ธ ํฐํธ ์ค์
|
| 9 |
+
font_path = '/usr/share/fonts/truetype/nanum/NanumGothic.ttf' # ํฐํธ ๊ฒฝ๋ก๋ ์์คํ
์ ๋ฐ๋ผ ๋ค๋ฅผ ์ ์์
|
| 10 |
+
font_name = font_manager.FontProperties(fname=font_path).get_name()
|
| 11 |
+
rc('font', family=font_name)
|
| 12 |
|
| 13 |
def extract_keywords(product_name):
|
| 14 |
# ๋ชจ๋ธ๋ช
์ ๊ฑฐ๋ฅผ ์ํ ์ ๊ทํํ์ ํจํด ์ค์
|
|
|
|
| 53 |
# ๊ทธ๋ํ๋ฅผ ์ ์ฅํ๊ณ ๋ฐํ
|
| 54 |
plt.savefig('keyword_frequency.png')
|
| 55 |
|
| 56 |
+
# ๊ฒฐ๊ณผ ์ถ๋ ฅ์ฉ ํ
์คํธ ์์ฑ
|
| 57 |
+
result_text = "\n".join([f"{keyword}: {count}" for keyword, count in common_keywords])
|
| 58 |
+
|
| 59 |
+
return result_text, 'keyword_frequency.png'
|
| 60 |
|
| 61 |
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
| 62 |
demo = gr.Interface(
|
| 63 |
fn=process_file,
|
| 64 |
inputs=gr.File(label="Upload Excel File"),
|
| 65 |
+
outputs=[gr.Textbox(label="Top 10 Keywords"), gr.Image(type="filepath", label="Keyword Frequency Graph")]
|
| 66 |
)
|
| 67 |
|
| 68 |
if __name__ == "__main__":
|