Spaces:
Runtime error
Runtime error
Update textrank.py
Browse files12345678910111213141516171819import numpy as npimport pandas as pdimport nltknltk.download('punkt') # one time executionimport reimport warningswarnings.filterwarnings('ignore')from sklearn.metrics.pairwise import cosine_similarityimport networkx as nxfrom tqdm import tqdmfrom sentence_transformers import SentenceTransformermodel = SentenceTransformer('all-mpnet-base-v2')model.to('cuda')def get_summary(text, num_words: int=1000):sentences = nltk.sent_tokenize(text)embeddings = model.encode(sentences, show_progress_bar=False)1234567891011121314151617181920212223import numpy as npimport pandas as pdimport nltkimport reimport torchimport networkx as nxfrom tqdm import tqdmfrom sentence_transformers import SentenceTransformerfrom sklearn.metrics.pairwise import cosine_similarityimport warningswarnings.filterwarnings('ignore')nltk.download('punkt')model = SentenceTransformer('all-mpnet-base-v2')device = "cuda" if torch.cuda.is_available() else "cpu"model.to(device)def get_summary(text, num_words: int=1000):sentences = nltk.sent_tokenize(text)embeddings = model.encode(sentences, show_progress_bar=False)
textrank.py+10-6