abdulmatinomotoso commited on
Commit
4b10e4c
1 Parent(s): 0b5b5f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -17,11 +17,10 @@ def read_in_text(url):
17
  tmp_model = SentenceTransformer('valurank/MiniLM-L6-Keyword-Extraction')
18
  kw_extractor = KeyBERT(tmp_model)
19
 
20
- def get_keybert_results_with_vectorizer(file, number_of_results=20):
21
  try:
22
- text = read_in_text(file.name)
23
  keywords = kw_extractor.extract_keywords(text, vectorizer=KeyphraseCountVectorizer(), stop_words=None, top_n=number_of_results)
24
- keywords = [i for i in keywords if i[1] >= 0.25]
25
 
26
  keybert_diversity_phrases = []
27
  for i, j in keywords:
@@ -33,7 +32,7 @@ def get_keybert_results_with_vectorizer(file, number_of_results=20):
33
  except Exception:
34
  return "Error"
35
 
36
- demo = gr.Interface(get_keybert_results_with_vectorizer, inputs=gr.inputs.File(),
37
  outputs=gr.outputs.Dataframe(),
38
  title = "Keyword Extraction")
39
 
 
17
  tmp_model = SentenceTransformer('valurank/MiniLM-L6-Keyword-Extraction')
18
  kw_extractor = KeyBERT(tmp_model)
19
 
20
+ def get_keybert_results_with_vectorizer(text, number_of_results=30):
21
  try:
 
22
  keywords = kw_extractor.extract_keywords(text, vectorizer=KeyphraseCountVectorizer(), stop_words=None, top_n=number_of_results)
23
+ keywords = [i for i in keywords if i[1] >= 0.20]
24
 
25
  keybert_diversity_phrases = []
26
  for i, j in keywords:
 
32
  except Exception:
33
  return "Error"
34
 
35
+ demo = gr.Interface(get_keybert_results_with_vectorizer, inputs=gr.Texbox(),
36
  outputs=gr.outputs.Dataframe(),
37
  title = "Keyword Extraction")
38