|
import gradio as gr |
|
import pandas as pd |
|
import re |
|
from collections import Counter |
|
from openpyxl import Workbook |
|
|
|
def process_excel(file): |
|
|
|
df = pd.read_excel(file, sheet_name=0) |
|
|
|
|
|
product_names = df.iloc[3:, 3].dropna() |
|
|
|
|
|
all_keywords = [] |
|
for name in product_names: |
|
|
|
keywords = re.findall(r'\b\w+\b', name) |
|
|
|
unique_keywords = set(keywords) |
|
all_keywords.extend(unique_keywords) |
|
|
|
|
|
keyword_counts = Counter(all_keywords) |
|
sorted_keywords = keyword_counts.most_common() |
|
|
|
|
|
wb = Workbook() |
|
ws = wb.active |
|
ws.title = "Keywords" |
|
ws['A4'] = "ํค์๋" |
|
ws['B4'] = "๋น๋" |
|
|
|
for idx, (keyword, count) in enumerate(sorted_keywords, start=5): |
|
ws[f'A{idx}'] = keyword |
|
ws[f'B{idx}'] = count |
|
|
|
result_file = "keyword_counts.xlsx" |
|
wb.save(result_file) |
|
|
|
return result_file |
|
|
|
|
|
iface = gr.Interface( |
|
fn=process_excel, |
|
inputs=gr.File(label="์์
ํ์ผ์ ์
๋ก๋ํ์ธ์"), |
|
outputs=gr.File(label="๊ฒฐ๊ณผ ์์
ํ์ผ"), |
|
title="์์
ํค์๋ ๋ถ์๊ธฐ" |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|