Ejemplo n.º 1
0
    def test_letter_count(self):
        count = textstat.letter_count(self.long_test)
        count_spaces = textstat.letter_count(self.long_test,
                                             ignore_spaces=False)

        self.assertEqual(1688, count)
        self.assertEqual(2061, count_spaces)
Ejemplo n.º 2
0
def test_letter_count():
    textstat.set_lang("en_US")
    count = textstat.letter_count(long_test)
    count_spaces = textstat.letter_count(long_test, ignore_spaces=False)

    assert count == 1688
    assert count_spaces == 2061
Ejemplo n.º 3
0
def test_letter_count():
    count = textstat.letter_count(long_test)
    count_spaces = textstat.letter_count(
        long_test, ignore_spaces=False
    )

    assert count == 1688
    assert count_spaces == 2061
Ejemplo n.º 4
0
def get_raw_stats(book, text):
    return {
        'total_words': textstat.lexicon_count(text),
        'total_sentences': len(sent_tokenize(text)),
        'total_letters': textstat.letter_count(text),
        'total_syllables': textstat.syllable_count(text),
        # 'total_paragraphs': len(get_paragraphs(text)),
        # 'average_word_difficulty': get_average_frequency(book)
    }
Ejemplo n.º 5
0
def words_sentence_syllables(data_list):
    words_12_letters = []
    words_4_syllables = []
    words_12_count = 0
    words_4_count = 0

    for sentence in data_list:
        for word in sentence.split():
            count4 = textstat.syllable_count(word)
            count12 = textstat.letter_count(word)
            if count12 > 12:
                words_12_count += 1
                words_12_letters.append((count12, word))
            if count4 > 4:
                words_4_count += 1
                words_4_syllables.append((count4, word))
    return words_12_letters, words_12_count, words_4_syllables, words_4_count