-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_phrases.py
8 lines (6 loc) · 1.63 KB
/
key_phrases.py
1
2
3
4
5
6
7
8
# Stopwords from NLTK lib - no need to import NLTK and corpus just for stopwords
stopwords = [u'i', u'me', u'my', u'myself', u'we', u'our', u'ours', u'ourselves', u'you', u'your', u'yours', u'yourself', u'yourselves', u'he', u'him', u'his', u'himself', u'she', u'her', u'hers', u'herself', u'it', u'its', u'itself', u'they', u'them', u'their', u'theirs', u'themselves', u'what', u'which', u'who', u'whom', u'this', u'that', u'these', u'those', u'am', u'is', u'are', u'was', u'were', u'be', u'been', u'being', u'have', u'has', u'had', u'having', u'do', u'does', u'did', u'doing', u'a', u'an', u'the', u'and', u'but', u'if', u'or', u'because', u'as', u'until', u'while', u'of', u'at', u'by', u'for', u'with', u'about', u'against', u'between', u'into', u'through', u'during', u'before', u'after', u'above', u'below', u'to', u'from', u'up', u'down', u'in', u'out', u'on', u'off', u'over', u'under', u'again', u'further', u'then', u'once', u'here', u'there', u'when', u'where', u'why', u'how', u'all', u'any', u'both', u'each', u'few', u'more', u'most', u'other', u'some', u'such', u'nor', u'only', u'own', u'same', u'so', u'than', u'too', u'very', u's', u't', u'can', u'will', u'just', u'don\'t', u'should', u'now', u'd', u'll', u'm', u'o', u're', u've', u'y', u'ain\'t', u'aren\'t', u'couldn\'t', u'didn\'t', u'doesn\'t', u'hadn\'t', u'hasn\'t', u'haven\'t', u'isn\'t', u'ma', u'mightn\'t', u'mustn\'t', u'needn\'t', u'shan\'t', u'shouldn\'t', u'wasn\'t', u'weren\'t', u'won\'t', u'wouldn\'t']
def get_best(text):
return [word for word in text.lower().strip().split(' ') if word not in stopwords]
def get_without_stopwords(text):
return ' '.join(get_best(text))