Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from keybert import KeyBERT | |
| # 初始化 KeyBERT 模型 | |
| kw_model = KeyBERT() | |
| # Streamlit 介面 | |
| st.title("KeyBERT 關鍵字抓取應用") | |
| # 輸入框讓用戶輸入文字 | |
| text = st.text_area("請貼上文字並按下按鈕以抓取關鍵字", height=200) | |
| # 按鈕來觸發關鍵字抓取 | |
| if st.button("抓取關鍵字"): | |
| if text: | |
| keywords = kw_model.extract_keywords(text, stop_words='english') | |
| st.write("抓取到的關鍵字:") | |
| for keyword in keywords: | |
| st.write(keyword[0]) | |
| else: | |
| st.write("請先輸入文字") | |