songhai2022 commited on
Commit
0d66495
·
1 Parent(s): e89867e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -1,22 +1,28 @@
1
- import streamlit as st
2
- from keybert import KeyBERT
3
 
4
- # KeyBERT model
5
- keybert_model = KeyBERT(model='all-MiniLM-L6-v2')
6
 
7
- def get_bert_keywords(text, num_keywords):
8
- result = keybert_model.extract_keywords(text, keyphrase_ngram_range=(1, 1), top_n=num_keywords)
9
- keyberts = [keyword for keyword, score in result]
10
- return keyberts
11
 
12
- # Streamlit app
13
- st.title("Keyword Extraction with KeyBERT")
14
- text = st.text_area("Enter your text here:", value='', height=200)
 
15
 
16
  # if st.button("Extract Keywords"):
17
  # if text:
18
- # keywords = get_bert_keywords(text, 5)
19
  # st.write("Keywords:")
20
  # st.write(", ".join(keywords))
21
  # else:
22
  # st.error("Please enter some text.")
 
 
 
 
 
 
1
+ # import streamlit as st
2
+ # from keybert import KeyBERT
3
 
4
+ # # KeyBERT model
5
+ # keybert_model = KeyBERT(model='all-MiniLM-L6-v2')
6
 
7
+ # def get_bert_keywords(text, num_keywords):
8
+ # result = keybert_model.extract_keywords(text, keyphrase_ngram_range=(1, 1), top_n=num_keywords)
9
+ # keyberts = [keyword for keyword, score in result]
10
+ # return keyberts
11
 
12
+ # # Streamlit app
13
+ # st.title("Keyword Extraction with KeyBERT")
14
+ # text = st.text_area("Enter your text here:", value='', height=200)
15
+ num_keywords = st.slider("Number of keywords:", min_value=1, max_value=10, value=5, step=1)
16
 
17
  # if st.button("Extract Keywords"):
18
  # if text:
19
+ # keywords = get_bert_keywords(text, num_keywords)
20
  # st.write("Keywords:")
21
  # st.write(", ".join(keywords))
22
  # else:
23
  # st.error("Please enter some text.")
24
+
25
+ import streamlit as st
26
+
27
+ st.write(x, 'num_keywords', num_keywords)
28
+