1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
+
|
"""
Grammalecte - Compiled regular expressions
"""
import re
#### Lemme
Lemma = re.compile(r"^>(\w[\w-]*)")
#### Analyses
Gender = re.compile(":[mfe]")
Number = re.compile(":[spi]")
GenderNumber = re.compile(":[mfe]:[spi]")
#### Nom et adjectif
NA = re.compile(":[NA]")
## nombre
NAs = re.compile(":[NA].*:s")
NAp = re.compile(":[NA].*:p")
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
m = Number.search(sMorph)
if m:
if not sNumber:
sNumber = m.group(0)
elif sNumber != m.group(0):
return ":i"
return sNumber
def getGenderNumber (lMorph):
"returns tuple (gender, number) of word: (':m', ':f', ':e' or empty string) and (':s', ':p', ':i' or empty string)"
sGender = ""
sNumber = ""
for sMorph in lMorph:
m = GenderNumber.search(sMorph)
if m:
sGenderx = m.group(0)[0:2]
sNumberx = m.group(0)[2:4]
if not sGender:
sGender = sGenderx
elif sGender != sGenderx:
sGender = ":e"
if not sNumber:
sNumber = sNumberx
elif sNumber != sNumberx:
sNumber = ":i"
return sGender, sNumber
# NOTE : isWhat (lMorph) returns True if lMorph contains nothing else than What
# mbWhat (lMorph) returns True if lMorph contains What at least once
## isXXX = it’s certain
def isNom (lMorph):
|