def test_error_maker_pronoun_errors_p_error_gte_one(self): sentences = [ Sentence([ Pronoun.I, Pronoun.ME, Pronoun.YOU, Pronoun.HE, Pronoun.HIM, Pronoun.SHE, Pronoun.HER, Pronoun.IT, Pronoun.WE, Pronoun.US, Pronoun.THEY, Pronoun.THEM ]), Sentence([ CapitalPronoun.I, Pronoun.ME, CapitalPronoun.YOU, CapitalPronoun.HE, Pronoun.HIM, CapitalPronoun.SHE, Pronoun.HER, CapitalPronoun.IT, CapitalPronoun.WE, Pronoun.US, CapitalPronoun.THEY, Pronoun.THEM ]) ] expected = [ Sentence([ Pronoun.ME, Pronoun.I, Pronoun.YOU, Pronoun.HIM, Pronoun.HE, Pronoun.HER, Pronoun.SHE, Pronoun.IT, Pronoun.US, Pronoun.WE, Pronoun.THEM, Pronoun.THEY ]), Sentence([ CapitalPronoun.ME, Pronoun.I, CapitalPronoun.YOU, CapitalPronoun.HIM, Pronoun.HE, CapitalPronoun.HER, Pronoun.SHE, CapitalPronoun.IT, CapitalPronoun.US, Pronoun.WE, CapitalPronoun.THEM, Pronoun.THEY ]) ] paragraph = Paragraph(sentences) error_maker = ErrorMaker(paragraph) error_paragraph = error_maker.pronoun_errors(1.0).get_paragraph() self.assertEqual(error_paragraph.sentence_list(), expected) error_paragraph = error_maker.pronoun_errors(1.1).get_paragraph() self.assertEqual(error_paragraph.sentence_list(), expected)
def test_error_maker_pronoun_errors_p_error_lte_zero(self): sentences = [ Sentence([Pronoun.HE, Pronoun.THEY, Pronoun.ME, Pronoun.YOU]) ] paragraph = Paragraph(sentences) error_maker = ErrorMaker(paragraph) error_paragraph = error_maker.pronoun_errors(0.0).get_paragraph() self.assertEqual(error_paragraph.sentence_list(), sentences) error_paragraph = error_maker.pronoun_errors(-1.0).get_paragraph() self.assertEqual(error_paragraph.sentence_list(), sentences)
def test_error_maker_pronoun_error_does_not_affect_others(self): sentences = [ Sentence([ BasicWord.preposition('a'), Verb('a'), Noun('a'), Punctuation.COMMA, BeVerb.AM ]) ] error_maker = ErrorMaker(Paragraph(sentences)) error_paragraph = error_maker.pronoun_errors(1.0).get_paragraph() self.assertEqual(error_paragraph.sentence_list(), sentences)
def test_error_maker_pronoun_error_p_error_middle(self): random.seed(47534) sentences = [ Sentence([Pronoun.I, Pronoun.HE]), Sentence([Pronoun.US, Pronoun.THEM]) ] paragraph = Paragraph(sentences) error_maker = ErrorMaker(paragraph) error_paragraph = error_maker.pronoun_errors(0.5).get_paragraph() expected = [ Sentence([Pronoun.ME, Pronoun.HE]), Sentence([Pronoun.US, Pronoun.THEY]) ] self.assertEqual(error_paragraph.sentence_list(), expected)
def test_error_maker_verb_errors_retains_capital_letters_in_first_word( self): sentences = [ Sentence([Verb('A'), Verb('b')]), Sentence([Verb('d'), Verb('e')]), Sentence([Verb('F'), Verb('g')]) ] error_maker = ErrorMaker(Paragraph(sentences)) error_pargraph = error_maker.pronoun_errors(1.0).get_paragraph() capitals = [0, 2] for index, sentence in enumerate(error_pargraph): first_word = sentence.get(0) if index in capitals: self.assertEqual(first_word.capitalize(), first_word) else: self.assertNotEqual(first_word.capitalize(), first_word)
def test_error_maker_pronoun_errors_retains_capital_letters_in_first_word( self): sentences = [ Sentence([CapitalPronoun.I, Pronoun.ME]), Sentence([Pronoun.HIM, Pronoun.HE]), Sentence([CapitalPronoun.HER, Pronoun.THEY]) ] error_maker = ErrorMaker(Paragraph(sentences)) error_pargraph = error_maker.pronoun_errors(1.0).get_paragraph() capitals = [0, 2] for index, sentence in enumerate(error_pargraph): first_word = sentence.get(0) if index in capitals: self.assertEqual(first_word.capitalize(), first_word) else: self.assertNotEqual(first_word.capitalize(), first_word)
def test_error_maker_empty_paragraph(self): paragraph = Paragraph([]) error_maker = ErrorMaker(paragraph) self.assertEqual( error_maker.noun_errors(1.0).get_paragraph().sentence_list(), []) self.assertEqual( error_maker.pronoun_errors(1.0).get_paragraph().sentence_list(), []) self.assertEqual( error_maker.verb_errors(1.0).get_paragraph().sentence_list(), []) self.assertEqual( error_maker.is_do_errors(1.0).get_paragraph().sentence_list(), []) self.assertEqual( error_maker.preposition_errors( 1.0).get_paragraph().sentence_list(), []) self.assertEqual( error_maker.punctuation_errors( 1.0).get_paragraph().sentence_list(), [])
def test_error_maker_preposition_errors_retains_capital_letters_in_first_word( self): sentences = [ Sentence([Verb('Go'), BasicWord.preposition('with'), Pronoun.HIM]), Sentence([Verb('go'), BasicWord.preposition('with'), Pronoun.HIM]), Sentence([Verb('Eat'), BasicWord.preposition('at'), Noun("Joe's")]) ] error_maker = ErrorMaker(Paragraph(sentences)) error_pargraph = error_maker.pronoun_errors(1.0).get_paragraph() capitals = [0, 2, 3] for index, sentence in enumerate(error_pargraph): first_word = sentence.get(0) if index in capitals: self.assertEqual(first_word.capitalize(), first_word) else: self.assertNotEqual(first_word.capitalize(), first_word)