INNER CODE UNIT · Python

__init__

wyounas/homer · homer/analyzer.py:125

    def __init__(self, paragraph):
        paragraph = paragraph.replace('—', ' ')
        self.paragraph = paragraph
        self.tokenized_sentences = nltk.sent_tokenize(paragraph)
        self._sentences = [Sentence(sentence) for sentence in self.tokenized_sentences]


    @property
    def sentences(self):
        return self._sentences

    @property
    def longest_sentence(self):
        return max(self._sentences, key=lambda sentence: len(sentence))

    @property
    def total_words(self):
        return sum([len(sentence) for sentence in self.sentences])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…