INNER CODE UNIT · Python
__str__
wyounas/homer · homer/analyzer.py:61
def __str__(self):
return self.word
@lru_cache(maxsize=256)
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]