def test_english_constants(self): lan = LanguageRule().en constants = FleschKincaidDifficultyEstimator.get_constants_for_language(lan) self.assertEqual(206.835, constants["start"]) self.assertEqual(1.015, constants["sentence"]) self.assertEqual(84.6, constants["word"])
def test_german_constants(self): lan = LanguageRule().de constants = FleschKincaidDifficultyEstimator.get_constants_for_language(lan) self.assertEqual(180, constants["start"]) self.assertEqual(1, constants["sentence"]) self.assertEqual(58.5, constants["word"])
def test_discrete_between_80_and_50(self): d = FleschKincaidDifficultyEstimator.discrete_difficulty(60) self.assertEqual(d, 'MEDIUM')
def test_discrete_below_0(self): d = FleschKincaidDifficultyEstimator.discrete_difficulty(-10) self.assertEqual(d, 'HARD')
def test_discrete_above_80(self): d = FleschKincaidDifficultyEstimator.discrete_difficulty(100) self.assertEqual(d, 'EASY')
def test_discrete_80(self): d = FleschKincaidDifficultyEstimator.discrete_difficulty(80) self.assertEqual(d, 'MEDIUM')
def test_normalized_between_100_and_0(self): d = FleschKincaidDifficultyEstimator.normalize_difficulty(50) self.assertEqual(d, 0.5)
def test_normalized_below_0(self): d = FleschKincaidDifficultyEstimator.normalize_difficulty(-10) self.assertEqual(d, 1)
def test_recognized_by_flesch_kincaid(self): name = "flesch-kincaid" self.assertTrue(FleschKincaidDifficultyEstimator.has_custom_name(name))
def test_normalized_100(self): d = FleschKincaidDifficultyEstimator.normalize_difficulty(100) self.assertEqual(d, 0)
def test_recognized_by_FKIndex(self): name = "FKIndex" self.assertTrue(FleschKincaidDifficultyEstimator.has_custom_name(name))
def test_german_hard(self): lan = LanguageRule().de d = FleschKincaidDifficultyEstimator.estimate_difficulty(DE_HARD_TEXT, lan, self.user) self.assertEqual('HARD', d['discrete'])
def test_german_medium(self): lan = LanguageRule().de d = FleschKincaidDifficultyEstimator.estimate_difficulty(DE_MEDIUM_TEXT, lan, self.user) self.assertEqual('MEDIUM', d['discrete'])
def test_english_hard(self): lan = LanguageRule().en d = FleschKincaidDifficultyEstimator.estimate_difficulty(E_HARD_TEXT, lan, self.user) self.assertEqual(d['discrete'], 'HARD')
def test_english_medium(self): lan = LanguageRule().en d = FleschKincaidDifficultyEstimator.estimate_difficulty(E_MEDIUM_TEXT, lan, self.user) self.assertEqual(d['discrete'], 'MEDIUM')