Example #1
0
File: rules.py Project: fergusq/hau
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)
Example #2
0
File: rules.py Project: fergusq/hau
 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])
Example #3
0
File: rules.py Project: fergusq/hau
 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)
Example #4
0
File: rules.py Project: fergusq/hau
 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
Example #5
0
File: rules.py Project: fergusq/hau
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)
Example #6
0
File: rules.py Project: fergusq/hau
 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)
         ])
Example #7
0
File: rules.py Project: fergusq/hau
 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)
Example #8
0
File: rules.py Project: fergusq/hau
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"})
Example #9
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, VP_RULES)
    return FiA([val], {"-nut"})
Example #10
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest[1:])
    return FiA([val], {"superlatiivi"})
Example #11
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest[1:])
    return FiA([val], {"kielto"})
Example #12
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    return FiA([val], {"passiivi", "pe4"})
Example #13
0
File: rules.py Project: fergusq/hau
 def _(tree, params, rest):
     val = translateRest(tree)
     return FiA([FiP(fi_adv), val], flags)
Example #14
0
File: rules.py Project: fergusq/hau
 def _(tree, params, rest):
     val = translate(tree, rest)
     return FiA([FiNI(fi_pronoun), val], val.flags | flags)
Example #15
0
File: rules.py Project: fergusq/hau
def translateRest(tree):
    ts = []
    for subtree in tree["modifiers"]:
        ts.append(translateUnknownPos(subtree))
    return FiA(ts, no_forwarding=True)
Example #16
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translateRest(tree)
    noun = FiP(tree["lemma"], {"monikko"})
    return FiA([noun, val], noun.flags)
Example #17
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    val2 = translate(params["proper"], NP_RULES)
    return FiA([niTree(val2, {"genetiivi"}), val], val.flags)
Example #18
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    acl = translate(params["subtree"], VP_RULES)
    return FiA([FiA([acl], {"-tu"}), val], val.flags)
Example #19
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    return FiA([FiNI("kuinka"), val], val.flags)
Example #20
0
File: rules.py Project: fergusq/hau
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])
Example #21
0
File: rules.py Project: fergusq/hau
 def _(tree, params, rest):
     val = translateRest(tree)
     return FiA([FiP(fi_adj, {"adjektiivi"} | (flags or set())), val])
Example #22
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    ap = params["ap"]
    val = translate(tree, rest)
    val2 = translate(ap, NP_RULES)
    return FiA([niTree(val2, {"genetiivi"}), val], val.flags)
Example #23
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    val2 = translate(params["subtree"], VP_RULES)
    return FiA([val, niTree(val2, {"-a"})], val.flags)
Example #24
0
File: rules.py Project: fergusq/hau
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)
Example #25
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    return FiA([val], set())
Example #26
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translateRest(tree)
    return FiA([randomTranslation(tree["lemma"], "fi:n"), val], {"monikko"})
Example #27
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    ap = params["ap"]
    val = translate(tree, rest)
    val2 = translate(ap, ADVP_RULES)
    return FiA([val, niTree(val2)])
Example #28
0
File: rules.py Project: fergusq/hau
def _(tree, params, rest):
    val = translate(tree, rest)
    val2 = translate(params["ap"], VP_RULES)
    return FiA([FiA([val2], {"-tu"}), val])
Example #29
0
File: fiwn.py Project: fergusq/hau
		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
Example #30
0
File: rules.py Project: fergusq/hau
 def _(tree, params, rest):
     val = translate(tree, rest)
     val2 = translate(params["cc"], cc_rules)
     return FiA([val, FiNI(fi_conj), val2], val.flags)