Grammalecte  Diff

Differences From Artifact [79fb2363d1]:

To Artifact [04a573e2a5]:


244
245
246
247
248
249
250

251
252
253
254
255
256
257
258
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Close':
                self.xContainer.endExecute()
            elif xActionEvent.ActionCommand == 'New':
                self._newVerb()
            elif xActionEvent.ActionCommand == 'Change':

                self._displayResults()
            else:
                print(str(xActionEvent))
        except:
            traceback.print_exc()

    # XJobExecutor
    def trigger (self, args):







>
|







244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
    def actionPerformed (self, xActionEvent):
        try:
            if xActionEvent.ActionCommand == 'Close':
                self.xContainer.endExecute()
            elif xActionEvent.ActionCommand == 'New':
                self._newVerb()
            elif xActionEvent.ActionCommand == 'Change':
                if self.oVerb:
                    self._displayResults(self.oVerb.createConjTable(self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State))
            else:
                print(str(xActionEvent))
        except:
            traceback.print_exc()

    # XJobExecutor
    def trigger (self, args):
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
357
358


359
360
361
362
363
364

365
366
367
368
369
370
371


372
373
374
375
376
377

378
379
380



381
382
383
384
385
386
387
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
        self.opro.State = False
        self.oint.State = False
        self.otco.State = False
        self.ofem.State = False
        # request analyzing
        sVerb = self.input.Text.strip().lower().replace(u"’", "'").replace("  ", " ")
        if sVerb:

            if sVerb.startswith("ne pas "):
                self.oneg.State = True
                sVerb = sVerb[7:]
            if sVerb.startswith("se "):
                self.opro.State = True
                sVerb = sVerb[3:]
            elif sVerb.startswith("s'"):
                self.opro.State = True
                sVerb = sVerb[2:]
            if sVerb.endswith("?"):
                self.oint.State = True
                sVerb = sVerb.rstrip(" ?")
            if not conj_fr.isVerb(sVerb):
                self.input.TextColor = 0xAA2200
            else:
                self.input.TextColor = 0x666666
                self.oVerb = conj_fr.Verb(sVerb)
                sRawInfo = conj_fr.getVtyp(sVerb)
                self.info.Label = self.oVerb.sInfo
                self.opro.Label = "pronominal"
                if sRawInfo.endswith("zz"):
                    self.opro.State = False
                    self.opro.Enabled = False
                    self.otco.State = False
                    self.otco.Enabled = False
                    self.option_msg.Label = self.sWarning
                else:
                    self.option_msg.Label = ""
                    if sRawInfo[5] == "_":
                        self.opro.State = False
                        self.opro.Enabled = False
                    elif sRawInfo[5] in ["q", "u", "v", "e"]:
                        self.opro.State = False
                        self.opro.Enabled = True
                    elif sRawInfo[5] == "p" or sRawInfo[5] == "r":
                        self.opro.State = True
                        self.opro.Enabled = False
                    elif sRawInfo[5] == "x":
                        self.opro.Label = "cas particuliers"
                        self.opro.State = False
                        self.opro.Enabled = False
                    else:
                        self.opro.Label = "# erreur #"
                        self.opro.State = False
                        self.opro.Enabled = False
                    self.otco.Enabled = True
                self._displayResults()

    def _displayResults (self):
        try:
            self._setTitles()




            # participes passés
            self.ppas1.Label = self.oVerb.participePasse(":Q1")
            self.ppas2.Label = self.oVerb.participePasse(":Q2")
            self.ppas3.Label = self.oVerb.participePasse(":Q3")
            self.ppas4.Label = self.oVerb.participePasse(":Q4")
            # infinitif
            self.infi.Label = self.oVerb.infinitif(self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)



            # participe présent
            self.ppre.Label = self.oVerb.participePresent(self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            # conjugaisons
            self.ipre1.Label = self.oVerb.conjugue(":Ip", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipre2.Label = self.oVerb.conjugue(":Ip", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipre3.Label = self.oVerb.conjugue(":Ip", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipre4.Label = self.oVerb.conjugue(":Ip", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipre5.Label = self.oVerb.conjugue(":Ip", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipre6.Label = self.oVerb.conjugue(":Ip", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)


            self.iimp1.Label = self.oVerb.conjugue(":Iq", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.iimp2.Label = self.oVerb.conjugue(":Iq", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.iimp3.Label = self.oVerb.conjugue(":Iq", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.iimp4.Label = self.oVerb.conjugue(":Iq", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.iimp5.Label = self.oVerb.conjugue(":Iq", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.iimp6.Label = self.oVerb.conjugue(":Iq", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipsi1.Label = self.oVerb.conjugue(":Is", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipsi2.Label = self.oVerb.conjugue(":Is", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipsi3.Label = self.oVerb.conjugue(":Is", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipsi4.Label = self.oVerb.conjugue(":Is", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipsi5.Label = self.oVerb.conjugue(":Is", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ipsi6.Label = self.oVerb.conjugue(":Is", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ifut1.Label = self.oVerb.conjugue(":If", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ifut2.Label = self.oVerb.conjugue(":If", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ifut3.Label = self.oVerb.conjugue(":If", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ifut4.Label = self.oVerb.conjugue(":If", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ifut5.Label = self.oVerb.conjugue(":If", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.ifut6.Label = self.oVerb.conjugue(":If", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)


            self.conda1.Label = self.oVerb.conjugue(":K", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.conda2.Label = self.oVerb.conjugue(":K", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.conda3.Label = self.oVerb.conjugue(":K", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.conda4.Label = self.oVerb.conjugue(":K", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.conda5.Label = self.oVerb.conjugue(":K", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            self.conda6.Label = self.oVerb.conjugue(":K", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)

            if not self.oint.State:
                self.spre1.Label = self.oVerb.conjugue(":Sp", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.spre2.Label = self.oVerb.conjugue(":Sp", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.spre3.Label = self.oVerb.conjugue(":Sp", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.spre4.Label = self.oVerb.conjugue(":Sp", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.spre5.Label = self.oVerb.conjugue(":Sp", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.spre6.Label = self.oVerb.conjugue(":Sp", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)


                self.simp1.Label = self.oVerb.conjugue(":Sq", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.simp2.Label = self.oVerb.conjugue(":Sq", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.simp3.Label = self.oVerb.conjugue(":Sq", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.simp4.Label = self.oVerb.conjugue(":Sq", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.simp5.Label = self.oVerb.conjugue(":Sq", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.simp6.Label = self.oVerb.conjugue(":Sq", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)

                self.impe1.Label = self.oVerb.imperatif(":2s", self.opro.State, self.oneg.State, self.otco.State, self.ofem.State)
                self.impe2.Label = self.oVerb.imperatif(":1p", self.opro.State, self.oneg.State, self.otco.State, self.ofem.State)
                self.impe3.Label = self.oVerb.imperatif(":2p", self.opro.State, self.oneg.State, self.otco.State, self.ofem.State)



            else:
                self.spre.Label = ""
                self.spre1.Label = ""
                self.spre2.Label = ""
                self.spre3.Label = ""
                self.spre4.Label = ""
                self.spre5.Label = ""
                self.spre6.Label = ""

                self.simp.Label = ""
                self.simp1.Label = ""
                self.simp2.Label = ""
                self.simp3.Label = ""
                self.simp4.Label = ""
                self.simp5.Label = ""
                self.simp6.Label = ""
                self.impe.Label = ""
                self.impe1.Label = ""
                self.impe2.Label = ""
                self.impe3.Label = ""
            if self.otco.State:
                self.condb1.Label = self.oVerb.conjugue(":Sq", ":1s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.condb2.Label = self.oVerb.conjugue(":Sq", ":2s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.condb3.Label = self.oVerb.conjugue(":Sq", ":3s", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.condb4.Label = self.oVerb.conjugue(":Sq", ":1p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.condb5.Label = self.oVerb.conjugue(":Sq", ":2p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
                self.condb6.Label = self.oVerb.conjugue(":Sq", ":3p", self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State)
            else:
                self.condb1.Label = ""
                self.condb2.Label = ""
                self.condb3.Label = ""
                self.condb4.Label = ""
                self.condb5.Label = ""
                self.condb6.Label = ""
            self.input.Text = ""
            # refresh
            self.xContainer.setVisible(True)
        except:
            traceback.print_exc()

    def _setTitles (self):
        if not self.otco.State:
            self.ipre.Label = "Présent"
            self.ifut.Label = "Futur"
            self.iimp.Label = "Imparfait"
            self.ipsi.Label = "Passé simple"
            self.spre.Label = "Présent"
            self.simp.Label = "Imparfait"
            self.conda.Label = "Présent"
            self.condb.Label = ""
            self.impe.Label = "Présent"
        else:
            self.ipre.Label = "Passé composé"
            self.ifut.Label = "Futur antérieur"
            self.iimp.Label = "Plus-que-parfait"
            self.ipsi.Label = "Passé antérieur"
            self.spre.Label = "Passé"
            self.simp.Label = "Plus-que-parfait"
            self.conda.Label = "Passé (1ʳᵉ forme)"
            self.condb.Label = "Passé (2ᵉ forme)"
            self.impe.Label = "Passé"


# g_ImplementationHelper = unohelper.ImplementationHelper()
# g_ImplementationHelper.addImplementation(Conjugueur, 'dicollecte.Conjugueur', ('com.sun.star.task.Job',))







>

















<

|
|






<
<
<
|
|


|


<
<
<
<
|
<


|
|

|

|
>
>
>
>

|
|
|
|
|
|
>
>
>
|
|
<
|
|
|
|
|
|
>
>
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
|
>
>
|
|
|
|
|
|
>
|
|
|
|
|
|
|
>
>
|
|
|
|
|
|
>
|
|
|
>
>
>
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<



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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394



















395
396
397
398























399
400
401
        self.opro.State = False
        self.oint.State = False
        self.otco.State = False
        self.ofem.State = False
        # request analyzing
        sVerb = self.input.Text.strip().lower().replace(u"’", "'").replace("  ", " ")
        if sVerb:
            self.oVerb = None
            if sVerb.startswith("ne pas "):
                self.oneg.State = True
                sVerb = sVerb[7:]
            if sVerb.startswith("se "):
                self.opro.State = True
                sVerb = sVerb[3:]
            elif sVerb.startswith("s'"):
                self.opro.State = True
                sVerb = sVerb[2:]
            if sVerb.endswith("?"):
                self.oint.State = True
                sVerb = sVerb.rstrip(" ?")
            if not conj_fr.isVerb(sVerb):
                self.input.TextColor = 0xAA2200
            else:
                self.input.TextColor = 0x666666
                self.oVerb = conj_fr.Verb(sVerb)

                self.info.Label = self.oVerb.sInfo
                self.opro.Label = self.oVerb.sProLabel
                if self.oVerb.bUncomplete:
                    self.opro.State = False
                    self.opro.Enabled = False
                    self.otco.State = False
                    self.otco.Enabled = False
                    self.option_msg.Label = self.sWarning
                else:



                    self.otco.Enabled = True
                    if self.oVerb.nPronominable == 0:
                        self.opro.State = False
                        self.opro.Enabled = True
                    elif self.oVerb.nPronominable == 1:
                        self.opro.State = True
                        self.opro.Enabled = False




                    else: # -1 or 1 or error

                        self.opro.State = False
                        self.opro.Enabled = False
                    self.option_msg.Label = ""
                self._displayResults(self.oVerb.createConjTable(self.opro.State, self.oneg.State, self.otco.State, self.oint.State, self.ofem.State))

    def _displayResults (self, dConjTable):
        try:
            self.input.Text = ""
            # infinitif
            self.infi.Label = dConjTable["infi"]
            # participe présent
            self.ppre.Label = dConjTable["ppre"]
            # participes passés
            self.ppas1.Label = dConjTable["ppas1"]
            self.ppas2.Label = dConjTable["ppas2"]
            self.ppas3.Label = dConjTable["ppas3"]
            self.ppas4.Label = dConjTable["ppas4"]
            # impératif
            self.impe.Label = dConjTable["t_impe"]
            self.impe1.Label = dConjTable["impe1"]
            self.impe2.Label = dConjTable["impe2"]
            self.impe3.Label = dConjTable["impe3"]
            # présent
            self.ipre.Label = dConjTable["t_ipre"]

            self.ipre1.Label = dConjTable["ipre1"]
            self.ipre2.Label = dConjTable["ipre2"]
            self.ipre3.Label = dConjTable["ipre3"]
            self.ipre4.Label = dConjTable["ipre4"]
            self.ipre5.Label = dConjTable["ipre5"]
            self.ipre6.Label = dConjTable["ipre6"]
            # imparfait
            self.iimp.Label = dConjTable["t_iimp"]
            self.iimp1.Label = dConjTable["iimp1"]
            self.iimp2.Label = dConjTable["iimp2"]
            self.iimp3.Label = dConjTable["iimp3"]
            self.iimp4.Label = dConjTable["iimp4"]
            self.iimp5.Label = dConjTable["iimp5"]












            self.iimp6.Label = dConjTable["iimp6"]
            # passé simple
            self.ipsi.Label = dConjTable["t_ipsi"]
            self.ipsi1.Label = dConjTable["ipsi1"]
            self.ipsi2.Label = dConjTable["ipsi2"]
            self.ipsi3.Label = dConjTable["ipsi3"]
            self.ipsi4.Label = dConjTable["ipsi4"]
            self.ipsi5.Label = dConjTable["ipsi5"]
            self.ipsi6.Label = dConjTable["ipsi6"]
            # futur
            self.ifut.Label = dConjTable["t_ifut"]
            self.ifut1.Label = dConjTable["ifut1"]
            self.ifut2.Label = dConjTable["ifut2"]
            self.ifut3.Label = dConjTable["ifut3"]
            self.ifut4.Label = dConjTable["ifut4"]
            self.ifut5.Label = dConjTable["ifut5"]
            self.ifut6.Label = dConjTable["ifut6"]
            # Conditionnel
            self.conda.Label = dConjTable["t_conda"]
            self.conda1.Label = dConjTable["conda1"]
            self.conda2.Label = dConjTable["conda2"]
            self.conda3.Label = dConjTable["conda3"]
            self.conda4.Label = dConjTable["conda4"]
            self.conda5.Label = dConjTable["conda5"]
            self.conda6.Label = dConjTable["conda6"]
            self.condb.Label = dConjTable["t_condb"]
            self.condb1.Label = dConjTable["condb1"]
            self.condb2.Label = dConjTable["condb2"]
            self.condb3.Label = dConjTable["condb3"]
            self.condb4.Label = dConjTable["condb4"]
            self.condb5.Label = dConjTable["condb5"]
            self.condb6.Label = dConjTable["condb6"]
            # subjonctif présent
            self.spre.Label = dConjTable["t_spre"]
            self.spre1.Label = dConjTable["spre1"]
            self.spre2.Label = dConjTable["spre2"]
            self.spre3.Label = dConjTable["spre3"]
            self.spre4.Label = dConjTable["spre4"]
            self.spre5.Label = dConjTable["spre5"]
            self.spre6.Label = dConjTable["spre6"]
            # subjonctif imparfait
            self.simp.Label = dConjTable["t_simp"]
            self.simp1.Label = dConjTable["simp1"]
            self.simp2.Label = dConjTable["simp2"]
            self.simp3.Label = dConjTable["simp3"]
            self.simp4.Label = dConjTable["simp4"]
            self.simp5.Label = dConjTable["simp5"]
            self.simp6.Label = dConjTable["simp6"]



















            # refresh
            self.xContainer.setVisible(True)
        except:
            traceback.print_exc()
























# g_ImplementationHelper = unohelper.ImplementationHelper()
# g_ImplementationHelper.addImplementation(Conjugueur, 'dicollecte.Conjugueur', ('com.sun.star.task.Job',))