コード例 #1
0
    def __analyzeText(self, text=''):
        if text != '':
            if text != self.text:
                self.text = text
                if self.lang == "":
                    self.lang = NaiveBayes().classifyText(text)
                t = textanalyzer(self.lang)
                t.analyzeText(text)
                words = t.getWords(text)
                charCount = t.getCharacterCount(words)
                wordCount = len(words)
                sentenceCount = len(t.getSentences(text))
                syllableCount = t.countSyllables(words)
                complexwordsCount = t.countComplexWords(text)
                averageWordsPerSentence = wordCount/sentenceCount

                analyzedVars = {}

                analyzedVars['words'] = words
                analyzedVars['charCount'] = float(charCount)
                analyzedVars['wordCount'] = float(wordCount)
                analyzedVars['sentenceCount'] = float(sentenceCount)
                analyzedVars['syllableCount'] = float(syllableCount)
                analyzedVars['complexwordCount'] = float(complexwordsCount)
                analyzedVars['averageWordsPerSentence'] = float(averageWordsPerSentence)
                self.analyzedVars = analyzedVars
コード例 #2
0
ファイル: readabilitytests.py プロジェクト: Saragon87/raTest
 def __analyzeText(self, text=''):
     if text != '':
         if text != self.text:
             self.text = text
             #lang = NaiveBayes().classifyText(text)
             #nur vorruebergehend, da das bei mir fehler geworfen hat
             lang = "eng"
             self.lang = lang
             t = textanalyzer(lang)
             t.analyzeText(text)
             words = t.getWords(text)
             charCount = t.getCharacterCount(words)
             wordCount = len(words)
             sentenceCount = len(t.getSentences(text))
             syllableCount = t.countSyllables(words)
             complexwordsCount = t.countComplexWords(text)
             averageWordsPerSentence = wordCount/sentenceCount
             newDaleChallMissingWords = t.countNewDaleChallWordsNotInList(text)
             newDaleChallMissingWords_enhanced = t.countNewDaleChallWordsNotInList_enhanced(text)
             
             analyzedVars = {}
             
             analyzedVars['words'] = words
             analyzedVars['charCount'] = float(charCount)
             analyzedVars['wordCount'] = float(wordCount)
             analyzedVars['sentenceCount'] = float(sentenceCount)
             analyzedVars['syllableCount'] = float(syllableCount)
             analyzedVars['complexwordCount'] = float(complexwordsCount)
             analyzedVars['averageWordsPerSentence'] = float(averageWordsPerSentence)
             analyzedVars['newDaleChallMissingWords'] = float(newDaleChallMissingWords)
             analyzedVars['newDaleChallMissingWords_enhanced'] = float(newDaleChallMissingWords_enhanced)
             self.analyzedVars = analyzedVars
コード例 #3
0
    def __analyzeText(self, text=''):
        if text != '':
            if text != self.text:
                self.text = text
                self.lang = 'eng'
                t = textanalyzer(self.lang)
                t.analyzeText(text)
                words = t.getWords(text)
                charCount = t.getCharacterCount(words)
                wordCount = len(words)
                sentenceCount = len(t.getSentences(text))
                syllableCount = t.countSyllables(words)
                complexwordsCount = t.countComplexWords(text)
                averageWordsPerSentence = wordCount / sentenceCount

                analyzedVars = {}

                analyzedVars['words'] = words
                analyzedVars['charCount'] = float(charCount)
                analyzedVars['wordCount'] = float(wordCount)
                analyzedVars['sentenceCount'] = float(sentenceCount)
                analyzedVars['syllableCount'] = float(syllableCount)
                analyzedVars['complexwordCount'] = float(complexwordsCount)
                analyzedVars['averageWordsPerSentence'] = float(
                    averageWordsPerSentence)
                self.analyzedVars = analyzedVars
コード例 #4
0
    def __analyzeText(self, text=""):
        if text != "":
            if text != self.text:
                self.text = text
                self.lang = "eng"
                t = textanalyzer(self.lang)
                words = t.getWords(text)
                charCount = t.getCharacterCount(words)
                wordCount = len(words)
                sentenceCount = len(t.getSentences(text))
                syllableCount = t.countSyllables(words)
                complexwordsCount = t.countComplexWords(text)
                averageWordsPerSentence = wordCount / sentenceCount

                analyzedVars = {}

                analyzedVars["words"] = words
                analyzedVars["charCount"] = float(charCount)
                analyzedVars["wordCount"] = float(wordCount)
                analyzedVars["sentenceCount"] = float(sentenceCount)
                analyzedVars["syllableCount"] = float(syllableCount)
                analyzedVars["complexwordCount"] = float(complexwordsCount)
                analyzedVars["averageWordsPerSentence"] = float(averageWordsPerSentence)
                self.analyzedVars = analyzedVars