Roberta2024 commited on
Commit
6ae0021
·
verified ·
1 Parent(s): f6bb66f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from keybert import KeyBERT
3
+
4
+ # 初始化 KeyBERT 模型
5
+ kw_model = KeyBERT()
6
+
7
+ # Streamlit 介面
8
+ st.title("KeyBERT 關鍵字抓取應用")
9
+
10
+ # 輸入框讓用戶輸入文字
11
+ text = st.text_area("請貼上文字並按下按鈕以抓取關鍵字", height=200)
12
+
13
+ # 按鈕來觸發關鍵字抓取
14
+ if st.button("抓取關鍵字"):
15
+ if text:
16
+ keywords = kw_model.extract_keywords(text, stop_words='english')
17
+ st.write("抓取到的關鍵字:")
18
+ for keyword in keywords:
19
+ st.write(keyword[0])
20
+ else:
21
+ st.write("請先輸入文字")