File size: 14,208 Bytes
c772837
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/*
 * Symbolic Morphology Engine β€” Latin verb morphology from raw letters to Boolean grammar
 * Copyright (C) 2026 Ahmad Ali Parr
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

namespace Sovereign.Engine;

/// <summary>
/// Latin verb morphology corpus.
/// Each entry maps a word form to its Boolean grammatical feature vector.
/// </summary>
public static class Dataset
{
    public static (string Word, double[] Target)[] BuildCorpus()
    {
        var corpus = new List<(string, double[])>();

        // ─── 1st Conjugation: amare (to love) ──────────────────────
        // Present indicative active
        Add(corpus, "amo",    "PERSON_1", "SINGULAR", "PRESENT",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amas",   "PERSON_2", "SINGULAR", "PRESENT",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amat",   "PERSON_3", "SINGULAR", "PRESENT",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amamus", "PERSON_1", "PLURAL",   "PRESENT",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amatis", "PERSON_2", "PLURAL",   "PRESENT",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amant",  "PERSON_3", "PLURAL",   "PRESENT",    "INDICATIVE", "ACTIVE", "CONJ_1");

        // Imperfect indicative active
        Add(corpus, "amabam",  "PERSON_1", "SINGULAR", "IMPERFECT", "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabas",  "PERSON_2", "SINGULAR", "IMPERFECT", "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabat",  "PERSON_3", "SINGULAR", "IMPERFECT", "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabamus","PERSON_1", "PLURAL",   "IMPERFECT", "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabatis","PERSON_2", "PLURAL",   "IMPERFECT", "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabant", "PERSON_3", "PLURAL",   "IMPERFECT", "INDICATIVE", "ACTIVE", "CONJ_1");

        // Future indicative active
        Add(corpus, "amabo",  "PERSON_1", "SINGULAR", "FUTURE",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabis", "PERSON_2", "SINGULAR", "FUTURE",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabit", "PERSON_3", "SINGULAR", "FUTURE",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabimus","PERSON_1","PLURAL",   "FUTURE",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabitis","PERSON_2","PLURAL",   "FUTURE",    "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amabunt", "PERSON_3","PLURAL",   "FUTURE",    "INDICATIVE", "ACTIVE", "CONJ_1");

        // Perfect indicative active
        Add(corpus, "amavi",    "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amavisti", "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amavit",   "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amavimus", "PERSON_1", "PLURAL",   "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amavistis","PERSON_2", "PLURAL",   "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "amaverunt","PERSON_3", "PLURAL",   "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");

        // ─── 1st Conjugation: laudare (to praise) ──────────────────
        Add(corpus, "laudo",      "PERSON_1", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudas",     "PERSON_2", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudat",     "PERSON_3", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudamus",   "PERSON_1", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudatis",   "PERSON_2", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudant",    "PERSON_3", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudabam",   "PERSON_1", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudabas",   "PERSON_2", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudabat",   "PERSON_3", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudabamus", "PERSON_1", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudabatis", "PERSON_2", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudabant",  "PERSON_3", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudavi",    "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudavisti", "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");
        Add(corpus, "laudavit",   "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_1");

        // ─── 2nd Conjugation: monere (to warn) ─────────────────────
        Add(corpus, "moneo",    "PERSON_1", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "mones",    "PERSON_2", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monet",    "PERSON_3", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monemus",  "PERSON_1", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monetis",  "PERSON_2", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monent",   "PERSON_3", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monebam",  "PERSON_1", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monebas",  "PERSON_2", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monebat",  "PERSON_3", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monebamus","PERSON_1", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monebatis","PERSON_2", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monebant", "PERSON_3", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monui",    "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monuisti", "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "monuit",   "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_2");

        // ─── 2nd Conjugation: habere (to have) ─────────────────────
        Add(corpus, "habeo",    "PERSON_1", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habes",    "PERSON_2", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habet",    "PERSON_3", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habemus",  "PERSON_1", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habetis",  "PERSON_2", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habent",   "PERSON_3", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habui",    "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habuisti", "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_2");
        Add(corpus, "habuit",   "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_2");

        // ─── 3rd Conjugation: regere (to rule) ─────────────────────
        Add(corpus, "rego",     "PERSON_1", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regis",    "PERSON_2", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regit",    "PERSON_3", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regimus",  "PERSON_1", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regitis",  "PERSON_2", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regunt",   "PERSON_3", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regebam",  "PERSON_1", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "reuebas",  "PERSON_2", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regebat",  "PERSON_3", "SINGULAR", "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regebamus","PERSON_1", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regebatis","PERSON_2", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "regebant", "PERSON_3", "PLURAL",   "IMPERFECT","INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "rexi",     "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "rexisti",  "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "rexit",    "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");

        // ─── 3rd Conjugation: agere (to do/drive) ──────────────────
        Add(corpus, "ago",      "PERSON_1", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "agis",     "PERSON_2", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "agit",     "PERSON_3", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "agimus",   "PERSON_1", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "agitis",   "PERSON_2", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "agunt",    "PERSON_3", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "egi",      "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "egisti",   "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "egit",     "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");

        // ─── 3rd Conjugation: ducere (to lead) ─────────────────────
        Add(corpus, "duco",     "PERSON_1", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "ducis",    "PERSON_2", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "ducit",    "PERSON_3", "SINGULAR", "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "ducimus",  "PERSON_1", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "ducitis",  "PERSON_2", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "ducunt",   "PERSON_3", "PLURAL",   "PRESENT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "duxi",     "PERSON_1", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "duxisti",  "PERSON_2", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");
        Add(corpus, "duxit",    "PERSON_3", "SINGULAR", "PERFECT",  "INDICATIVE", "ACTIVE", "CONJ_3");

        return corpus.ToArray();
    }

    static void Add(List<(string, double[])> corpus, string word,
        string person, string number, string tense, string mood, string voice, string conjugation)
    {
        corpus.Add((word.ToUpperInvariant(), Features.MakeTarget(
            ("PERSON", person),
            ("NUMBER", number),
            ("TENSE", tense),
            ("MOOD", mood),
            ("VOICE", voice),
            ("CONJUGATION", conjugation)
        )));
    }

    /// <summary>
    /// Unseen words for generalization testing.
    /// These verbs do NOT appear in the training corpus.
    /// </summary>
    public static (string Word, double[] Target)[] UnseenWords()
    {
        return new (string, double[])[]
        {
            ("NARRAT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","SINGULAR"),("TENSE","PRESENT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_1"))),
            ("NARRANT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","PLURAL"),("TENSE","PRESENT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_1"))),
            ("NARRABAT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","SINGULAR"),("TENSE","IMPERFECT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_1"))),
            ("VIDET", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","SINGULAR"),("TENSE","PRESENT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_2"))),
            ("VIDENT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","PLURAL"),("TENSE","PRESENT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_2"))),
            ("VIDEBAT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","SINGULAR"),("TENSE","IMPERFECT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_2"))),
            ("SCRIBIT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","SINGULAR"),("TENSE","PRESENT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_3"))),
            ("SCRIBUNT", Features.MakeTarget(("PERSON","PERSON_3"),("NUMBER","PLURAL"),("TENSE","PRESENT"),("MOOD","INDICATIVE"),("VOICE","ACTIVE"),("CONJUGATION","CONJ_3"))),
        };
    }
}