Spaces:
Runtime error
Runtime error
Download src/rake.py from nihaldsouza1/wikicontext: direct link, hf CLI and curl.
- Browser
- Download file 723 Bytes
-
https://huggingface.co/spaces/nihaldsouza1/wikicontext/resolve/main/src/rake.py
- Command line
-
hf download hf://spaces/nihaldsouza1/wikicontext/src/rake.py
-
curl -L -o rake.py https://huggingface.co/spaces/nihaldsouza1/wikicontext/resolve/main/src/rake.py
723 Bytes
| from rake_nltk import Rake as RAKE | |
| class Rake(): | |
| def __init__(self): | |
| self.rake = RAKE() | |
| def get_keyphrases_with_score(self, rake_input): | |
| if isinstance(rake_input, list): | |
| self.rake.extract_keywords_from_sentences(rake_input) | |
| elif isinstance(rake_input, str): | |
| self.rake.extract_keywords_from_text(rake_input) | |
| return self.rake.get_ranked_phrases_with_scores() | |
| def get_keyphrases(self, rake_input): | |
| if isinstance(rake_input, list): | |
| self.rake.extract_keywords_from_sentences(rake_input) | |
| elif isinstance(rake_input, str): | |
| self.rake.extract_keywords_from_text(rake_input) | |
| return self.rake.get_ranked_phrases() | |