Spaces:
Runtime error
Runtime error
File size: 513 Bytes
f214d73 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from typing import List, Tuple
import pandas as pd
from examples.common import NLP
from textacy.extract.keyterms.sgrank import sgrank as keywords
def process(text: str) -> pd.DataFrame:
doc = NLP(text)
terms: List[Tuple[str, float]] = keywords(doc, topn=10)
term_set = [t for t, _ in terms]
return pd.DataFrame([{"Keyphrase": term, "Probability": prob}
for term, prob in terms
if all(other == term or term not in other for other in term_set)])
|