Created
March 3, 2016 18:29
-
-
Save neerajvashistha/e093b111d7d706172c99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
from __future__ import print_function | |
import six | |
import rake | |
import operator | |
import io | |
import spellcheck | |
def extract_phrase(sentence): | |
# 1. initialize RAKE by providing a path to a stopwords file | |
stoppath = "SmartStoplist.txt" | |
rake_object = rake.Rake(stoppath) | |
text = "I would like to order 2 mnchurien and rice. Send me a mechnic" | |
# 2. Split text into sentences | |
txt = spellcheck.sentence_correct(sentence) | |
sentenceList = rake.split_sentences(txt) | |
# 3. generate candidate keywords | |
stopwordpattern = rake.build_stop_word_regex(stoppath) | |
phraseList = rake.generate_candidate_keywords(sentenceList, stopwordpattern) | |
return phraseList | |
if __name__ == "__main__": | |
print(extract_phrase("hi how are you?")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment