Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,11 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
import re
|
4 |
from collections import Counter
|
|
|
5 |
|
6 |
def process_excel(file):
|
7 |
# μμ
νμΌ μ½κΈ°
|
8 |
-
df = pd.read_excel(file)
|
9 |
|
10 |
# Dμ΄μ λ°μ΄ν° μΆμΆ
|
11 |
product_names = df.iloc[:, 3].dropna() # Dμ΄μ 0λΆν° μμνλ―λ‘ indexλ 3
|
@@ -27,8 +28,12 @@ def process_excel(file):
|
|
27 |
result_df = pd.DataFrame(keyword_counts.items(), columns=['Keyword', 'Frequency'])
|
28 |
result_df = result_df.sort_values(by='Frequency', ascending=False).reset_index(drop=True)
|
29 |
|
30 |
-
#
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
result_df.to_excel(output_file, index=False)
|
33 |
|
34 |
return output_file
|
@@ -36,7 +41,7 @@ def process_excel(file):
|
|
36 |
# Gradio μΈν°νμ΄μ€ μ μ
|
37 |
iface = gr.Interface(
|
38 |
fn=process_excel,
|
39 |
-
inputs="
|
40 |
outputs="file",
|
41 |
title="Excel Keyword Extractor",
|
42 |
description="μμ
νμΌμ Dμ΄μμ ν€μλλ₯Ό μΆμΆνκ³ λΉλλ₯Ό κ³μ°νμ¬ μλ‘μ΄ μμ
νμΌλ‘ μΆλ ₯ν©λλ€."
|
|
|
2 |
import pandas as pd
|
3 |
import re
|
4 |
from collections import Counter
|
5 |
+
import os
|
6 |
|
7 |
def process_excel(file):
|
8 |
# μμ
νμΌ μ½κΈ°
|
9 |
+
df = pd.read_excel(file.name)
|
10 |
|
11 |
# Dμ΄μ λ°μ΄ν° μΆμΆ
|
12 |
product_names = df.iloc[:, 3].dropna() # Dμ΄μ 0λΆν° μμνλ―λ‘ indexλ 3
|
|
|
28 |
result_df = pd.DataFrame(keyword_counts.items(), columns=['Keyword', 'Frequency'])
|
29 |
result_df = result_df.sort_values(by='Frequency', ascending=False).reset_index(drop=True)
|
30 |
|
31 |
+
# λλ ν 리 μμ± νμΈ λ° νμΌ μ μ₯
|
32 |
+
output_dir = "output"
|
33 |
+
if not os.path.exists(output_dir):
|
34 |
+
os.makedirs(output_dir)
|
35 |
+
|
36 |
+
output_file = os.path.join(output_dir, "keyword_counts.xlsx")
|
37 |
result_df.to_excel(output_file, index=False)
|
38 |
|
39 |
return output_file
|
|
|
41 |
# Gradio μΈν°νμ΄μ€ μ μ
|
42 |
iface = gr.Interface(
|
43 |
fn=process_excel,
|
44 |
+
inputs=gr.inputs.File(file_types=[".xlsx"]), # μμ
νμΌλ§ μ
λ‘λν μ μκ² μ€μ
|
45 |
outputs="file",
|
46 |
title="Excel Keyword Extractor",
|
47 |
description="μμ
νμΌμ Dμ΄μμ ν€μλλ₯Ό μΆμΆνκ³ λΉλλ₯Ό κ³μ°νμ¬ μλ‘μ΄ μμ
νμΌλ‘ μΆλ ₯ν©λλ€."
|