Commit 3b2c5a39e0a92f4a93b27592e47a1c895dd6d489
1 parent
015571a6
infp we frazeologii
Showing
1 changed file
with
25 additions
and
0 deletions
semantics/phraseology_generator.py
... | ... | @@ -26,6 +26,9 @@ def lexicalisation(argument, subj, base, negativity, reference=None): |
26 | 26 | elif lexicalisation_type == 'prepadjp': #prepadjp(prep, case), number, gender, degree, adjectives, atr |
27 | 27 | prepadjps = get_prepadjps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1], subj, False, reference), get_number(attributes[1], subj, reference), get_gender(attributes[2], reference), get_degree(attributes[3]), get_words(attributes[4]), attributes[5]) |
28 | 28 | return (prepadjps, []) |
29 | + elif lexicalisation_type == 'infp': | |
30 | + infps = get_infps(get_aspect(lexicalisation_parameters[0]), get_words(attributes[2]), attributes[4]) | |
31 | + return (infps, []) | |
29 | 32 | else: |
30 | 33 | return ([], []) |
31 | 34 | return ([], []) |
... | ... | @@ -46,6 +49,9 @@ def get_words(attribute): |
46 | 49 | words = [word.text[1:-1] for word in attribute.values.all()] |
47 | 50 | return words |
48 | 51 | |
52 | +def get_aspect(attribute): | |
53 | + return attribute.values.all()[0].parameter.type.name | |
54 | + | |
49 | 55 | def get_case(attribute, is_subj, negativity, reference=None): |
50 | 56 | case = attribute.values.all()[0].parameter.type.name |
51 | 57 | if case == u'str': |
... | ... | @@ -115,6 +121,25 @@ def get_prepnps(prep, case, number, nouns, _atr): |
115 | 121 | nps = get_nps(case, number, nouns, _atr) |
116 | 122 | return [prep + ' ' + np for np in nps] |
117 | 123 | |
124 | +def get_infps(aspect, verbs, atr): | |
125 | + result = [] | |
126 | + for verb in verbs: | |
127 | + options = [(interp.orth, interp.getTag(MORFEUSZ2)) for interp in MORFEUSZ2.generate(verb.encode('utf8'))] | |
128 | + filtered = [] | |
129 | + for option in options: | |
130 | + (orth, tag) = option | |
131 | + if u'inf:' in tag: | |
132 | + filtered.append(option) | |
133 | + options = filtered | |
134 | + if aspect != u'_': | |
135 | + for option in options: | |
136 | + (orth, tag) = option | |
137 | + if u':' + aspect + u':' in tag: | |
138 | + filtered.append(option) | |
139 | + options = filtered | |
140 | + result += options | |
141 | + return dependents(atr, result) | |
142 | + | |
118 | 143 | def get_adjps(case, number, gender, degree, adjectives, atr): |
119 | 144 | result = [] |
120 | 145 | for adjective in adjectives: |
... | ... |