def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["subtree"], VP_RULES) val2 = FiPossSuffixFromSubject(FiA([val2], {"verbi", "-tu", "partitiivi"}), sibling_flags=val.flags, no_forwarding=True) return FiA([val, val2], val.flags)
def _(tree, params, rest): val = translateRest(tree) val2 = translate(params["subtree"], VP_RULES) pp = niTree(val2, {case, "-minen"}) if after: return FiA([val, fi_pre_val, pp, fi_post_val]) else: return FiA([fi_pre_val, pp, fi_post_val, val])
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["subtree"], NP_RULES) pp = niTree(val2, {case}) verbp = FiP(verb, {"verbi", "-va"}) if verb else FiNI("") if after: return FiA([val, verbp, fi_pre_val, pp, fi_post_val], val.flags) return FiA([fi_pre_val, pp, fi_post_val, verbp, val], val.flags)
def _(tree, params, rest): val = translate(tree, rest) if fi_determiner: return FiA([FiP(fi_determiner, det_flags or set()), val], val.flags | (flags or set())) elif flags: return FiA([val], val.flags | flags) else: return val
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["np"], NP_RULES) flags = set(val.flags) if "monikko" in val2.flags: pass # TODO: lippujen poistaminen alemmilta tasoilta # käytä "heikko partitiivi" -lippua return FiA([FiA([val2], {"ei omistusliitettä"}), val], flags)
def _(tree, params, rest): val = translate(tree, rest) if isinstance(val, FiVP): valverb = val.verb val.verb = FiA([ FiP(fi_verb, verbflags), compgen(valverb) if compgen else niTree(valverb, compflags) ]) val.flags |= phraseflags return val else: return FiA([ FiP(fi_verb, verbflags), compgen(val) if compgen else niTree(val, compflags) ])
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["subtree"], PHRASE_RULES) return FiA( [val, FiNI("("), FiNI(fi_conj), niTree(val2), FiNI(")")], val.flags)
def _(tree, params, rest): val = translateRest(tree) val2 = translate(params["subtree"], VP_RULES) subj = translate(params["subj"], NP_RULES) return FiVP(verb=FiA([FiP("olla"), niTree(val2, {"-tava"}), val]), subj=subj, flags={"nollapersoona"})
def _(tree, params, rest): val = translate(tree, VP_RULES) return FiA([val], {"-nut"})
def _(tree, params, rest): val = translate(tree, rest[1:]) return FiA([val], {"superlatiivi"})
def _(tree, params, rest): val = translate(tree, rest[1:]) return FiA([val], {"kielto"})
def _(tree, params, rest): val = translate(tree, rest) return FiA([val], {"passiivi", "pe4"})
def _(tree, params, rest): val = translateRest(tree) return FiA([FiP(fi_adv), val], flags)
def _(tree, params, rest): val = translate(tree, rest) return FiA([FiNI(fi_pronoun), val], val.flags | flags)
def translateRest(tree): ts = [] for subtree in tree["modifiers"]: ts.append(translateUnknownPos(subtree)) return FiA(ts, no_forwarding=True)
def _(tree, params, rest): val = translateRest(tree) noun = FiP(tree["lemma"], {"monikko"}) return FiA([noun, val], noun.flags)
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["proper"], NP_RULES) return FiA([niTree(val2, {"genetiivi"}), val], val.flags)
def _(tree, params, rest): val = translate(tree, rest) acl = translate(params["subtree"], VP_RULES) return FiA([FiA([acl], {"-tu"}), val], val.flags)
def _(tree, params, rest): val = translate(tree, rest) return FiA([FiNI("kuinka"), val], val.flags)
def _(tree, params, rest): val = translateRest(tree) val2 = translate(params["subtree"], VP_RULES) # TODO: predikatiivimuoto erikseen: kykenevä tekemään return FiA([niTree(val2, {"-minen", "illatiivi"}), FiP("kykenevä"), val])
def _(tree, params, rest): val = translateRest(tree) return FiA([FiP(fi_adj, {"adjektiivi"} | (flags or set())), val])
def _(tree, params, rest): ap = params["ap"] val = translate(tree, rest) val2 = translate(ap, NP_RULES) return FiA([niTree(val2, {"genetiivi"}), val], val.flags)
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["subtree"], VP_RULES) return FiA([val, niTree(val2, {"-a"})], val.flags)
def _(tree, params, rest): ap = params["ap"] val = translate(tree, rest) val2 = translate(ap, AP_RULES) return FiA([FiA([val2], {"ei omistusliitettä"}), val], val.flags)
def _(tree, params, rest): val = translate(tree, rest) return FiA([val], set())
def _(tree, params, rest): val = translateRest(tree) return FiA([randomTranslation(tree["lemma"], "fi:n"), val], {"monikko"})
def _(tree, params, rest): ap = params["ap"] val = translate(tree, rest) val2 = translate(ap, ADVP_RULES) return FiA([val, niTree(val2)])
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["ap"], VP_RULES) return FiA([FiA([val2], {"-tu"}), val])
ficode, filemma, encode, enlemma, rel = line.strip().split("\t")[:5] pos = ficode[:4] if rel == "synonym" and pos in trans: if enlemma not in trans[pos]: trans[pos][enlemma] = [] words = [FiP(word) for word in filemma.split(" ")] if pos == "fi:v": for i, word in enumerate(words[1:]): if word.word in OBJECT_CASES: words.pop(i+1) objcase = OBJECT_CASES[word.word] break else: objcase = "akkusatiivi" data = (words[0], words[1:], objcase) else: data = FiA(words) trans[pos][enlemma].append(TranslationPair(enlemma=enlemma, filemma=filemma, data=data)) print() def randomTranslation(word, pos): translations = trans[pos][word] tr_pair = random.choice(translations) settings.addTranslationPair(tr_pair) return tr_pair.data
def _(tree, params, rest): val = translate(tree, rest) val2 = translate(params["cc"], cc_rules) return FiA([val, FiNI(fi_conj), val2], val.flags)