Misnik commited on
Commit
adb8535
·
verified ·
1 Parent(s): 0ad4791

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from keybert import KeyBERT
3
+
4
+ # Инициализируем KeyBERT
5
+ kw_model = KeyBERT()
6
+
7
+ def extract_keywords(text):
8
+ if not text or not text.strip():
9
+ return []
10
+ # Извлекаем топ-5 ключевых слов
11
+ keywords = kw_model.extract_keywords(text, top_n=5)
12
+ return keywords # список кортежей (keyword, score)
13
+
14
+ # Готовим Gradio-интерфейс
15
+ iface = gr.Interface(
16
+ fn=extract_keywords,
17
+ inputs=gr.Textbox(label="Enter text"),
18
+ outputs="json",
19
+ title="KeyBERT Extractor",
20
+ description="Введите текст, чтобы получить ключевые слова"
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ iface.launch()