-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathcs_es.cpp
More file actions
2877 lines (2702 loc) · 109 KB
/
cs_es.cpp
File metadata and controls
2877 lines (2702 loc) · 109 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
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
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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "common.h"
#include <unordered_map>
#include <string>
//
// All pos data comes from original spanish dictionary. If not there, we dont know about it
//
// NOTE: the ComputeSpanish1... code tests using correctly accented forms of Spanish words.
// It is assumed that if the user accents a character, it is correct. If this becomes a problem, we will use
// spellcheck to permute that as well as incorrectly unaccented characters.
// computespanish uses all of the original dictionary (not seeing UNIVERSAL merged words) and it not
// allowed to change properties or systemflags of words, except at at the computespanish outer layer.
// For this (and other treetagger-based dictionaries), the only reliable data is that lemmas are there, marked
// by their part of speech. While it contains common conjugations, we cannot assume all are there. Nor
// is there data on additional attributes like gender and plurality (in fact often it marks a singular noun as both
// singular and plural). So the task of ComputeSpanish1 is two-fold. First, to determine for spellcheck
// if a word in user input that is NOT recognized, can be determined to be a conjugation of a known lemma.
// Second, for GetPosData, to return the set of all possible parts of speech and ancillary data like lemma, gender,
// plurality, and embedded object referencing for PosTagging.
// Currently this is not in the dictionary as static data because we would have to compute it using this function anyway
// to write the revised dictionary. And if this code is wrong and we already used it to rewrite the dictionary flags
// of the source, then recovering from faulty markings may be difficult.
// primary entry point for conjugation processing
uint64 ComputeSpanish(int at, const char* original, WORDP& entry, WORDP& canonical, uint64& sysflags);
uint64 ComputeSpanish1(int at, const char* original, WORDP& entry, WORDP& canonical, uint64& sysflags);
typedef struct IrregularSpanishInfo
{
const char* lemma;
const char* original; // conjugated form
const char* stem; // suffixes go against this
const uint64 properties;
const uint64 sysFlags;
string unaccented;
} IrregularSpanishInfo;
static IrregularSpanishInfo irregularSpanishVerbs[] =
{// any stem that is a blank means we dont know, and it may not matter
// we deliver SIMPLE PAST (PRETERITE) and IMPERFECT past
// we deliver spanish FUTURE and conditional tenses as FUTURE
// preterite past
{"ser","fue","fu",VERB | VERB_PAST,0, ""}, // él fue, ellos fueron
{"ser","fueron","fu", VERB | VERB_PAST,0, ""},
{"estar","estuve","estuv", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_I, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estuviste","estuv", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_YOU, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estuviseis","estuv", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"tener","tuve","ten", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_I, ""}, // - yo tuve, él tuvo
{"tener","tuviste","ten", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_YOU, ""}, // - yo tuve, él tuvo
{"tener","tuvo","ten", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT, ""}, // - yo tuve, él tuvo
{"tener","tuvimos","ten", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_I, ""}, // - yo tuve, él tuvo
{"tener","tuvisteis","ten", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""}, // - yo tuve, él tuvo
{"tener","tuvieron","ten", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_HE_SHE_IT, ""}, // - yo tuve, él tuvo
{"poder","pude","pud", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_I, ""},
{"poder","pudiste","pud", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"poder","pudo","pud", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT, ""},
{"poder","pudimos","pud", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_I, ""},
{"poder","pudisteis","pud", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"poder","pudieron","pud", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU | PRONOUN_HE_SHE_IT, ""},
{"hacer","hice","hic", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_I, ""}, // most subjects yo hice,
{"hacer","hiciste","hic", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_YOU, ""}, // most subjects yo hice,
{"hacer","hicimos","hic", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_I, ""}, // most subjects yo hice,
{"hacer","hicisteis","hic", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""}, // most subjects yo hice,
{"hacer","hicieron","hic", VERB | VERB_PAST,PRONOUN_PLURAL, ""}, // most subjects yo hice,
{"poner","puse","pus", VERB | VERB_PAST,0, ""}, // yo puse, él puso
{"poner","puso","pus", VERB | VERB_PAST,0, ""}, // yo puse, él puso
{"decir","dije","dij", VERB | VERB_PAST,0, ""}, // yo dije, él dijo
{"decir","dijiste","dij", VERB | VERB_PAST,0, ""},
{"decir","dijo"," dij", VERB | VERB_PAST,0, ""},
{"decir","dijimos"," dij", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_I, ""},
{"decir","dijisties"," dij", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"decir","dijeron"," dij", VERB | VERB_PAST,PRONOUN_PLURAL, ""},
{"ver","vi","vi", VERB | VERB_PAST,0, ""},
{"ver","vio","vi", VERB | VERB_PAST,0, ""},
{"querer","quise","quis", VERB | VERB_PAST,0, ""}, // yo quise, él quiso
{"querer","quiso","quis", VERB | VERB_PAST,0, ""},
// in present tense, various irregular verbs vary in their 1stperson singular form and conjugate normally otherwise
{"caber","quepo","cab", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"caer","caigo","ca", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"coger","cojo","cog", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"comer","come","com", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | PRONOUN_HE_SHE_IT | VERB_IMPERATIVE, ""},
{"conocer","conozco","conoc", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"contar","cuento","cont", VERB | VERB_PRESENT, PRONOUN_I | PRONOUN_SINGULAR, ""},
{"dar","doy"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"decir","digo","dec", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"decir","dices","dec", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"decir","dice","dec", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"decir","dicen","dec", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_PLURAL, ""},
{"estar","estoy","estuv", VERB | VERB_PRESENT,PRONOUN_SINGULAR | PRONOUN_I, ""},
{"estar",u8"está","estuv", VERB | VERB_PRESENT,PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT, ""},
{"estar",u8"están","estuv", VERB | VERB_PRESENT,PRONOUN_PLURAL | PRONOUN_HE_SHE_IT, ""},
{"hacer","hago"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"mostrar","muestro","muestr", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"poner","pongo"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"salir","salgo"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"sentir","siento","sent", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"sentir","sientes","sent", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"sentir","siente","sent", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT | PRONOUN_YOU | VERB_IMPERATIVE | PRONOUN_INDIRECTOBJECT_SINGULAR | PRONOUN_INDIRECTOBJECT_YOU, ""},
{"sentir","sienta","sent", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{"sentir","sientas","sent", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{"sentir","sintamos","sent", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I | VERB_IMPERATIVE, ""},
{"sentir","sienten","sent", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_HE_SHE_IT, ""},
{"sentir","sientan","sent", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"tener","tengo","ten", VERB | VERB_PRESENT,PRONOUN_SINGULAR | PRONOUN_I, ""},
{"tener","tienes","ten", VERB | VERB_PRESENT,PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"tener","tiene","ten", VERB | VERB_PRESENT,PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT, ""},
{"tener","tienen","ten", VERB | VERB_PRESENT,PRONOUN_PLURAL | PRONOUN_HE_SHE_IT, ""},
{"tomar","tome","tom", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | PRONOUN_HE_SHE_IT | VERB_IMPERATIVE, ""},
{"traducir","traduzco"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"traer","traigo"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"valer","valgo"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"ver","veo"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
// imperfect past
{"estar","estaba","estuv", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_I, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estabas","estuv", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_YOU, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estuvimos","estuv", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_I, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estuvistereis","estuv", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estuvieron","estuv", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_HE_SHE_IT, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"estar","estuvo","estuv", VERB | VERB_PAST, PRONOUN_SINGULAR | PRONOUN_HE_SHE_IT, ""}, //yo estuve, tu estuviste, él estuvo, nosotros estuvimos, vosotros estuvisteis, ellos estuvieron
{"ir","iba","ir", VERB | VERB_PAST, PRONOUN_I | PRONOUN_SINGULAR, ""},
{"ir","ibas","ir", VERB | VERB_PAST, PRONOUN_YOU | PRONOUN_SINGULAR, ""}, // ir (to go)
{"ir","ibamos","ir", VERB | VERB_PAST, PRONOUN_PLURAL | PRONOUN_I, ""},
{"ir","ibais","ir", VERB | VERB_PAST, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"ir","iban","ir", VERB | VERB_PAST, PRONOUN_PLURAL, ""},
{"ser","era","s", VERB | VERB_PAST, PRONOUN_I | PRONOUN_SINGULAR, ""},
{"ser","eras","s", VERB | VERB_PAST, PRONOUN_YOU | PRONOUN_SINGULAR, ""}, // ser (to be)
{"ser","eramos","s", VERB | VERB_PAST, PRONOUN_PLURAL | PRONOUN_I, ""},
{"ser","erais","s", VERB | VERB_PAST, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"ser","eran","s", VERB | VERB_PAST, PRONOUN_PLURAL, ""},
{"ver",u8"veía","v", VERB | VERB_PAST, PRONOUN_I | PRONOUN_SINGULAR, ""},
{"ver",u8"veías","v", VERB | VERB_PAST, PRONOUN_YOU | PRONOUN_SINGULAR, ""}, // ver (to see)
{"ver",u8"veíamos","v", VERB | VERB_PAST, PRONOUN_PLURAL | PRONOUN_I, ""},
{"ver",u8"veían","v", VERB | VERB_PAST, PRONOUN_PLURAL, ""},
// and some are irregular in all forms present
{"estar","estamos","est", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I, ""},
{"estar",u8"estáis","est", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"estar",u8"estás","est", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"haber","ha"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR , ""},
{"haber","han"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL, ""},
{"haber","has"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"haber","hay"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR , ""},
{"haber","he"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"haber","hemos"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I, ""},
{"haber",u8"habéis"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"hacer",u8"hacía","hic", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_I, ""}, // most subjects yo hice,
{"hacer",u8"hacíaimos","hic", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_I, ""}, // most subjects yo hice,
{"hacer",u8"hacíain","hic", VERB | VERB_PAST,PRONOUN_PLURAL, ""}, // most subjects yo hice,
{"hacer",u8"hacíais","hic", VERB | VERB_PAST,PRONOUN_PLURAL | PRONOUN_YOU, ""}, // most subjects yo hice,
{"hacer",u8"hacías","hic", VERB | VERB_PAST,PRONOUN_SINGULAR | PRONOUN_YOU, ""}, // most subjects yo hice,
{"ir","va"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR, ""},
{"ir","vais"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"ir","vamos"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I, ""},
{"ir","van"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL , ""},
{"ir","vas"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"ir","voy"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"ser","eres"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"ser","es"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR, ""},
{"ser","sois"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"ser","somos"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I, ""},
{"ser","son"," ", VERB | VERB_PRESENT, PRONOUN_PLURAL, ""},
{"ser","soy"," ", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_I, ""},
// irregular simple future
{"decir",u8"diré","dec", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"decir",u8"dirás","dec", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"decir",u8"dirá","dec", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR, ""},
{"decir",u8"diremos","dec", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_I, ""},
{"decir",u8"diréis","dec", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"decir",u8"dirán","dec", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL, ""},
{"estar",u8"estaré","est", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"estar",u8"estarás","est", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"estar",u8"estará","est", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR, ""},
{"estar","estaremos","est", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_I, ""},
{"estar",u8"estaréis","est", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"estar",u8"estarán","est", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL, ""},
{"hacer",u8"haré","hac", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"hacer",u8"harás","hac", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"hacer",u8"hará","hac", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR, ""},
{"hacer","haremos","hac", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_I, ""},
{"hacer",u8"haréis","hac", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"hacer",u8"harán","eshact", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL, ""},
// irregular conditional future
{"decir",u8"diría","dec", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"decir",u8"dirías","dec", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"decir",u8"diríamos","dec", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_I, ""},
{"decir",u8"diríais","dec", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"decir",u8"dirían","dec", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL, ""},
{"estar",u8"estaría","est", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_I, ""},
{"estar",u8"estarías","est", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{"estar",u8"estaríamos","est", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_I, ""},
{"estar",u8"estaríais","est", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{"estar",u8"estarían","est", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL, ""},
{ "hacer",u8"haría","hac", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_I, ""},
{ "hacer",u8"harías","hac", VERB | AUX_VERB_FUTURE, PRONOUN_SINGULAR | PRONOUN_YOU, ""},
{ "hacer",u8"hacíamos","hac", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_I, ""},
{ "hacer",u8"haríais","hac", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL | PRONOUN_YOU, ""},
{ "hacer",u8"harían","eshact", VERB | AUX_VERB_FUTURE, PRONOUN_PLURAL, ""},
// irregular past participle
{ "abrir",u8"abierto","abr", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "escribir","escrito","escrib", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "cubrir",u8"cubierto","abr", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "decir",u8"dicho","dec", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "hacer",u8"hecho","hac", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "leer",u8"leído","leí", VERB | VERB_PAST_PARTICIPLE, 0, ""},
{ "morir",u8"muerto","mor", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "poner",u8"puesto","pon", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "romper",u8"roto","romp", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "satisfacer",u8"satisfecho","satisfac", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
{ "ver",u8"visto","v", VERB | VERB_PAST_PARTICIPLE | ADJECTIVE, 0, ""},
// irregular present participle (verb present paticiple)
{ "leer","leyendo","ley", VERB | VERB_PRESENT_PARTICIPLE, 0, ""},
// Irregular imperatives
{ "coger","coja","cog", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "coger","cojamos","cog", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I | VERB_IMPERATIVE, ""},
{ "coger","cojan","cog", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "coger",u8"cojáis","cog", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "contar","cuente","cont", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "contar","cuenten","cont", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "contar","cuentes","cont", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "contar",u8"cuénta","cont", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "dar","da","d", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "dar","deis","d", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "dar","des","d", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "dar",u8"dáselo","d", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE | PRONOUN_INDIRECTOBJECT | PRONOUN_INDIRECTOBJECT_SINGULAR, ""},
{ "dar",u8"dé","d", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "decir","di","dec", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "girar","gire","gir", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "girar","gires","gir", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "hacer","haz","hac", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir","andante","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir","vaya","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir","vayamos","ir", VERB | VERB_PRESENT, PRONOUN_SINGULAR | PRONOUN_PLURAL | PRONOUN_I | VERB_IMPERATIVE, ""},
{ "ir","vayan","ir", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir","vayas","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir","ve","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir","vete","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir",u8"váyase","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir",u8"andá","ir", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ir",u8"vayáis","ir", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I | VERB_IMPERATIVE, ""},
{ "ir",u8"vámonos","ir", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I | VERB_IMPERATIVE, ""},
{ "laxar",u8"lávenselas","lax", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE | PRONOUN_OBJECT_PLURAL | PRONOUN_OBJECT_SINGULAR, ""},
{ "poner","pon","pon", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "repetir","repite","repit", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "separar","separa","separ", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_I | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "saltar","salte","sal", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_I | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "ser",u8"sé","ser", VERB | VERB_PRESENT | SINGULAR_PERSON,PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "tener","tenga","ten", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "tener","tengamos","ten", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_I | VERB_IMPERATIVE, ""},
{ "tener","tengan","ten", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "tener","tengas","ten", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "tener",u8"tengáis","ten", VERB | VERB_PRESENT, PRONOUN_PLURAL | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "tenir","ten","ten", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
{ "venir","ven","ven", VERB | VERB_PRESENT | SINGULAR_PERSON, PRONOUN_SINGULAR | PRONOUN_YOU | VERB_IMPERATIVE, ""},
// sentinal
{ "", NULL, NULL, 0, 0, ""},
};
void MarkSpanishTags(WORDP OL, int i)
{ // we have to manual name concept because primary naming is from the english corresponding bit
uint64 systemFlags = GetSystemFlags(OL);
if (finalPosValues[i] & PRONOUN_OBJECT) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_object")), i, i, CANONICAL);
if (systemFlags & PRONOUN_SINGULAR) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_singular")), i, i, CANONICAL);
if (systemFlags & PRONOUN_PLURAL) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_plural")), i, i, CANONICAL);
if (systemFlags & PRONOUN_I) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_i")), i, i, CANONICAL);
if (systemFlags & PRONOUN_YOU) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_you")), i, i, CANONICAL);
if (systemFlags & PRONOUN_HE_SHE_IT) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_he_she_it")), i, i, CANONICAL);
if (systemFlags & PRONOUN_OBJECT_SINGULAR) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_object_singular")), i, i, CANONICAL);
if (systemFlags & PRONOUN_OBJECT_PLURAL) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_object_plural")), i, i, CANONICAL);
if (systemFlags & PRONOUN_OBJECT_I) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_object_i")), i, i, CANONICAL);
if (systemFlags & PRONOUN_OBJECT_YOU) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_object_you")), i, i, CANONICAL);
if (systemFlags & PRONOUN_OBJECT_HE_SHE_IT) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_object_he_she_it")), i, i, CANONICAL);
if (systemFlags & PRONOUN_INDIRECTOBJECT) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_indirectobject")), i, i, CANONICAL);
if (systemFlags & PRONOUN_INDIRECTOBJECT_SINGULAR) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_indirectobject_singular")), i, i, CANONICAL);
if (systemFlags & PRONOUN_INDIRECTOBJECT_PLURAL) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_indirectobject_plural")), i, i, CANONICAL);
if (systemFlags & PRONOUN_INDIRECTOBJECT_I) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_indirectobject_i")), i, i, CANONICAL);
if (systemFlags & PRONOUN_INDIRECTOBJECT_YOU) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_indirectobject_you")), i, i, CANONICAL);
if (systemFlags & PRONOUN_INDIRECTOBJECT_HE_SHE_IT) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~pronoun_indirectobject_he_she_it")), i, i, CANONICAL);
if (finalPosValues[i] & AUX_VERB_FUTURE)
{
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~AUX_VERB_FUTURE")), i, i, CANONICAL);
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~SPANISH_FUTURE")), i, i, CANONICAL);
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~verb_future")), i, i, CANONICAL);
}
if (allOriginalWordBits[i] & NOUN_HE)
{
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~NOUN_HE")), i, i, CANONICAL);
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~SPANISH_HE")), i, i, CANONICAL);
}
if (allOriginalWordBits[i] & NOUN_SHE)
{
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~NOUN_SHE")), i, i, CANONICAL);
MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~SPANISH_SHE")), i, i, CANONICAL);
}
if (allOriginalWordBits[i] & SINGULAR_PERSON) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~SINGULAR_PERSON")), i, i, CANONICAL);
if (systemFlags & VERB_IMPERATIVE) MarkMeaningAndImplications(0, 0, MakeMeaning(StoreWord("~verb_imperative")), i, i, CANONICAL);
}
uint64 GetSpanishLemmaBits(char* wordx)
{
WORDP D = FindWord(wordx, 0, PRIMARY_CASE_ALLOWED,true);
if (!D) return 0;
WORDP E = RawCanonical(D);
if (!E || *E->word != '`') return 0; // normal english canonical or simple canonical of foreign (not multiple choice)
uint64 properties = D->properties;
char word[MAX_WORD_SIZE];
char type[MAX_WORD_SIZE];
strcpy(word, E->word + 1);
char* lemma = word;
char* tags = strrchr(word, '`');
*tags++ = 0; // type decriptors
// walk list of pos tags and simultaneously walk the list of lemmas
while (*tags && (tags = ReadCompiledWord(tags, type)))
{
char ptag[MAX_WORD_SIZE];
sprintf(ptag, "_%s", type);
WORDP X = FindWord(ptag,0,PRIMARY_CASE_ALLOWED,true);
if (X) properties |= X->properties;
tags = SkipWhitespace(tags);
}
return properties;
}
uint64 FindSpanishSingular(char* original, char* word, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
WORDP E = FindWord(word,0,PRIMARY_CASE_ALLOWED,true);
if (E && E->properties & NOUN)
{
canonical = E;
if (!exportdictionary)
{
entry = GetLanguageWord(original);
}
else entry = canonical;
sysflags = E->systemFlags;
return NOUN | NOUN_PLURAL;
}
return 0;
}
uint64 KnownSpanishUnaccented(char* original, WORDP& entry, uint64& sysflags)
{
char word[MAX_WORD_SIZE];
MakeLowerCopy(word, original);
char copy[MAX_WORD_SIZE];
char* at = word - 1;
char c;
//with the marks over the five vowels(á, é, í, ó, ú), you will never see two of those in the same word.
while ((c = *++at)) // try single accented change
{
char* change = NULL;
if (c == 'a') change = "\xC3\xA1";
else if (c == 'e') change = "\xC3\xA9";
else if (c == 'i') change = "\xC3\xAD";
else if (c == 'o') change = "\xC3\xB3";
else if (c == 'u') change = "\xC3\xBA";
if (change)
{
strcpy(copy, word);
strcpy(copy + (at - word), change);
strcpy(copy + (at - word) + 2, at + 1);
WORDP canonical = NULL;
uint64 newSysflags = 0;
uint64 properties = ComputeSpanish1(2, copy, entry, canonical, newSysflags);
if (properties)
{
sysflags |= newSysflags;
return properties;
}
}
}
return 0;
}
static WORDP ConfirmSpanishInfinitive(char* stem, char* verbType, int stemLen, char* original, const char* suffix, char* rawlemma = NULL);
static WORDP ConfirmSpanishInfinitive(char* stem, char* verbType, int stemLen, char* original, const char* suffix, char* rawlemma)
{
char word[MAX_WORD_SIZE];
strcpy(word, stem);
char rawword[MAX_WORD_SIZE];
if (rawlemma) strcpy(rawword, rawlemma);
else strcpy(rawword, stem);
WORDP Lemma;
if (*verbType) // we know the kind of verb
{
strcpy(word + stemLen, verbType); // make lemma from stem and type
Lemma = FindWord(word,0,PRIMARY_CASE_ALLOWED,true);
if (Lemma && Lemma->properties & VERB) // this is a lemma
{
strcpy(rawword + stemLen, suffix); // the actual word we would generate
if (!stricmp(rawword, original))
return Lemma; // we would get this
}
}
else // try all 3 verb types
{
strcpy(word + stemLen, "er"); // papxxx becomes paper
Lemma = FindWord(word,0, PRIMARY_CASE_ALLOWED,true);
if (Lemma && Lemma->properties & VERB)
{
strcpy(rawword + stemLen, suffix); // the actual
if (!stricmp(rawword, original))
return Lemma; // we would get this
}
strcpy(word + stemLen, "ar");
Lemma = FindWord(word, 0, PRIMARY_CASE_ALLOWED, true);
if (Lemma && Lemma->properties & VERB)
{
strcpy(rawword + stemLen, suffix); // the actual
if (!stricmp(rawword, original))
return Lemma; // we would get this
}
strcpy(word + stemLen, "ir");
Lemma = FindWord(word, 0, PRIMARY_CASE_ALLOWED, true);
if (Lemma && Lemma->properties & VERB)
{
strcpy(rawword + stemLen, suffix); // the actual
if (!stricmp(rawword, original))
return Lemma; // we would get this
}
}
return NULL;
}
static uint64 FindSpanishInfinitive(char* original, const char* suffix, char* verbType, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
// Infinitives always end in ar, er or ir added to the stem - verbType names this suffix.
// If empty, means try all 3 types
// Conjugation involves changing to different suffix on stem verb
// So, given original and a suffix to consider, we know the stem part before that suffix.
// Of course the stem may have changed spelling along the way, for added complexity.
uint64 properties = 0;
size_t originalLen = strlen(original);
size_t suffixLen = strlen(suffix);
size_t stemLen = originalLen - suffixLen;
if (strcmp(original + stemLen, suffix)) return 0; // this conjugation doesnt end with suffix named
WORDP D = GetLanguageWord(original);
// original ended in designated suffix. See if we can get its infinitive form with no changes of spelling
char stem[MAX_WORD_SIZE];
strncpy(stem, original, stemLen);
char lemma[MAX_WORD_SIZE];
stem[stemLen] = 0;
strcpy(lemma, stem);
WORDP oldcanonical = canonical;
canonical = ConfirmSpanishInfinitive(stem, verbType, stemLen, original, suffix);
if (canonical && canonical->properties & (VERB_INFINITIVE | NOUN_GERUND)) // simple verb conjugation matched. we have canonical also.
{
entry = D;
return VERB_INFINITIVE;
}
// didnt have direct match, but sometimes stem changes spelling
// if from pronoun, may have to remove added accent
char lemma1[MAX_WORD_SIZE];
strcpy(lemma1, stem);
char c = 'a';
char* found = strstr(lemma1, "\xC3\xA1");
if (!found) { found = strstr(lemma1, "\xC3\xA9"); c = 'e'; }
if (!found) { found = strstr(lemma1, "\xC3\xAD"); c = 'i'; }
if (!found) { found = strstr(lemma1, "\xC3\xB3"); c = 'o'; }
if (!found) { found = strstr(lemma1, "\xC3\xBA"); c = 'u'; }
if (!canonical && found) // replace accented form with unaccented
{
*found = c;
memmove(found + 1, found + 2, strlen(found + 1)); // know its 2 chars wide
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix);
if (canonical) // simple verb conjugation matched. we have canonical also.
{
entry = D;
return properties;
}
}
strcpy(lemma1, stem);
strcat(lemma1, suffix);
if (properties & AUX_VERB_FUTURE)
{
canonical = FindWord(stem,0,PRIMARY_CASE_ALLOWED,true);
if (canonical && canonical->properties & VERB && !stricmp(lemma1, original)) { ; }
else canonical = NULL;
}
// stem changed from e to ie
strcpy(lemma1, stem);
char* change = strstr(lemma1, "ie");
char* again = (change) ? strstr(change + 1, "ie") : NULL;
if (again) change = again; // prefer 2nd one
if (!canonical && change) // ie from e
{
memmove(change, change + 1, strlen(change));
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
}
// stem changed from o to ue
strcpy(lemma1, stem);
change = strstr(lemma1, "ue");
again = (change) ? strstr(change + 1, "ue") : NULL;
if (!canonical && change) // ue from o
{
memmove(change, change + 1, strlen(change));
*change = 'o';
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
}
// stem changed from e to i
if (!strcmp(verbType, "ir")) // ir verb i from e
{
strcpy(lemma1, stem);
char* change = strrchr(lemma1, 'i');
if (!canonical && change) // i from e
{
*change = 'e';
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
}
}
else if (!stricmp(verbType, "er"))
{
strcpy(lemma1, stem);
char* change = strstr(lemma1, "ie");
char* again = (change) ? strstr(change + 1, "ie") : NULL;
if (again) change = again;
if (!canonical && change) // ie from e
{
memmove(change, change + 1, strlen(change));
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
}
// stem o changed to ue
strcpy(lemma1, stem);
change = strstr(lemma1, "ue");
again = (change) ? strstr(change + 1, "ue") : NULL;
if (!canonical && change) // ue from o
{
memmove(change, change + 1, strlen(change));
*change = 'o';
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
}
}
// stem changed from c to b (hacer conditional)
strcpy(lemma1, stem);
change = strrchr(lemma1, 'b');
if (!canonical && change) // b from c
{
memmove(change, change + 1, strlen(change));
*change = 'c';
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
}
// IRREGULAR VERB SPECIALS
//
// stem changed from c to r (hacer future)
strcpy(lemma1, stem);
change = strstr(lemma1, "r");
if (!canonical && change && properties & AUX_VERB_FUTURE) // r from c
{
memmove(change, change + 1, strlen(change));
*change = 'c';
canonical = ConfirmSpanishInfinitive(lemma1, verbType, stemLen, original, suffix, stem);
*change = 'r'; // revert
}
if (canonical)
{// since we found infinitive for it, assign info to the word
entry = D;
return properties | (canonical->properties & VERB_BITS);
}
if (!canonical) canonical = oldcanonical;
return properties;
}
static uint64 ReflexiveVerbSpanish(char* word, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
uint64 properties = 0;
size_t len = strlen(word);
// try reflexive forms of any regular verb
if (len > 2 && word[len - 2] == 's' && word[len - 1] == 'e')
{
char base[MAX_WORD_SIZE];
strcpy(base, word);
base[len - 2] = 0;
WORDP E = FindWord(base,0,PRIMARY_CASE_ALLOWED,true);
if (E && E->properties & VERB)
{
canonical = E;
if (!exportdictionary)
{
entry = GetLanguageWord(word);
properties |= VERB_PRESENT;
}
else entry = canonical;
sysflags |= PRONOUN_REFLEXIVE;
// if (E->properties & VERB_INFINITIVE) RemoveProperty(E, VERB_INFINITIVE); // treetagger lied - direct change, not restorable
properties |= VERB_PRESENT; // treetagger lied - direct change, not restorable
// if (entry->properties & VERB_INFINITIVE) RemoveProperty(entry, VERB_INFINITIVE); // treetagger lied - direct change, not restorable
properties |= E->properties;
}
}
return properties;
}
static void MakeUnaccentedCopy(const char* word, char* copy)
{
struct AccentEquivalence {
const char accent[3];
const char unaccent;
};
const AccentEquivalence table[] = {
{ "\xC3\xA1", 'a' },
{ "\xC3\xA9", 'e' },
{ "\xC3\xAD", 'i' },
{ "\xC3\xB3", 'o' },
{ "\xC3\xBA", 'u' }
};
while (*word) {
bool changed_letter = false;
if (*word == '\xC3')
{
for (const AccentEquivalence& entry : table) {
if (entry.accent[1] == word[1]) {
*copy = entry.unaccent;
changed_letter = true;
}
}
}
if (changed_letter) {
word += 2;
}
else {
*copy = *word;
word++;
}
copy++;
}
*copy = '\0';
}
static uint64 IrregularSpanishVerb(char* wordToFind, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
uint64 properties = 0;
// All searches done on unaccented version
char unaccentedWord[MAX_WORD_SIZE];
static unordered_map<std::string, IrregularSpanishInfo*> verb_map;
if (verb_map.empty()) {
IrregularSpanishInfo* entry = irregularSpanishVerbs;
while (entry->lemma[0] != '\0') {
MakeUnaccentedCopy(entry->original, unaccentedWord);
if (verb_map.find(unaccentedWord) != verb_map.end()) {
printf("Error: duplicate original %s unaccented %s\n",
entry->original, unaccentedWord);
}
verb_map[unaccentedWord] = entry;
entry->unaccented = unaccentedWord;
entry++;
}
}
MakeUnaccentedCopy(wordToFind, unaccentedWord);
if (verb_map.find(unaccentedWord) != verb_map.end())
{
IrregularSpanishInfo* fn = verb_map[unaccentedWord];
canonical = GetLanguageWord(fn->lemma);
sysflags |= fn->sysFlags;
properties = fn->properties;
}
return properties;
}
static WORDP FindSpanishWordRemoveAccent(char* base)
{
WORDP D = FindWord(base,0,PRIMARY_CASE_ALLOWED,true);
if (D) return D;
char copy[MAX_WORD_SIZE];
strcpy(copy, base);
char* ptr = copy - 1;
char c = 0;
while (*++ptr)
{
if (!strnicmp(ptr, "\xC3\xA1", 2)) c = 'a';
else if (!strnicmp(ptr, "\xC3\xA9", 2)) c = 'e';
else if (!strnicmp(ptr, "\xC3\xAD", 2)) c = 'i';
else if (!strnicmp(ptr, "\xC3\xB3", 2)) c = 'o';
else if (!strnicmp(ptr, "\xC3\xBA", 2)) c = 'u';
if (c)
{
*ptr = c;
memmove(ptr + 1, ptr + 2, strlen(ptr + 1));
D = FindWord(copy,0,PRIMARY_CASE_ALLOWED,true);
if (D) strcpy(base, copy);
return D;
}
}
return NULL;
}
WORDP FindSpanishWord(char* base, char* full)
{ // presume it had accent added, try to remove it
WORDP D = FindWord(full, 0, PRIMARY_CASE_ALLOWED, true); // dictionary knows it?
if (D)
{
D = GetCanonical(D, VERB_INFINITIVE);
if (D && D->properties & VERB_INFINITIVE) return D;
}
return FindSpanishWordRemoveAccent(base);
}
uint64 ImperativeSpanish(char* word, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
char base[MAX_WORD_SIZE];
strcpy(base, word);
size_t len = strlen(base);
WORDP Dbase = FindSpanishWordRemoveAccent(base);
uint64 properties = 0;
if (Dbase)
{
entry = Dbase;
}
// tu form, add 'r' to form infinitive
strcat(base, "r");
WORDP Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_SINGULAR | VERB_IMPERATIVE;
return properties | VERB;
}
base[len] = '\0';
// vosotros/vosotras form, remove 'd' and add 'r' to form infinitive
// also, éis -> ar as infinitive,
if (base[len - 1] == 'd') {
base[len - 1] = 'r';
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
base[len - 1] = 'd';
}
if (!stricmp(&base[len - 4], u8"éis")) {
strcpy(&base[len - 4], "ar");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_SINGULAR | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 4], u8"éis");
}
// usted form, e -> ar as infinitive, a -> er, a -> ir
if (base[len - 1] == 'e') {
strcpy(&base[len - 1], "ar");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_SINGULAR | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 1], "e");
}
if (base[len - 1] == 'a') {
strcpy(&base[len - 1], "er");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_SINGULAR | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 1], "ir");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_SINGULAR | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 1], "a");
}
// ustedes form, en -> ar as infinitive, an -> er, an -> ir
if (!stricmp(&base[len - 2], "en"))
{
strcpy(&base[len - 2], "ar");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 2], "en");
}
if (!stricmp(&base[len - 2], "an")) {
strcpy(&base[len - 2], "er");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 2], "ir");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_YOU | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 2], "an");
}
// nosotros form, emos -> ar as infinitive, amos -> er an ir
if (!stricmp(&base[len - 4], "emos")) {
strcpy(&base[len - 4], "ar");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_I | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 4], "emos");
}
if (!stricmp(&base[len - 4], "amos")) {
strcpy(&base[len - 4], "er");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_I | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 4], "ir");
Dcanon = FindSpanishWord(base, base);
if (Dcanon && (Dcanon->properties & VERB_INFINITIVE))
{
canonical = Dcanon;
sysflags |= PRONOUN_I | PRONOUN_PLURAL | VERB_IMPERATIVE;
return properties | VERB;
}
strcpy(&base[len - 4], "amos");
}
// irregular form
base[len] = '\0';
uint64 transient = IrregularSpanishVerb(base, entry, canonical, sysflags);
if (sysflags & VERB_IMPERATIVE) return properties | transient;
return false;
}
uint64 PresentSpanish(char* original, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
uint64 properties = PRONOUN_SUBJECT | VERB_PRESENT | VERB;
// imperative tu form? parar(to stop) = paras(you stop) → ¡Para!(Stop!)
uint64 transient = 0;
uint64 ans = ImperativeSpanish(original, entry, canonical, transient);
if (ans)
{
sysflags |= transient;
return properties | ans;
}
// we have the original. We know verb infinitive comes in 3 flavors. We try those flavors with the
// various possible stems.
// Spanish infinitives end in ar, er, or ir.
//
// 1st person // yo (habl)o (com)o (abr)o
transient = PRONOUN_SINGULAR | PRONOUN_I;
if (FindSpanishInfinitive(original, "o", "ar", entry, canonical, transient)) // yo
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "o", "er", entry, canonical, transient)) /// él, ella, usted habl + a habla
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "o", "ir", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
// 2nd person // tú (habl)as (com)es (abr)es
transient = PRONOUN_SINGULAR | PRONOUN_YOU;
if (FindSpanishInfinitive(original, "as", "ar", entry, canonical, transient)) // tu
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "es", "er", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "es", "ir", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
// 3rd person // él / ella (habl)a (com)e (abr)e
transient = PRONOUN_SINGULAR;
if (FindSpanishInfinitive(original, "a", "ar", entry, canonical, transient)) /// él, ella, usted habl + a habla
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "e", "er", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "e", "ir", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
transient = PRONOUN_PLURAL | PRONOUN_I;
// 1st person plural // nosotros (habl)amos (com)emos (abr)imos
if (FindSpanishInfinitive(original, "amos", "ar", entry, canonical, transient)) /// él, ella, usted habl + a habla
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "emos", "er", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "imos", "ir", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
transient = PRONOUN_PLURAL | PRONOUN_YOU;
// 2nd person plural // vosotros (habl)áis (com)éis (abr)ís
if (FindSpanishInfinitive(original, u8"áis", "ar", entry, canonical, transient)) /// él, ella, usted habl + a habla
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, u8"áis", "er", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, u8"ís", "ir", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
transient = PRONOUN_PLURAL;
// 3rd person plural ellos, ellas, ustedes // ellos/ellas (habl)an (com)en (abr)en
if (FindSpanishInfinitive(original, "an", "ar", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "en", "er", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
else if (FindSpanishInfinitive(original, "en", "ir", entry, canonical, transient))
{
sysflags |= transient;
return properties;
}
return 0;
}
uint64 PastSpanish(char* original, WORDP& entry, WORDP& canonical, uint64& sysflags)
{
// FindSpanishInfinitive(original, suffix, verb type, etnry, canonical, properties so far, new properties if match ) // yo
uint64 properties = PRONOUN_SUBJECT | VERB_PAST | VERB;
// 1st person preterite past // yo (habl)é (com)í (abr)í
uint64 transient = PRONOUN_SINGULAR | PRONOUN_I;