INNER CODE UNIT · Python
get_word
wyounas/homer · homer/analyzer.py:66
def get_word(word):
return Word(word)
class Sentence(object):
"""
An abstraction that represents a sentence and gives various stats.
"""
def __init__(self, sentence):
self.sentence = sentence
words = nltk.word_tokenize(sentence)
words = [word for word in words if word.isalpha() or word.isdigit()]
self._words = [get_word(word) for word in words]
@property
def words(self):
return self._words