def ate_fish(verbosity=0, all_sols=True): """ Amh->Orm አሳ በላ (he ate fish) -> qurxummii nyaate. Illustrates (1) SL-TL feature agreement """ amh, orm = hiiktuu.Language.load('amh', 'orm') s = hiiktuu.Sentence(raw="አሳ በላ", language=amh, target=orm, verbosity=verbosity) # print("Translating {} to {}".format(s.raw, s.target)) s.initialize(verbosity=verbosity) s.solve(verbosity=verbosity, all_sols=all_sols) return s
def kick_the_bucket(verbosity=0, all_sols=True): """ Eng->Spa Illustrates (1) SL group ambiguity (search for solutions) (2) SL-TL feature agreement """ eng, spa = hiiktuu.Language.load('eng', 'spa') s = hiiktuu.Sentence(raw='John kicked the bucket', language=eng, target=spa, verbosity=verbosity) # print("Translating {} to {}".format(s.raw, s.target)) s.initialize(verbosity=verbosity) s.solve(verbosity=verbosity, all_sols=all_sols) return s
def piece_of_mind_parse_ung(verbosity=0, all_sols=True): """ Eng parse. Illustrates (1) within SL agreement (fails because 'my' doesn't agree with 'gives') """ eng = hiiktuu.Language.load('eng')[0] s = hiiktuu.Sentence(raw='Mary gives them a piece of my mind', language=eng, verbosity=verbosity) # print("Parsing: {}".format(s.raw)) s.initialize(verbosity=verbosity) s.solve(translate=False, verbosity=verbosity, all_sols=all_sols) return s
def never_eaten_fish_ungr(trans=True, verbosity=0, all_sols=True): """ Amh አሳ በልተው አያውቅም 'he's never eaten fish' (ungrammatical because the በልተው is 3rd person *plural* so it doesn't agree with አያውቅም). Like the last case except since this is ungrammatical, no solution is found that covers all of the words. """ amh, orm = hiiktuu.Language.load('amh', 'orm') s = hiiktuu.Sentence(raw="አሳ በልተው አያውቅም", language=amh, target=orm, verbosity=verbosity) # print("Attempting to translate {} to {}".format(s.raw, s.target)) s.initialize(verbosity=verbosity) s.solve(verbosity=verbosity, all_sols=all_sols) return s
def end_of_world(verbosity=0, all_sols=True): """ Eng->Spa it's the end of the world -> es el fin del mundo Illustrates (1) SL-TL word count mismatch (SL > TL) """ eng, spa = hiiktuu.Language.load('eng', 'spa') s = hiiktuu.Sentence(raw="it's the end of the world", language=eng, target=spa, verbosity=verbosity) # print("Translating {} to {}".format(s.raw, s.target)) s.initialize(verbosity=verbosity) s.solve(verbosity=verbosity, all_sols=all_sols) return s
def piece_of_mind_trans(verbosity=0, all_sols=True): """ Eng->Spa Illustrates (1) within SL agreement (succeeds because 'her' agrees with 'gives') (2) SL-TL feature agreement (3) SL-TL word count mismatch (SL > TL) """ eng, spa = hiiktuu.Language.load('eng', 'spa') s = hiiktuu.Sentence(raw='Mary gives them a piece of her mind', language=eng, target=spa, verbosity=verbosity) # print("Translating {} to {}".format(s.raw, s.target)) s.initialize(verbosity=verbosity) s.solve(translate=True, verbosity=verbosity, all_sols=all_sols) return s
def never_eaten_fish(verbosity=0, trans=True, all_sols=True): """ Amh አሳ በልቶ አያውቅም 'he's never eaten fish' Either parse (trans=False) or translate -> Orm: qurxummii nyaate hin beeku. Illustrates (1) SL-TL feature agreement (2) SL-TL word count mismatch (SL < TL) """ amh, orm = hiiktuu.Language.load('amh', 'orm') s = hiiktuu.Sentence(raw="አሳ በልቶ አያውቅም", language=amh, target=orm, verbosity=verbosity) s.initialize(verbosity=verbosity) if trans: # print("Translating {} to {}".format(s.raw, s.target)) s.solve(verbosity=verbosity, all_sols=all_sols) else: # print("Parsing: {}".format(s.raw)) s.solve(translate=False, verbosity=verbosity, all_sols=all_sols) return s
def cantar_las_cuarenta_I(trans=True, verbosity=0, all_sols=True): """ Spa->Eng les canté las cuarenta -> read them the riot act. -> gave them a piece of my mind. Illustrates (1) SL-TL feature agreement (2) SL-TL mismatch in word count (SL < TL) (3) SL-TL mismatch in word order (4) SL word not associated with any group (5) within-TL-group agreement """ spa, eng = hiiktuu.Language.load('spa', 'eng') s = hiiktuu.Sentence(raw="les canté las cuarenta", language=spa, target=eng if trans else None, verbosity=verbosity) # print("Translating {} to {}".format(s.raw, s.target)) s.initialize(verbosity=verbosity) s.solve(translate=trans, verbosity=verbosity, all_sols=all_sols) return s