Skip to content

Commit e2096f0

Browse files
Rename phrase features
1 parent bd89be0 commit e2096f0

File tree

9 files changed

+100
-89
lines changed

9 files changed

+100
-89
lines changed

udapi/block/msf/phrase.py

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,63 @@
1010

1111
class Phrase(Block):
1212

13-
def process_node(self, node):
13+
def __init__(self, feature_prefix='CG', **kwargs):
1414
"""
15-
Override this in a derived class!
15+
Parameters:
16+
feature_prefix (string) - The prefix of phrase features (e. g. 'CG', 'Phrase'), default is 'CG'
1617
"""
17-
logging.fatal('process_node() not implemented.')
18+
super().__init__(**kwargs)
19+
self.feature_prefix = feature_prefix
20+
21+
self.dictionary = {
22+
'person': f'{feature_prefix}Person',
23+
'number': f'{feature_prefix}Number',
24+
'mood': f'{feature_prefix}Mood',
25+
'tense': f'{feature_prefix}Tense',
26+
'voice': f'{feature_prefix}Voice',
27+
'aspect':f'{feature_prefix}Aspect',
28+
'form': f'{feature_prefix}Form',
29+
'reflex': f'{feature_prefix}Reflex',
30+
'polarity': f'{feature_prefix}Polarity',
31+
'gender': f'{feature_prefix}Gender',
32+
'animacy': f'{feature_prefix}Animacy',
33+
'ords': feature_prefix,
34+
'expl': f'{feature_prefix}Expl',
35+
'analytic': 'Analytic',
36+
}
37+
38+
# a dictionary where the key is the lemma of a negative particle and the value is a list of the lemmas of their possible children that have a 'fixed' relation
39+
# we do not want to include these negative particles in the phrase; these are expressions like "never", etc.
40+
self.negation_fixed = {
41+
# Belarusian
42+
'ні' : ['раз'],
43+
'ня' : ['толькі'],
1844

19-
dictionary = {
20-
'person': 'PeriPerson',
21-
'number': 'PeriNumber',
22-
'mood': 'PeriMood',
23-
'tense': 'PeriTense',
24-
'voice': 'PeriVoice',
25-
'aspect':'PeriAspect',
26-
'form': 'PeriForm',
27-
'reflex': 'PeriReflex',
28-
'polarity': 'PeriPolarity',
29-
'gender':'PeriGender',
30-
'animacy':'PeriAnimacy',
31-
'ords':'Peri',
32-
'expl':'PeriExpl',
33-
'periphrasis':'Periphrasis',
34-
}
35-
36-
# a dictionary where the key is the lemma of a negative particle and the value is a list of the lemmas of their possible children that have a 'fixed' relation
37-
# we do not want to include these negative particles in the phrase; these are expressions like "never", etc.
38-
negation_fixed = {
39-
# Belarusian
40-
'ні' : ['раз'],
41-
'ня' : ['толькі'],
45+
# Upper Sorbian
46+
'nic' : ['naposledku'],
47+
48+
# Polish
49+
'nie' : ['mało'],
4250

43-
# Upper Sorbian
44-
'nic' : ['naposledku'],
51+
# Pomak
52+
'néma' : ['kak'],
4553

46-
# Polish
47-
'nie' : ['mało'],
54+
# Slovenian
55+
'ne' : ['le'],
4856

49-
# Pomak
50-
'néma' : ['kak'],
57+
# Russian and Old East Slavic
58+
'не' : ['то', 'токмо'],
59+
'ни' : ['в', 'раз', 'шатко'],
60+
'нет' : ['нет']
61+
}
5162

52-
# Slovenian
53-
'ne' : ['le'],
63+
def process_node(self, node):
64+
"""
65+
Override this in a derived class!
66+
"""
67+
logging.fatal('process_node() not implemented.')
5468

55-
# Russian and Old East Slavic
56-
'не' : ['то', 'токмо'],
57-
'ни' : ['в', 'раз', 'шатко'],
58-
'нет' : ['нет']
59-
}
69+
6070

6171
def write_node_info(self, node,
6272
tense = None,
@@ -72,7 +82,7 @@ def write_node_info(self, node,
7282
animacy = None,
7383
aspect = None,
7484
expl=None,
75-
periphrasis=None):
85+
analytic=None):
7686
arguments = locals()
7787
del arguments['self'] # delete self and node from arguments,
7888
del arguments['node'] # we want only grammatical categories
@@ -148,7 +158,7 @@ def get_voice(self,node,refl):
148158
return 'Pass'
149159
return voice
150160

