INNER CODE UNIT · Python

Sentence

wyounas/homer · homer/analyzer.py:70

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

    @property
    def total_and_words(self):
        return len([word for word in self.words if word.is_and()])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…