Skip to content

Instantly share code, notes, and snippets.

@neerajvashistha
Created March 3, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neerajvashistha/e093b111d7d706172c99 to your computer and use it in GitHub Desktop.
Save neerajvashistha/e093b111d7d706172c99 to your computer and use it in GitHub Desktop.
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