Spaces:
Build error
Build error
File size: 1,507 Bytes
ebe69e3 9cc9f0f b33a613 9cc9f0f 1b80991 9cc9f0f 1b80991 ebe69e3 1b80991 ebe69e3 9cc9f0f ebe69e3 b33a613 1b80991 12b4943 1b80991 e5da41f 1b80991 7468f33 1b80991 e5da41f 1b80991 b7dd29c b33a613 b7dd29c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import streamlit as st
st.markdown("""### TL;DR: give me the keywords!
Here you can get the keywords and topic of the article based on it's title or abstract.
The only supported language is English.""")
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)
#from transformers import pipeline
#pipe = pipeline("ner", "Davlan/distilbert-base-multilingual-cased-ner-hrl")
#st.markdown("#### Title:")
title = st.text_area("Title:")
abstract = st.text_area("abstract:")
from transformers import AutoModel, AutoTokenizer
#from tqdm import tqdm as tqdm
import transformers
transformers.utils.logging.disable_progress_bar()
model_name = "distilroberta-base"
main_model = AutoModel.from_pretrained(model_name)
main_tokenizer = AutoTokenizer.from_pretrained(model_name)
from utils.utils import *
import spacy
#import en_core_web_sm
import os
os.system("python3 -m spacy download en")
# Вообще, стоит найти pipeline, заточенный под научный текст.
# Но этим займёмся потом, если будет время.
main_nlp = spacy.load('en_core_web_sm')
text = title + abstract
if not text is None and len(text) > 0:
#keywords = get_candidates(text, main_nlp)
keywords = get_keywords(summaries[0], main_nlp, main_model, main_tokenizer)
st.markdown(f"{keywords}")
else:
st.markdown("Please, try to enter something.")
|