Ejemplo n.º 1
0
def test_reading_time():
    textstat.set_lang("en_US")
    score = textstat.reading_time(long_test)

    assert score == 25.68
Ejemplo n.º 2
0
def main():

    txt = str(input("Paste Paragraph: "))
    blob = TextBlob(txt)
    #frames

    #values
    nChars = len(txt)
    nWords = len(txt.split())
    nUniqueWords = len(unique(txt.split()))
    ncharNoSpaces = charNoSpaces(txt)
    nSentences = (txt.count("."))
    wordsLongestSentenceVal = wordsLongestSentence(txt)
    wordsShortestSentenceVal = wordsShortestSentence(txt)
    avgSentenceWordsVal = avgSentenceWords(txt)
    avgSentenceCharsVal = avgSentenceChars(txt)
    avgWordLengthVal = avgWordLength(txt)
    nParagraphsVal = txt.count("\n")
    syllablesVal = syllables(txt)
    words_publisherVal = words_publisher(txt)
    readingLevelVal = textstat.dale_chall_readability_score_v2(txt)
    readingTimeVal = textstat.reading_time(txt)
    sentimentPolarityVal = blob.sentiment.polarity

    nParasInp = int(input("Enter number of paragraphs: "))
    gradeInp = str(input("Enter grade: "))
    '''
    print("charLength", nChars)
    print("nWords", nWords)
    print("nUniqueWords", nUniqueWords)
    print("ncharNoSpaces", ncharNoSpaces)
    print("nSentences", nSentences)
    print("wordsLongestSentence", wordsLongestSentenceVal)
    print("wordsShortestSentence", wordsShortestSentenceVal)
    print("avgSentenceWords", avgSentenceWordsVal)
    print("avgSentenceChars", avgSentenceCharsVal)
    print("avgWordLength", avgWordLengthVal)
    print("nParagraphs", nParagraphsVal)
    print("syllables", syllablesVal)
    print("words_publisher", words_publisherVal)
    print("readingLevel", readingLevelVal)
    print("readingTime", readingTimeVal)
    print("sentimentPolarity", sentimentPolarityVal)
    '''
    print("")
    print("Writing to file")

    # New data to write:
    new_companies = [
        nChars, nWords, nUniqueWords, ncharNoSpaces, nSentences,
        wordsLongestSentenceVal, wordsShortestSentenceVal, avgSentenceWordsVal,
        avgSentenceCharsVal, avgWordLengthVal, nParagraphsVal, syllablesVal,
        words_publisherVal, readingLevelVal, readingTimeVal,
        sentimentPolarityVal, nParasInp, gradeInp
    ]

    maxR = page.max_row + 1
    for column, entry in enumerate(new_companies, start=1):
        page.cell(row=maxR, column=column, value=entry)

    wb.save(filename=workbook_name)

    print("-----------------DONE----------------------")
    main()