121
122
123
124
125
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
nXB = nX1 + 195
nXC = nXB + 205
nHeight = 10
#### Add word
self._addWidget("add_section", 'FixedLine', nX1, nY1, 190, nHeight, Label = self.dUI.get("add_section", "#err"), FontDescriptor = xFDTitle)
#self._addWidget('main_lemma_label', 'FixedText', nX1, nY1+10, 30, nHeight, Label = self.dUI.get('lemma', "#err"))
self.xLemma = self._addWidget('main_lemma', 'Edit', nX1, nY1+10, 120, 14, FontDescriptor = xFDTitle)
self._addWidget('generate_button', 'Button', nX1+130, nY1+10, 60, 14, Label = self.dUI.get('generate_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000)
# Radio buttons: main POS tag
# Note: the only way to group RadioButtons is to create them successively
self.xNA = self._addWidget('nom_adj', 'RadioButton', nX1, nY2+12, 60, nHeight, Label = self.dUI.get("nom_adj", "#err"), HelpText = ":N:A")
self.xN = self._addWidget('nom', 'RadioButton', nX1, nY2+22, 60, nHeight, Label = self.dUI.get("nom", "#err"), HelpText = ":N")
self.xA = self._addWidget('adj', 'RadioButton', nX1, nY2+32, 60, nHeight, Label = self.dUI.get("adj", "#err"), HelpText = ":A")
self.xM1 = self._addWidget('M1', 'RadioButton', nX1, nY3+12, 60, nHeight, Label = self.dUI.get("M1", "#err"), HelpText = ":M1")
self.xM2 = self._addWidget('M2', 'RadioButton', nX1, nY3+22, 60, nHeight, Label = self.dUI.get("M2", "#err"), HelpText = ":M2")
self.xMP = self._addWidget('MP', 'RadioButton', nX1, nY3+32, 60, nHeight, Label = self.dUI.get("MP", "#err"), HelpText = ":MP")
self.xV = self._addWidget('verb', 'RadioButton', nX1, nY4+2, 10, nHeight, HelpText = ":V")
self.xW = self._addWidget('adv', 'RadioButton', nX1, nY5+2, 10, nHeight, HelpText = ":W")
self.xX = self._addWidget('other', 'RadioButton', nX1, nY6+2, 10, nHeight, HelpText = ":X")
# Nom, adjectif
self._addWidget("fl_nom_adj", 'FixedLine', nX1, nY2, 190, nHeight, Label = self.dUI.get("common_name", "#err"), FontDescriptor = xFDSubTitle)
self.xSepi = self._addWidget('Sepi', 'RadioButton', nX1+65, nY2+12, 50, nHeight, Label = self.dUI.get("epi", "#err"), HelpText = ":e")
self.xSmas = self._addWidget('Smas', 'RadioButton', nX1+65, nY2+22, 50, nHeight, Label = self.dUI.get("mas", "#err"), HelpText = ":m")
self.xSfem = self._addWidget('Sfem', 'RadioButton', nX1+65, nY2+32, 50, nHeight, Label = self.dUI.get("fem", "#err"), HelpText = ":f")
self._addWidget("fl_sep1", 'FixedLine', nX1, nY2, 1, nHeight)
self.xSs = self._addWidget('S-s', 'RadioButton', nX1+120, nY2+12, 50, nHeight, Label = self.dUI.get("-s", "#err"), HelpText = "·s")
self.xSx = self._addWidget('S-x', 'RadioButton', nX1+120, nY2+22, 50, nHeight, Label = self.dUI.get("-x", "#err"), HelpText = "·x")
self.xSinv = self._addWidget('Sinv', 'RadioButton', nX1+120, nY2+32, 50, nHeight, Label = self.dUI.get("inv", "#err"), HelpText = ":i")
self._addWidget("alt_lemma_label", 'FixedLine', nX1+10, nY2+42, 180, nHeight, Label = self.dUI.get("alt_lemma", "#err"))
self.xAltLemma = self._addWidget('alt_lemma', 'Edit', nX1+10, nY2+52, 120, nHeight)
self.xNA2 = self._addWidget('nom_adj2', 'RadioButton', nX1+10, nY2+65, 60, nHeight, Label = self.dUI.get("nom_adj", "#err"), HelpText = ":N:A")
self.xN2 = self._addWidget('nom2', 'RadioButton', nX1+10, nY2+75, 60, nHeight, Label = self.dUI.get("nom", "#err"), HelpText = ":N")
self.xA2 = self._addWidget('adj2', 'RadioButton', nX1+10, nY2+85, 60, nHeight, Label = self.dUI.get("adj", "#err"), HelpText = ":A")
self._addWidget("fl_sep2", 'FixedLine', nX1, nY2, 1, nHeight)
self.xSepi2 = self._addWidget('Sepi2', 'RadioButton', nX1+75, nY2+65, 50, nHeight, Label = self.dUI.get("epi", "#err"), HelpText = ":e")
self.xSmas2 = self._addWidget('Smas2', 'RadioButton', nX1+75, nY2+75, 50, nHeight, Label = self.dUI.get("mas", "#err"), HelpText = ":m")
self.xSfem2 = self._addWidget('Sfem2', 'RadioButton', nX1+75, nY2+85, 50, nHeight, Label = self.dUI.get("fem", "#err"), HelpText = ":f")
self._addWidget("fl_sep3", 'FixedLine', nX1, nY2, 1, nHeight)
self.xSs2 = self._addWidget('S-s2', 'RadioButton', nX1+130, nY2+65, 50, nHeight, Label = self.dUI.get("-s", "#err"), HelpText = "·s")
self.xSx2 = self._addWidget('S-x2', 'RadioButton', nX1+130, nY2+75, 50, nHeight, Label = self.dUI.get("-x", "#err"), HelpText = "·x")
self.xSinv2 = self._addWidget('Sinv2', 'RadioButton', nX1+130, nY2+85, 50, nHeight, Label = self.dUI.get("inv", "#err"), HelpText = ":i")
# Nom propre
self._addWidget("fl_M", 'FixedLine', nX1, nY3, 190, nHeight, Label = self.dUI.get("proper_name", "#err"), FontDescriptor = xFDSubTitle)
self.xMepi = self._addWidget('Mepi', 'RadioButton', nX1+65, nY3+12, 50, nHeight, Label = self.dUI.get("epi", "#err"), HelpText = ":e")
self.xMmas = self._addWidget('Mmas', 'RadioButton', nX1+65, nY3+22, 50, nHeight, Label = self.dUI.get("mas", "#err"), HelpText = ":m")
self.xMfem = self._addWidget('Mfem', 'RadioButton', nX1+65, nY3+32, 50, nHeight, Label = self.dUI.get("fem", "#err"), HelpText = ":f")
# Verbe
self._addWidget("fl_verb", 'FixedLine', nX2, nY4, 180, nHeight, Label = self.dUI.get("verb", "#err"), FontDescriptor = xFDSubTitle)
self.xV_i = self._addWidget('v_i', 'CheckBox', nX2, nY4+12, 60, nHeight, Label = self.dUI.get("v_i", "#err"))
self.xV_t = self._addWidget('v_t', 'CheckBox', nX2, nY4+20, 60, nHeight, Label = self.dUI.get("v_t", "#err"))
self.xV_n = self._addWidget('v_n', 'CheckBox', nX2, nY4+28, 60, nHeight, Label = self.dUI.get("v_n", "#err"))
self.xV_p = self._addWidget('v_p', 'CheckBox', nX2, nY4+36, 60, nHeight, Label = self.dUI.get("v_p", "#err"))
self.xV_m = self._addWidget('v_m', 'CheckBox', nX2, nY4+44, 60, nHeight, Label = self.dUI.get("v_m", "#err"))
self._addWidget('aux', 'FixedText', nX2+75, nY4+10, 90, nHeight, Label = self.dUI.get("aux", "#err"))
self.xV_ae = self._addWidget('v_ae', 'CheckBox', nX2+75, nY4+20, 90, nHeight, Label = self.dUI.get("v_ae", "#err"))
self.xV_aa = self._addWidget('v_aa', 'CheckBox', nX2+75, nY4+28, 90, nHeight, Label = self.dUI.get("v_aa", "#err"))
self.xV_pp = self._addWidget('v_pp', 'CheckBox', nX2+75, nY4+44, 90, nHeight, Label = self.dUI.get("v_pp", "#err"))
self._addWidget('v_pattern_label', 'FixedText', nX2+10, nY4+56, 70, nHeight, Label = self.dUI.get('v_pattern', "#err"), Align = 2)
self.xVpattern = self._addWidget('v_pattern', 'Edit', nX2+85, nY4+56, 80, nHeight)
# Adverbe
self._addWidget("fl_adv", 'FixedLine', nX2, nY5, 180, nHeight, Label = self.dUI.get("adverb", "#err"), FontDescriptor = xFDSubTitle)
# Autre
self._addWidget("fl_other", 'FixedLine', nX2, nY6, 180, nHeight, Label = self.dUI.get("other", "#err"), FontDescriptor = xFDSubTitle)
self._addWidget('flexion_label', 'FixedText', nX2, nY6+10, 85, nHeight, Label = self.dUI.get('flexion', "#err"))
self.xFlexion = self._addWidget('flexion', 'Edit', nX2, nY6+20, 85, nHeight)
self._addWidget('tags_label', 'FixedText', nX2+90, nY6+10, 85, nHeight, Label = self.dUI.get('tags', "#err"))
self.xTags = self._addWidget('tags', 'Edit', nX2+90, nY6+20, 85, nHeight)
#### Generated words
self._addWidget("gwords_section", 'FixedLine', nXB, nY1, 200, nHeight, Label = self.dUI.get("new_section", "#err"), FontDescriptor = xFDTitle)
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
123
124
125
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
nXB = nX1 + 195
nXC = nXB + 205
nHeight = 10
#### Add word
self._addWidget("add_section", 'FixedLine', nX1, nY1, 190, nHeight, Label = self.dUI.get("add_section", "#err"), FontDescriptor = xFDTitle)
self.xLemma = self._addWidget('lemma', 'Edit', nX1, nY1+10, 120, 14, FontDescriptor = xFDTitle)
self._addWidget('close_button', 'Button', nX1+130, nY1+10, 60, 14, Label = self.dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000)
# Radio buttons: main POS tag
# Note: the only way to group RadioButtons is to create them successively
self.xNA = self._addWidget('nom_adj', 'RadioButton', nX1, nY2+12, 60, nHeight, Label = self.dUI.get("nom_adj", "#err"), HelpText = ":N:A")
self.xN = self._addWidget('nom', 'RadioButton', nX1, nY2+22, 60, nHeight, Label = self.dUI.get("nom", "#err"), HelpText = ":N")
self.xA = self._addWidget('adj', 'RadioButton', nX1, nY2+32, 60, nHeight, Label = self.dUI.get("adj", "#err"), HelpText = ":A")
self.xM1 = self._addWidget('M1', 'RadioButton', nX1, nY3+12, 60, nHeight, Label = self.dUI.get("M1", "#err"), HelpText = ":M1")
self.xM2 = self._addWidget('M2', 'RadioButton', nX1, nY3+22, 60, nHeight, Label = self.dUI.get("M2", "#err"), HelpText = ":M2")
self.xMP = self._addWidget('MP', 'RadioButton', nX1, nY3+32, 60, nHeight, Label = self.dUI.get("MP", "#err"), HelpText = ":MP")
self.xV = self._addWidget('verb', 'RadioButton', nX1, nY4+2, 30, nHeight, Label = self.dUI.get("verb", "#err"), FontDescriptor = xFDSubTitle, HelpText = ":V")
self.xW = self._addWidget('adv', 'RadioButton', nX1, nY5+2, 30, nHeight, Label = self.dUI.get("adverb", "#err"), FontDescriptor = xFDSubTitle, HelpText = ":W")
self.xX = self._addWidget('other', 'RadioButton', nX1, nY6+2, 30, nHeight, Label = self.dUI.get("other", "#err"), FontDescriptor = xFDSubTitle, HelpText = ":X")
# Nom, adjectif
self._addWidget("fl_nom_adj", 'FixedLine', nX1, nY2, 190, nHeight, Label = self.dUI.get("common_name", "#err"), FontDescriptor = xFDSubTitle)
self.xSepi = self._addWidget('Sepi', 'RadioButton', nX1+65, nY2+12, 50, nHeight, Label = self.dUI.get("epi", "#err"), HelpText = ":e")
self.xSmas = self._addWidget('Smas', 'RadioButton', nX1+65, nY2+22, 50, nHeight, Label = self.dUI.get("mas", "#err"), HelpText = ":m")
self.xSfem = self._addWidget('Sfem', 'RadioButton', nX1+65, nY2+32, 50, nHeight, Label = self.dUI.get("fem", "#err"), HelpText = ":f")
self._addWidget("fl_sep1", 'FixedLine', nX1, nY2, 1, nHeight)
self.xSs = self._addWidget('Ss', 'RadioButton', nX1+120, nY2+12, 50, nHeight, Label = self.dUI.get("-s", "#err"), HelpText = "·s")
self.xSx = self._addWidget('Sx', 'RadioButton', nX1+120, nY2+22, 50, nHeight, Label = self.dUI.get("-x", "#err"), HelpText = "·x")
self.xSinv = self._addWidget('Sinv', 'RadioButton', nX1+120, nY2+32, 50, nHeight, Label = self.dUI.get("inv", "#err"), HelpText = ":i")
self._addWidget("alt_lemma_label", 'FixedLine', nX1+10, nY2+42, 180, nHeight, Label = self.dUI.get("alt_lemma", "#err"))
self.xAltLemma = self._addWidget('alt_lemma', 'Edit', nX1+10, nY2+52, 120, nHeight)
self.xNA2 = self._addWidget('nom_adj2', 'RadioButton', nX1+10, nY2+65, 60, nHeight, Label = self.dUI.get("nom_adj", "#err"), HelpText = ":N:A")
self.xN2 = self._addWidget('nom2', 'RadioButton', nX1+10, nY2+75, 60, nHeight, Label = self.dUI.get("nom", "#err"), HelpText = ":N")
self.xA2 = self._addWidget('adj2', 'RadioButton', nX1+10, nY2+85, 60, nHeight, Label = self.dUI.get("adj", "#err"), HelpText = ":A")
self._addWidget("fl_sep2", 'FixedLine', nX1, nY2, 1, nHeight)
self.xSepi2 = self._addWidget('Sepi2', 'RadioButton', nX1+75, nY2+65, 50, nHeight, Label = self.dUI.get("epi", "#err"), HelpText = ":e")
self.xSmas2 = self._addWidget('Smas2', 'RadioButton', nX1+75, nY2+75, 50, nHeight, Label = self.dUI.get("mas", "#err"), HelpText = ":m")
self.xSfem2 = self._addWidget('Sfem2', 'RadioButton', nX1+75, nY2+85, 50, nHeight, Label = self.dUI.get("fem", "#err"), HelpText = ":f")
self._addWidget("fl_sep3", 'FixedLine', nX1, nY2, 1, nHeight)
self.xSs2 = self._addWidget('Ss2', 'RadioButton', nX1+130, nY2+65, 50, nHeight, Label = self.dUI.get("-s", "#err"), HelpText = "·s")
self.xSx2 = self._addWidget('Sx2', 'RadioButton', nX1+130, nY2+75, 50, nHeight, Label = self.dUI.get("-x", "#err"), HelpText = "·x")
self.xSinv2 = self._addWidget('Sinv2', 'RadioButton', nX1+130, nY2+85, 50, nHeight, Label = self.dUI.get("inv", "#err"), HelpText = ":i")
# Nom propre
self._addWidget("fl_M", 'FixedLine', nX1, nY3, 190, nHeight, Label = self.dUI.get("proper_name", "#err"), FontDescriptor = xFDSubTitle)
self.xMepi = self._addWidget('Mepi', 'RadioButton', nX1+65, nY3+12, 50, nHeight, Label = self.dUI.get("epi", "#err"), HelpText = ":e")
self.xMmas = self._addWidget('Mmas', 'RadioButton', nX1+65, nY3+22, 50, nHeight, Label = self.dUI.get("mas", "#err"), HelpText = ":m")
self.xMfem = self._addWidget('Mfem', 'RadioButton', nX1+65, nY3+32, 50, nHeight, Label = self.dUI.get("fem", "#err"), HelpText = ":f")
# Verbe
self._addWidget("fl_verb", 'FixedLine', nX2+30, nY4, 150, nHeight, FontDescriptor = xFDSubTitle)
self.xV_i = self._addWidget('v_i', 'CheckBox', nX2, nY4+12, 60, nHeight, Label = self.dUI.get("v_i", "#err"))
self.xV_t = self._addWidget('v_t', 'CheckBox', nX2, nY4+20, 60, nHeight, Label = self.dUI.get("v_t", "#err"))
self.xV_n = self._addWidget('v_n', 'CheckBox', nX2, nY4+28, 60, nHeight, Label = self.dUI.get("v_n", "#err"))
self.xV_p = self._addWidget('v_p', 'CheckBox', nX2, nY4+36, 60, nHeight, Label = self.dUI.get("v_p", "#err"))
self.xV_m = self._addWidget('v_m', 'CheckBox', nX2, nY4+44, 60, nHeight, Label = self.dUI.get("v_m", "#err"))
self._addWidget('aux', 'FixedText', nX2+75, nY4+10, 90, nHeight, Label = self.dUI.get("aux", "#err"))
self.xV_ae = self._addWidget('v_ae', 'CheckBox', nX2+75, nY4+20, 90, nHeight, Label = self.dUI.get("v_ae", "#err"))
self.xV_aa = self._addWidget('v_aa', 'CheckBox', nX2+75, nY4+28, 90, nHeight, Label = self.dUI.get("v_aa", "#err"))
self.xV_pp = self._addWidget('v_pp', 'CheckBox', nX2+75, nY4+44, 90, nHeight, Label = self.dUI.get("v_pp", "#err"))
self._addWidget('v_pattern_label', 'FixedText', nX2+10, nY4+56, 70, nHeight, Label = self.dUI.get('v_pattern', "#err"), Align = 2)
self.xVpattern = self._addWidget('v_pattern', 'Edit', nX2+85, nY4+56, 80, nHeight)
# Adverbe
self._addWidget("fl_adv", 'FixedLine', nX2+30, nY5, 150, nHeight, FontDescriptor = xFDSubTitle)
# Autre
self._addWidget("fl_other", 'FixedLine', nX2+30, nY6, 150, nHeight, FontDescriptor = xFDSubTitle)
self._addWidget('flexion_label', 'FixedText', nX2, nY6+10, 85, nHeight, Label = self.dUI.get('flexion', "#err"))
self.xFlexion = self._addWidget('flexion', 'Edit', nX2, nY6+20, 85, nHeight)
self._addWidget('tags_label', 'FixedText', nX2+90, nY6+10, 85, nHeight, Label = self.dUI.get('tags', "#err"))
self.xTags = self._addWidget('tags', 'Edit', nX2+90, nY6+20, 85, nHeight)
#### Generated words
self._addWidget("gwords_section", 'FixedLine', nXB, nY1, 200, nHeight, Label = self.dUI.get("new_section", "#err"), FontDescriptor = xFDTitle)
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
])
# container
self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
self.xContainer.setModel(self.xDialog)
self.xGridControlNew = self.xContainer.getControl('list_grid_gwords')
self.xGridControlLex = self.xContainer.getControl('list_grid_lexicon')
self.xContainer.getControl('add_button').addActionListener(self)
self.xContainer.getControl('add_button').setActionCommand('Add')
self.xContainer.getControl('delete_button').addActionListener(self)
self.xContainer.getControl('delete_button').setActionCommand('Delete')
self.xContainer.getControl('save_button').addActionListener(self)
self.xContainer.getControl('save_button').setActionCommand('Save')
self.xContainer.getControl('generate_button').addActionListener(self)
self.xContainer.getControl('generate_button').setActionCommand('Update')
self.xContainer.setVisible(False)
xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
self.xContainer.createPeer(xToolkit, None)
self.xContainer.execute()
# XActionListener
def actionPerformed (self, xActionEvent):
try:
if xActionEvent.ActionCommand == "Add":
pass
elif xActionEvent.ActionCommand == "Delete":
pass
elif xActionEvent.ActionCommand == "Save":
pass
elif xActionEvent.ActionCommand == "Update":
self.updateGenWords()
elif xActionEvent.ActionCommand == "Close":
self.xContainer.endExecute()
except:
traceback.print_exc()
# XJobExecutor
def trigger (self, args):
try:
xDialog = LexiconEditor(self.ctx)
xDialog.run()
except:
traceback.print_exc()
# Code
def getRadioValue (self, *args):
for x in args:
if x.State:
return x.HelpText
return None
def updateGenWords (self):
self.lGeneratedFlex = []
sLemma = self.xLemma.Text.strip()
if sLemma:
if self.getRadioValue(self.xNA, self.xN, self.xA):
# Substantif
sPOS = self.getRadioValue(self.xNA, self.xN, self.xA)
sGenderTag = self.getRadioValue(self.xSepi, self.xSmas, self.xSfem)
if sGenderTag:
if self.xSs.State:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":s/*"))
self.lGeneratedFlex.append((sLemma+"s", sLemma, sPOS+sGenderTag+":p/*"))
elif self.xSx.State:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":s/*"))
self.lGeneratedFlex.append((sLemma+"x", sLemma, sPOS+sGenderTag+":p/*"))
elif self.xSinv.State:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":i/*"))
sLemma2 = self.xAltLemma.Text.strip()
if sLemma2 and self.getRadioValue(self.xNA2, self.xN2, self.xA2) and self.getRadioValue(self.xSepi2, self.xSmas2, self.xSfem2):
sTag2 = self.getRadioValue(self.xNA2, self.xN2, self.xA2) + self.getRadioValue(self.xSepi2, self.xSmas2, self.xSfem2)
if self.xSs2.State:
self.lGeneratedFlex.append((sLemma2, sLemma, sTag2+":s/*"))
self.lGeneratedFlex.append((sLemma2+"s", sLemma, sTag2+":p/*"))
elif self.xSx2.State:
self.lGeneratedFlex.append((sLemma2, sLemma, sTag2+":s/*"))
self.lGeneratedFlex.append((sLemma2+"x", sLemma, sTag2+":p/*"))
elif self.xSinv2.State:
self.lGeneratedFlex.append((sLemma2, sLemma, sTag2+":i/*"))
elif self.getRadioValue(self.xM1, self.xM2, self.xMP):
# Nom propre
sPOS = self.getRadioValue(self.xM1, self.xM2, self.xMP)
sLemma = sLemma[0:1].upper() + sLemma[1:];
sGenderTag = self.getRadioValue(self.xMepi, self.xMmas, self.xMfem)
if sGenderTag:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":i/*"))
elif self.xV.State:
# Verbe
if sLemma.endswith(("er", "ir", "re")):
sLemma = sLemma.lower()
c_i = "i" if self.xV_i.State else "_"
|
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
|
|
|
|
|
|
|
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
])
# container
self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
self.xContainer.setModel(self.xDialog)
self.xGridControlNew = self.xContainer.getControl('list_grid_gwords')
self.xGridControlLex = self.xContainer.getControl('list_grid_lexicon')
#helpers.xray(self.xContainer.getControl('lemma'))
self._createKeyListeners(['lemma', 'alt_lemma', "v_pattern", 'flexion', 'tags'], "Update")
self._createActionListeners(['nom_adj', 'nom', 'adj', 'M1', 'M2', 'MP', 'verb', 'adv', 'other', \
'Sepi', 'Smas', 'Sfem', 'Ss', 'Sx', 'Sinv', 'nom_adj2', 'nom2', 'adj2', \
'Sepi2', 'Smas2', 'Sfem2', 'Ss2', 'Sx2', 'Sinv2', 'Mepi', 'Mmas', 'Mfem', \
'v_i', 'v_t', 'v_n', 'v_p', 'v_m', 'v_ae', 'v_aa', 'v_pp'], "Update")
self.xContainer.getControl('add_button').addActionListener(self)
self.xContainer.getControl('add_button').setActionCommand('Add')
self.xContainer.getControl('delete_button').addActionListener(self)
self.xContainer.getControl('delete_button').setActionCommand('Delete')
self.xContainer.getControl('save_button').addActionListener(self)
self.xContainer.getControl('save_button').setActionCommand('Save')
self.xContainer.getControl('close_button').addActionListener(self)
self.xContainer.getControl('close_button').setActionCommand('Close')
self.xContainer.setVisible(False)
xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
self.xContainer.createPeer(xToolkit, None)
self.xContainer.execute()
def _createKeyListeners (self, lNames, sAction):
for sName in lNames:
self.xContainer.getControl(sName).addKeyListener(self)
def _createActionListeners (self, lNames, sAction):
for sName in lNames:
self.xContainer.getControl(sName).addActionListener(self)
self.xContainer.getControl(sName).setActionCommand(sAction)
# XActionListener
def actionPerformed (self, xActionEvent):
try:
if xActionEvent.ActionCommand == "Add":
self.addToLexicon()
elif xActionEvent.ActionCommand == "Delete":
pass
elif xActionEvent.ActionCommand == "Save":
self.saveLexicon()
elif xActionEvent.ActionCommand == "Update":
self.updateGenWords()
elif xActionEvent.ActionCommand == "Close":
self.xContainer.endExecute()
except:
traceback.print_exc()
# XKeyListener
def keyPressed (self, xKeyEvent):
pass
def keyReleased (self, xKeyEvent):
self.updateGenWords()
# XJobExecutor
def trigger (self, args):
try:
xDialog = LexiconEditor(self.ctx)
xDialog.run()
except:
traceback.print_exc()
# Code
@_waitPointer
def loadLexicon (self):
pass
@_waitPointer
def saveLexicon (self):
xGridDataModel = self.xGridModelLex.GridDataModel
lEntry = []
for i in range(xGridDataModel.RowCount):
lEntry.append(xGridDataModel.getRowData(i))
oDAWG = dawg.DAWG(lEntry, "S", "fr", "Français", "Dictionnaire personnel")
def _getRadioValue (self, *args):
for x in args:
if x.State:
return x.HelpText
return None
@_waitPointer
def updateGenWords (self):
self.lGeneratedFlex = []
sLemma = self.xLemma.Text.strip()
if sLemma:
if self._getRadioValue(self.xNA, self.xN, self.xA):
# Substantif
sPOS = self._getRadioValue(self.xNA, self.xN, self.xA)
sGenderTag = self._getRadioValue(self.xSepi, self.xSmas, self.xSfem)
if sGenderTag:
if self.xSs.State:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":s/*"))
self.lGeneratedFlex.append((sLemma+"s", sLemma, sPOS+sGenderTag+":p/*"))
elif self.xSx.State:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":s/*"))
self.lGeneratedFlex.append((sLemma+"x", sLemma, sPOS+sGenderTag+":p/*"))
elif self.xSinv.State:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":i/*"))
sLemma2 = self.xAltLemma.Text.strip()
if sLemma2 and self._getRadioValue(self.xNA2, self.xN2, self.xA2) and self._getRadioValue(self.xSepi2, self.xSmas2, self.xSfem2):
sTag2 = self._getRadioValue(self.xNA2, self.xN2, self.xA2) + self._getRadioValue(self.xSepi2, self.xSmas2, self.xSfem2)
if self.xSs2.State:
self.lGeneratedFlex.append((sLemma2, sLemma, sTag2+":s/*"))
self.lGeneratedFlex.append((sLemma2+"s", sLemma, sTag2+":p/*"))
elif self.xSx2.State:
self.lGeneratedFlex.append((sLemma2, sLemma, sTag2+":s/*"))
self.lGeneratedFlex.append((sLemma2+"x", sLemma, sTag2+":p/*"))
elif self.xSinv2.State:
self.lGeneratedFlex.append((sLemma2, sLemma, sTag2+":i/*"))
elif self._getRadioValue(self.xM1, self.xM2, self.xMP):
# Nom propre
sPOS = self._getRadioValue(self.xM1, self.xM2, self.xMP)
sLemma = sLemma[0:1].upper() + sLemma[1:];
sGenderTag = self._getRadioValue(self.xMepi, self.xMmas, self.xMfem)
if sGenderTag:
self.lGeneratedFlex.append((sLemma, sLemma, sPOS+sGenderTag+":i/*"))
elif self.xV.State:
# Verbe
if sLemma.endswith(("er", "ir", "re")):
sLemma = sLemma.lower()
c_i = "i" if self.xV_i.State else "_"
|