abdulmatinomotoso commited on
Commit
bdde448
1 Parent(s): a391035

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -17,10 +17,11 @@ 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(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,7 +33,7 @@ def get_keybert_results_with_vectorizer(text, number_of_results=30):
32
  except Exception:
33
  return "Error"
34
 
35
- demo = gr.Interface(get_keybert_results_with_vectorizer, inputs=gr.Textbox(),
36
  outputs=gr.outputs.Dataframe(),
37
  title = "Keyword Extraction")
38
 
 
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.20]
25
 
26
  keybert_diversity_phrases = []
27
  for i, j in keywords:
 
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