Source

Kiva Editor's Assistant / tests / yearold.py

david_walker 465478a 



david_walker 05246e9 
















































from expect import expect

def test_year_old():
    expect(u'Mahmoud is a 47-year-old married man from Lebanon.')
    expect(u'This is 40 year-old Kadiatu.', 'This is 40-year-old Kadiatu.')
    expect(u'Eman is a 32 years old young woman.', u'Eman is a 32-year-old young woman.')

    # These cases are correct and should remain unchanged.
    expect(u'She is 47 years old.')
    expect(u'She is a 47-year-old farmer.')

    # These cases should be changed to have a single token of
    # '47-year-old'.
    expect(u'She is a 47 year old farmer.', u'She is a 47-year-old farmer.')
    expect(u'She is a 47-year old farmer.', u'She is a 47-year-old farmer.')
    expect(u'She is a 47 year-old farmer.', u'She is a 47-year-old farmer.')

    # These should have 'years' changed to 'year' and hyphens inserted.
    expect(ur'She is a 47 years old farmer.', ur'She is a 47-year-old farmer.')  # ok
    expect(ur'She is a 47-years old farmer.', ur'She is a 47-year-old farmer.')  # ok
    expect(ur'She is a 47 years-old farmer.', ur'She is a 47-year-old farmer.')
    expect(ur'She is a 47-years-old farmer.', ur'She is a 47-year-old farmer.')

    #
    # Here are the parse trees for all 9 cases:
    #
    # 1. She is 47 years old.
    #
    # root_informal
    #   subjh
    #     bare_npq
    #       she
    #         <She 0:3>
    #     hcomp
    #       be_c_is
    #         <is 4:6>
    #       npadv
    #         appos
    #           bare_np
    #             adjn
    #               attr_adj_verb_psv_part
    #                 generic_trans_verb_pas
    #                   <47 7:9>
    #               plur_noun_orule
    #                 year_n1
    #                   <years 10:15>
    #           proper_np
    #             adjn
    #               old_a1
    #                 <old 16:19>
    #               noptcomp
    #                 generic_year_ne
    #                   <. 19:20>
    #