vanessbut commited on
Commit
b33a613
·
1 Parent(s): b7dd29c

Исправлен вывод.

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -1,7 +1,9 @@
1
  import streamlit as st
2
 
3
  st.markdown("""### TL;DR: give me the keywords!
4
- Here you can get the keywords and topic of the article based on it's title or abstract.""")
 
 
5
 
6
  st.markdown("<p style=\"text-align:center\"><img width=700px src='https://c.tenor.com/IKt-6tAk9CUAAAAd/thats-a-lot-of-words-lots-of-words.gif'></p>", unsafe_allow_html=True)
7
 
@@ -13,6 +15,16 @@ st.markdown("<p style=\"text-align:center\"><img width=700px src='https://c.teno
13
  title = st.text_area("Title:")
14
  abstract = st.text_area("abstract:")
15
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  from utils.utils import *
18
  import spacy
@@ -26,11 +38,10 @@ os.system("python3 -m spacy download en")
26
  main_nlp = spacy.load('en_core_web_sm')
27
 
28
  text = title + abstract
29
- #text = preprocess(text)
30
-
31
- keywords = get_candidates(text, main_nlp)
32
 
33
- if not keywords is None and len(keywords) > 0:
 
 
34
  st.markdown(f"{keywords}")
35
  else:
36
  st.markdown("Please, try to enter something.")
 
1
  import streamlit as st
2
 
3
  st.markdown("""### TL;DR: give me the keywords!
4
+ Here you can get the keywords and topic of the article based on it's title or abstract.
5
+
6
+ The only supported language is English.""")
7
 
8
  st.markdown("<p style=\"text-align:center\"><img width=700px src='https://c.tenor.com/IKt-6tAk9CUAAAAd/thats-a-lot-of-words-lots-of-words.gif'></p>", unsafe_allow_html=True)
9
 
 
15
  title = st.text_area("Title:")
16
  abstract = st.text_area("abstract:")
17
 
18
+ from transformers import AutoModel, AutoTokenizer
19
+ #from tqdm import tqdm as tqdm
20
+
21
+ import transformers
22
+ transformers.utils.logging.disable_progress_bar()
23
+
24
+ model_name = "distilroberta-base"
25
+ main_model = AutoModel.from_pretrained(model_name)
26
+ main_tokenizer = AutoTokenizer.from_pretrained(model_name)
27
+
28
 
29
  from utils.utils import *
30
  import spacy
 
38
  main_nlp = spacy.load('en_core_web_sm')
39
 
40
  text = title + abstract
 
 
 
41
 
42
+ if not text is None and len(text) > 0:
43
+ #keywords = get_candidates(text, main_nlp)
44
+ keywords = get_keywords(summaries[0], main_nlp, main_model, main_tokenizer)
45
  st.markdown(f"{keywords}")
46
  else:
47
  st.markdown("Please, try to enter something.")