151-
def get_periphrasis_bool(self,node):
161+
def get_analytic_bool(self,node):
152162
auxes = [x for x in node.children if x.udeprel == 'aux']
153163

154164
if auxes:

udapi/block/msf/romance/romance.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ def __init__(self, neg=True, **kwargs):
3030
"""
3131
Parameters:
3232
neg (bool) - If True, process negation and generate the PhrasePolarity=Neg attribute.
33+
feature_prefix (string) - The prefix of phrase features (e. g. 'CG', 'Phrase'), default is 'CG'
3334
"""
3435
super().__init__(**kwargs)
3536
self.neg = neg
3637

3738
def process_node(self, node):
3839

39-
if node.misc['Peri'] != '':
40+
if node.misc[self.feature_prefix] != '':
4041
return
4142

4243
cop = [x for x in node.children if x.udeprel == 'cop']
@@ -102,7 +103,7 @@ def process_node(self, node):
102103
gender=node.feats['Gender'],
103104
voice=node.feats['Voice'],
104105
expl=expl,
105-
periphrasis=self.get_periphrasis_bool(node),
106+
analytic=self.get_analytic_bool(node),
106107
ords=[node.ord]
107108
)
108109
return
@@ -250,7 +251,7 @@ def process_phrases_with_ir_aller_estar(self, node, expl, polarity, phrase_ords,
250251
tense = node.feats['Tense']
251252

252253
# phrase already annotated
253-
if head_node.misc['Peri'] != '':
254+
if head_node.misc[self.feature_prefix] != '':
254255
return
255256

256257
xcomps = [x for x in node.children if x.udeprel == 'xcomp']
@@ -330,7 +331,7 @@ def process_phrases_with_ir_aller_estar(self, node, expl, polarity, phrase_ords,
330331
voice=voice,
331332
expl = expl,
332333
polarity = polarity,
333-
periphrasis='Yes',
334+
analytic='Yes',
334335
ords=phrase_ords)
335336
return
336337

@@ -468,7 +469,7 @@ def process_simple_verb_forms(self, node, expl, polarity, phrase_ords, head_node
468469
voice=head_node.feats['Voice'],
469470
expl=expl,
470471
polarity=polarity,
471-
periphrasis=self.get_periphrasis_bool(head_node),
472+
analytic=self.get_analytic_bool(head_node),
472473
ords=phrase_ords
473474
)
474475

@@ -486,7 +487,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
486487
"""
487488

488489
# phrase already annotated
489-
if head_node.misc['Peri'] != '':
490+
if head_node.misc[self.feature_prefix] != '':
490491
return
491492

492493
if len(auxes) == 1:
@@ -521,7 +522,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
521522
expl=expl,
522523
polarity=polarity,
523524
voice=head_node.feats['Voice'],
524-
periphrasis='Yes',
525+
analytic='Yes',
525526
ords=phrase_ords)
526527
return
527528

@@ -545,7 +546,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
545546
voice=head_node.feats['Voice'],
546547
expl=expl,
547548
polarity=polarity,
548-
periphrasis='Yes',
549+
analytic='Yes',
549550
ords=phrase_ords)
550551
return
551552

@@ -570,7 +571,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
570571
voice=head_node.feats['Voice'],
571572
expl=expl,
572573
polarity=polarity,
573-
periphrasis='Yes',
574+
analytic='Yes',
574575
ords=phrase_ords)
575576
return
576577

@@ -609,7 +610,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
609610
aspect=aspect,
610611
expl=expl,
611612
polarity=polarity,
612-
periphrasis='Yes',
613+
analytic='Yes',
613614
ords=phrase_ords)
614615

615616
return
@@ -656,7 +657,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
656657
# Portuguese
657658
# pretérito perfeito composto (aux ter) -> PhraseTense=PastPres, PhraseAspect=Perf
658659
# subjonctive pretérito perfeito composto (aux ter) -> PhraseTense=PastPres, PhraseAspect=Perf, PhraseMood=Sub
659-
if auxes[0].lemma in ['ter', 'fi'] or auxes[0].feats['Mood'] == 'Sub':
660+
if auxes[0].lemma == 'fi' or auxes[0].feats['Mood'] == 'Sub':
660661
tense = Tense.PASTPRES.value
661662

662663
# subjonctive mood not annotated in Romanian data
@@ -700,7 +701,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
700701
voice=head_node.feats['Voice'],
701702
expl=expl,
702703
polarity=polarity,
703-
periphrasis='Yes',
704+
analytic='Yes',
704705
ords=phrase_ords)
705706
return
706707

@@ -745,7 +746,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
745746
voice=head_node.feats['Voice'],
746747
expl=expl,
747748
polarity=polarity,
748-
periphrasis='Yes',
749+
analytic='Yes',
749750
ords=phrase_ords)
750751

751752
return
@@ -764,7 +765,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
764765
voice=head_node.feats['Voice'],
765766
expl=expl,
766767
polarity=polarity,
767-
periphrasis='Yes',
768+
analytic='Yes',
768769
ords=phrase_ords)
769770

770771
return
@@ -791,7 +792,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
791792
voice=head_node.feats['Voice'],
792793
expl=expl,
793794
polarity=polarity,
794-
periphrasis='Yes',
795+
analytic='Yes',
795796
ords=phrase_ords)
796797

797798
return
@@ -811,7 +812,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
811812
voice=head_node.feats['Voice'],
812813
expl=expl,
813814
polarity=polarity,
814-
periphrasis='Yes',
815+
analytic='Yes',
815816
ords=phrase_ords)
816817

817818
return
@@ -829,7 +830,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
829830
voice=head_node.feats['Voice'],
830831
expl=expl,
831832
polarity=polarity,
832-
periphrasis='Yes',
833+
analytic='Yes',
833834
ords=phrase_ords)
834835

835836
return
@@ -867,7 +868,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
867868
voice=head_node.feats['Voice'],
868869
expl=expl,
869870
polarity=polarity,
870-
periphrasis='Yes',
871+
analytic='Yes',
871872
ords=phrase_ords)
872873

873874
# auxiliriy 'ir' in present or future tense followed by auxiliary 'ter' in infinitive and a participle
@@ -893,7 +894,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
893894
voice=head_node.feats['Voice'],
894895
expl=expl,
895896
polarity=polarity,
896-
periphrasis='Yes',
897+
analytic='Yes',
897898
ords=phrase_ords)
898899

899900
# Cnd (only ter/haber), Sub and Past,Pres,Fut tenses: 2 auxes - ter/haber + estar
@@ -932,7 +933,7 @@ def process_periphrastic_verb_forms(self, node, auxes, expl, polarity, phrase_or
932933
voice=head_node.feats['Voice'],
933934
expl=expl,
934935
polarity=polarity,
935-
periphrasis='Yes',
936+
analytic='Yes',
936937
ords=phrase_ords,
937938
)
938939
return

udapi/block/msf/slavic/conditional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def process_node(self, node):
5050
ords=phrase_ords,
5151
gender=node.feats['Gender'],
5252
animacy=node.feats['Animacy'],
53-
periphrasis=self.get_periphrasis_bool(node)
53+
analytic=self.get_analytic_bool(node)
5454
)
5555
return
5656

@@ -83,5 +83,5 @@ def process_node(self, node):
8383
ords=phrase_ords,
8484
gender=copVerb.feats['Gender'],
8585
animacy=copVerb.feats['Animacy'],
86-
periphrasis=self.get_periphrasis_bool(node)
86+
analytic=self.get_analytic_bool(node)
8787
)

udapi/block/msf/slavic/converb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def process_node(self, node):
3232
gender=node.feats['Gender'],
3333
animacy=node.feats['Animacy'],
3434
voice=self.get_voice(node, refl),
35-
periphrasis=self.get_periphrasis_bool(node)
35+
analytic=self.get_analytic_bool(node)
3636
)
3737

3838
# passive voice
@@ -59,7 +59,7 @@ def process_node(self, node):
5959
gender=auxVerb.feats['Gender'],
6060
animacy=auxVerb.feats['Animacy'],
6161
voice='Pass',
62-
periphrasis=self.get_periphrasis_bool(node)
62+
analytic=self.get_analytic_bool(node)
6363
)
6464

6565
# copulas
@@ -90,5 +90,5 @@ def process_node(self, node):
9090
polarity=self.get_polarity(phrase_nodes),
9191
ords=phrase_ords,
9292
voice=self.get_voice(copVerb, refl),
93-
periphrasis=self.get_periphrasis_bool(node)
93+
analytic=self.get_analytic_bool(node)
9494
)

0 commit comments

Comments
 (0)