def test_capitalized_cook(): test_util.start('Testing CapitalizedCook...') ep = CapitalizedCook() test_util.assertion( ep.match(NLP('He is a cook')).has_error, False, 'He is a cook') test_util.assertion( ep.match(NLP('He is a Cook')).has_error, True, 'He is a Cook') test_util.result()
def test_where_are_you_from(): test_util.start('Testing errors1.where_are_you_from...') test_util.assertion( where_are_you_from(NLP('I am Taiwan.')).has_error, True, 'I am Taiwan') test_util.assertion( where_are_you_from(NLP('I am from Taiwan.')).has_error, False, 'I am from Taiwan') test_util.result()
def test_capitalized_doctor(): test_util.start('Testing CapitalizedDoctor...') ep = CapitalizedDoctor() test_util.assertion( ep.match(NLP('She is a doctor')).has_error, False, 'She is a doctor') test_util.assertion( ep.match(NLP('She is a Doctor')).has_error, True, 'She is a Doctor') test_util.result()
def test_missing_verb(): test_util.start('Testing MissingVerb...') ep = MissingVerb() test_util.assertion(ep.match(NLP('He a doctor')).has_error, True, None) test_util.assertion(ep.match(NLP('Happy')).has_error, False, None) test_util.assertion(ep.match(NLP('I happy')).has_error, True, None) test_util.assertion( ep.match(NLP('She is a doctor')).has_error, False, None) test_util.assertion(ep.match(NLP('She a doctor.')).has_error, True, None) test_util.result()
def test_capitalized_father(): test_util.start('Testing CapitalizedFather...') ep = CapitalizedFather() test_util.assertion( ep.match(NLP('My father is a cook')).has_error, False, 'My father is a cook') test_util.assertion( ep.match(NLP('My Father is a cook')).has_error, True, 'My Father is a cook') test_util.result()
def test_state_is_positive(): test_util.start('Testing state_is_positive...') test_util.assertion(state_is_positive('happy'), True, 'happy') test_util.assertion(state_is_positive('very happy'), True, 'very happy') test_util.assertion(state_is_positive('sad'), False, 'sad') test_util.assertion(state_is_positive('OK'), False, 'OK') test_util.result()
def test_wrong_subject_is_3(): test_util.start('Testing WrongSubjectIs3...') ep = WrongSubjectIs('She') test_util.assertion( ep.match(NLP('He is a nurse')).has_error, True, 'He is a nurse') test_util.assertion( ep.match(NLP('It is a nurse')).has_error, True, 'It is a nurse') test_util.assertion( ep.match(NLP('This is a nurse')).has_error, True, 'This is a nurse') test_util.assertion( ep.match(NLP('That is a nurse')).has_error, True, 'That is a nurse') test_util.assertion( ep.match(NLP('She is a nurse')).has_error, False, 'She is a nurse') test_util.result()
def test_he_is_a_job(): test_util.start('Testing HeIsAJob match...') pattern = HeIsAJob() test_util.assertion(pattern.match(NLP('He is a cook')), True, None) test_util.assertion(pattern.match(NLP('He is a taxi driver.')), True, None) test_util.assertion(pattern.match(NLP('She is a policeman')), False, None) test_util.assertion(pattern.match(NLP('He is a Cook')), False, None) test_util.result()
def test_no_he_is_not(): test_util.start('Testing NoHeIsNot match...') pattern = NoHeIsNot() test_util.assertion(pattern.match(NLP('No')), True, None) test_util.assertion(pattern.match(NLP('No, he is not.')), True, None) test_util.assertion(pattern.match(NLP("No, he isn't")), True, None) test_util.assertion(pattern.match(NLP('Yes he is.')), False, None) test_util.result()
def test_she_is_a_doctor_match(): test_util.start('Testing SheIsADoctor match...') pattern = SheIsADoctor() test_util.assertion(pattern.match(NLP('She is a doctor')), True, None) test_util.assertion(pattern.match(NLP('She is a doctor.')), True, None) test_util.assertion(pattern.match(NLP('He is a doctor')), False, None) test_util.assertion(pattern.match(NLP('She is a Doctor')), False, None) test_util.result()
def test_polarity_mismatch(): test_util.start('Testing PolarityMismatch...') ep = PolarityMismatch() test_util.assertion(ep.match(NLP('Yes, he is')).has_error, False, None) test_util.assertion(ep.match(NLP('No, he is not')).has_error, False, None) test_util.assertion(ep.match(NLP("Yes, he isn't")).has_error, True, None) test_util.assertion(ep.match(NLP('No, he is.')).has_error, True, None) test_util.result()
def test_he_is_a_cook(): test_util.start('Testing SheIsADoctor match...') pattern = HeIsACook() test_util.assertion(pattern.match(NLP('He is a cook')), True, None) test_util.assertion(pattern.match(NLP('He is a cook.')), True, None) test_util.assertion(pattern.match(NLP('She is a cook')), False, None) test_util.assertion(pattern.match(NLP('He is a Cook')), False, None) test_util.result()
def test_wrong_determiner(): test_util.start('Testing WrongDeterminer...') ep = WrongDeterminer() test_util.assertion(ep.match(NLP('He is an doctor')).has_error, True, None) test_util.assertion(ep.match(NLP('He is a apple')).has_error, True, None) test_util.assertion(ep.match(NLP('He is an apple')).has_error, False, None) test_util.assertion(ep.match(NLP('He is a doctor')).has_error, False, None) test_util.result()
def test_sentence_starts_lower(): test_util.start('Testing SentenceStartsLower...') ep = SentenceStartsLower() test_util.assertion(ep.match(NLP('hi')).has_error, True, 'hi') test_util.assertion(ep.match(NLP('Hi')).has_error, False, 'Hi') test_util.assertion(ep.match(NLP('i am Tim')).has_error, True, 'i am Tim') test_util.assertion( ep.match(NLP('She is a cook')).has_error, False, 'She is a cook') test_util.result()
def test_missing_determiner(): test_util.start('Testing MissingDeterminer...') ep = MissingDeterminer() test_util.assertion(ep.match(NLP('He is doctor')).has_error, True, None) test_util.assertion( ep.match(NLP('I have cold')).has_error, True, 'I have cold') test_util.assertion(ep.match(NLP('He is a doctor')).has_error, False, None) test_util.assertion(ep.match(NLP('Yes, he is')).has_error, False, None) test_util.result()
def test_what_is_your_name(): test_util.start('Testing errors1.what_is_your_name...') assert not what_is_your_name(NLP('I am Tim')).has_error assert what_is_your_name(NLP('I am tim')).has_error assert what_is_your_name(NLP('He is Tim')).has_error test_util.assertion(what_is_your_name(NLP('Hi')).has_error, True, 'Hi') test_util.assertion(what_is_your_name(NLP('hi')).has_error, True, 'hi') test_util.assertion(what_is_your_name(NLP('Tim')).has_error, False, 'Tim') test_util.assertion(what_is_your_name(NLP('tim')).has_error, True, 'tim') test_util.result()
def test_my_mother_is_a_job(): test_util.start('Testing MyMotherIsAJob match...') pattern = MyMotherIsAJob() test_util.assertion(pattern.match(NLP('My mother is a cook')), True, 'My mother is a cook') test_util.assertion(pattern.match(NLP('My mother is a taxi driver.')), True, 'My mother is a taxi driver.') test_util.assertion(pattern.match(NLP('My Mother is a policeman')), False, 'My Mother is a policeman') test_util.assertion(pattern.match(NLP('My mother is a Cook')), False, 'My mother is a Cook') test_util.result()
def test_he_is_a_nurse(): test_util.start('Testing HeIsANurse match...') pattern = HeIsANurse() test_util.assertion(pattern.match(NLP('He is a nurse')), True, None) test_util.assertion(pattern.match(NLP('Nurse')), False, None) test_util.assertion(pattern.match(NLP("A nurse.")), False, None) test_util.result()
def test_wrong_subject2(): test_util.start('Testing WrongSubject2...') ep = WrongSubject2() test_util.assertion(ep.match(NLP('She is a cook')).has_error, True, None) test_util.assertion(ep.match(NLP('He is a cook')).has_error, False, None) test_util.assertion(ep.match(NLP('It is a cook.')).has_error, True, None) test_util.result()
def test_too_short_answer(): test_util.start('Testing TooShortAnswer...') ep = TooShortAnswer() test_util.assertion(ep.match(NLP('Nurse.')).has_error, True, 'Nurse') test_util.assertion(ep.match(NLP("A nurse")).has_error, True, "A nurse") test_util.assertion( ep.match(NLP('He is a nurse')).has_error, False, 'He is a nurse') test_util.result()
def test_wrong_job_2(): test_util.start('Testing WrongJob2...') ep = WrongJob('cook') test_util.assertion( ep.match(NLP('He is a driver')).has_error, True, 'driver') test_util.assertion(ep.match(NLP('He is a cook')).has_error, False, 'cook') test_util.assertion( ep.match(NLP('He is a teacher')).has_error, True, 'teacher') test_util.result()
def test_yes(): test_util.start('Testing Yes...') ep = Yes() test_util.assertion( ep.match(NLP('Yes, he is')).has_error, True, 'Yes, he is') test_util.assertion(ep.match(NLP("Yes")).has_error, True, "Yes") test_util.assertion( ep.match(NLP('No, he is not')).has_error, False, 'No, he is not') test_util.result()
def test_missing_comma(): test_util.start('Testing MissingComma...') ep = MissingComma() test_util.assertion( ep.match(NLP('No he is not.')).has_error, True, 'No he is not') test_util.assertion( ep.match(NLP("No he isn't.")).has_error, True, "No he isn't") test_util.assertion( ep.match(NLP('No, he is not.')).has_error, False, 'No, he is not') test_util.result()
def test_wrong_job_1(): test_util.start('Testing WrongJob1...') ep = WrongJob('doctor') test_util.assertion( ep.match(NLP('She is a driver')).has_error, True, 'driver') test_util.assertion( ep.match(NLP('She is a doctor')).has_error, False, 'doctor') test_util.assertion( ep.match(NLP('She is a teacher')).has_error, True, 'teacher') test_util.result()
def test_age_bracket(): test_util.start('Testing age_bracket...') test_util.assertion(age_bracket('5'), 0, '5') test_util.assertion(age_bracket('five'), 0, 'five') test_util.assertion(age_bracket('7'), 1, '7') test_util.assertion(age_bracket('seven'), 1, 'seven') test_util.assertion(age_bracket('31'), 2, '31') test_util.assertion(age_bracket('thirty-one'), 2, 'thirty-one') test_util.assertion(age_bracket('51'), 3, '51') test_util.assertion(age_bracket('fifty-one'), 3, 'fifty-one') test_util.result()
def test_wrong_subject_5(): test_util.start('Testing WrongSubject5...') ep = WrongSubject5() test_util.assertion( ep.match(NLP('Yes, she is')).has_error, True, 'Yes, she is') test_util.assertion(ep.match(NLP("No, she isn't")).has_error, True, "Yes") test_util.assertion( ep.match(NLP('Yes, it is')).has_error, True, 'Yes, it is') test_util.assertion( ep.match(NLP("No, it isn't")).has_error, True, "No, it isn't") test_util.assertion(ep.match(NLP("She is")).has_error, True, "She is") test_util.assertion( ep.match(NLP("She isn't")).has_error, True, "She isn't") test_util.assertion(ep.match(NLP("It is")).has_error, True, "It is") test_util.assertion(ep.match(NLP("It isn't")).has_error, True, "It isn't") test_util.assertion( ep.match(NLP('No, he is not')).has_error, False, 'No, he is not') test_util.result()
def test_state_polarity(): test_util.start('Testing state_polarity...') test_util.assertion(state_polarity('happy'), 2, 'happy') test_util.assertion(state_polarity('so so'), 1, 'so so') test_util.assertion(state_polarity('sad'), 0, 'sad') test_util.result()
def test_text_to_number(): test_util.start('Testing text_to_number...') test_util.assertion(text_to_number('one'), 1, 'one') test_util.assertion(text_to_number('two'), 2, 'two') test_util.assertion(text_to_number('three'), 3, 'three') test_util.assertion(text_to_number('four'), 4, 'four') test_util.assertion(text_to_number('five'), 5, 'five') test_util.assertion(text_to_number('six'), 6, 'six') test_util.assertion(text_to_number('seven'), 7, 'seven') test_util.assertion(text_to_number('eight'), 8, 'eight') test_util.assertion(text_to_number('nine'), 9, 'nine') test_util.assertion(text_to_number('ten'), 10, 'ten') test_util.assertion(text_to_number('eleven'), 11, 'eleven') test_util.assertion(text_to_number('twelve'), 12, 'twelve') test_util.assertion(text_to_number('thirteen'), 13, 'thirteen') test_util.assertion(text_to_number('fourteen'), 14, 'fourteen') test_util.assertion(text_to_number('fifteen'), 15, 'fifteen') test_util.assertion(text_to_number('sixteen'), 16, 'sixteen') test_util.assertion(text_to_number('seventeen'), 17, 'seventeen') test_util.assertion(text_to_number('eighteen'), 18, 'eighteen') test_util.assertion(text_to_number('nineteen'), 19, 'nineteen') test_util.assertion(text_to_number('twenty'), 20, 'twenty') test_util.assertion(text_to_number('twenty-one'), 21, 'twenty-one') test_util.assertion(text_to_number('Twenty-one'), 21, 'Twenty-one') test_util.result()
def test_well_formed_number(): test_util.start('Testing well_formed_number...') test_util.assertion(well_formed_number('one'), True, 'one') test_util.assertion(well_formed_number('two'), True, 'two') test_util.assertion(well_formed_number('three'), True, 'three') test_util.assertion(well_formed_number('four'), True, 'four') test_util.assertion(well_formed_number('five'), True, 'five') test_util.assertion(well_formed_number('six'), True, 'six') test_util.assertion(well_formed_number('seven'), True, 'seven') test_util.assertion(well_formed_number('eight'), True, 'eight') test_util.assertion(well_formed_number('nine'), True, 'nine') test_util.assertion(well_formed_number('ten'), True, 'ten') test_util.assertion(well_formed_number('eleven'), True, 'eleven') test_util.assertion(well_formed_number('twelve'), True, 'twelve') test_util.assertion(well_formed_number('thirteen'), True, 'thirteen') test_util.assertion(well_formed_number('fourteen'), True, 'fourteen') test_util.assertion(well_formed_number('fifteen'), True, 'fifteen') test_util.assertion(well_formed_number('sixteen'), True, 'sixteen') test_util.assertion(well_formed_number('seventeen'), True, 'seventeen') test_util.assertion(well_formed_number('eighteen'), True, 'eighteen') test_util.assertion(well_formed_number('nineteen'), True, 'nineteen') test_util.assertion(well_formed_number('twenty'), True, 'twenty') test_util.assertion(well_formed_number('twenty-one'), True, 'twenty-one') test_util.assertion(well_formed_number('twenty one'), False, 'twenty one') test_util.assertion(well_formed_number('one-twenty'), False, 'one-twenty') test_util.result()