-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwords.hpp
346 lines (286 loc) · 9.87 KB
/
words.hpp
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
#pragma once
#include "json_fwd.hpp"
#include <string>
enum PartOfSpeech {
PART_OF_SPEECH_NOUN,
PART_OF_SPEECH_VERB,
PART_OF_SPEECH_PARTICIPLE,
PART_OF_SPEECH_SUPINE,
PART_OF_SPEECH_ADJECTIVE,
PART_OF_SPEECH_ADVERB,
PART_OF_SPEECH_PRONOUN,
PART_OF_SPEECH_CONJUNCTION,
PART_OF_SPEECH_PREPOSITION,
PART_OF_SPEECH_INTERJECTION,
PART_OF_SPEECH_NUMERAL,
};
enum Casus {
CASUS_NOMINATIVE,
CASUS_GENITIVE,
CASUS_DATIVE,
CASUS_ACCUSATIVE,
CASUS_ABLATIVE,
CASUS_VOCATIVE,
CASUS_LOCATIVE,
CASUS_NONE,
};
enum Gender {
GENDER_MASCULINE,
GENDER_FEMININE,
GENDER_NEUTER,
GENDER_COMMON,
GENDER_NONE,
};
inline bool operator==(Gender a, Gender b) {
return (int) a == b || (int) a == GENDER_COMMON || (int) b == GENDER_COMMON;
}
inline bool operator!=(Gender a, Gender b) {
return (int) a != GENDER_COMMON && (int) b != GENDER_COMMON && (int) a != b;
}
enum Degree {
DEGREE_POSITIVE,
DEGREE_COMPARATIVE,
DEGREE_SUPERLATIVE,
DEGREE_NONE,
};
enum Tense {
TENSE_PRESENT,
TENSE_IMPERFECT,
TENSE_PERFECT,
TENSE_PLUPERFECT,
TENSE_FUTURE,
TENSE_FUTURE_PERFECT,
TENSE_NONE,
};
enum Voice {
VOICE_ACTIVE,
VOICE_PASSIVE,
VOICE_NONE,
};
enum Mood {
MOOD_INDICATIVE,
MOOD_SUBJUNCTIVE,
MOOD_IMPERATIVE,
MOOD_INFINITIVE,
MOOD_NONE,
};
enum NumeralType {
NUMERAL_TYPE_CARDINAL,
NUMERAL_TYPE_ORDINAL,
NUMERAL_TYPE_DISTRIBUTIVE,
NUMERAL_TYPE_ADVERB,
NUMERAL_TYPE_NONE,
};
typedef unsigned short Declension;
typedef unsigned short Conjugation;
typedef unsigned short Person;
class WordForm {
public:
PartOfSpeech part_of_speech;
WordForm(PartOfSpeech part_of_speech):
part_of_speech(part_of_speech) {}
virtual ~WordForm() = default;
virtual std::string english_equivalent(const std::string& english_base) const = 0;
virtual std::string tokenize() const;
virtual nlohmann::json to_json() const;
virtual Casus get_casus() const { return CASUS_NONE; }
virtual Gender get_gender() const { return GENDER_NONE; }
virtual Degree get_degree() const { return DEGREE_NONE; }
virtual Tense get_tense() const { return TENSE_NONE; }
virtual Voice get_voice() const { return VOICE_NONE; }
virtual Mood get_mood() const { return MOOD_NONE; }
virtual NumeralType get_numeral_type() const { return NUMERAL_TYPE_NONE; }
virtual Declension get_declension() const { return 0; }
virtual Conjugation get_conjugation() const { return 0; }
virtual Person get_person() const { return 0; }
virtual bool is_plural() const { return false; }
virtual bool is_noun_like() const { return false; }
};
class Noun : public WordForm {
public:
Declension declension;
Casus casus;
bool plural;
Gender gender;
Noun(PartOfSpeech part_of_speech = PART_OF_SPEECH_NOUN):
WordForm(part_of_speech) {}
Noun(Declension declension, Casus casus, bool plural, Gender gender):
WordForm(PART_OF_SPEECH_NOUN),
declension(declension),
casus(casus),
plural(plural),
gender(gender) {}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
Casus get_casus() const override { return casus; }
Gender get_gender() const override { return gender; }
Declension get_declension() const override { return declension; }
bool is_plural() const override { return plural; }
bool is_noun_like() const override { return true; }
};
class Verb : public WordForm {
public:
Conjugation conjugation;
Tense tense;
Voice voice;
Mood mood;
Person person;
bool plural;
Verb(PartOfSpeech part_of_speech = PART_OF_SPEECH_VERB):
WordForm(part_of_speech) {}
Verb(Conjugation conjugation, Tense tense, Voice voice, Mood mood, Person person, bool plural):
WordForm(PART_OF_SPEECH_VERB),
conjugation(conjugation),
tense(tense),
voice(voice),
mood(mood),
person(person),
plural(plural) {}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
Tense get_tense() const override { return tense; }
Voice get_voice() const override { return voice; }
Mood get_mood() const override { return mood; }
Conjugation get_conjugation() const override { return conjugation; }
Person get_person() const override { return person; }
bool is_plural() const override { return plural; }
};
class Participle : public WordForm {
public:
Conjugation conjugation;
Casus casus;
bool plural;
Gender gender;
Tense tense;
Voice voice;
Participle(PartOfSpeech part_of_speech = PART_OF_SPEECH_PARTICIPLE):
WordForm(part_of_speech) {}
Participle(Conjugation conjugation, Casus casus, bool plural, Gender gender, Tense tense, Voice voice):
WordForm(PART_OF_SPEECH_PARTICIPLE),
conjugation(conjugation),
casus(casus),
plural(plural),
gender(gender),
tense(tense),
voice(voice) {}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
Casus get_casus() const override { return casus; }
Gender get_gender() const override { return gender; }
Tense get_tense() const override { return tense; }
Voice get_voice() const override { return voice; }
Conjugation get_conjugation() const override { return conjugation; }
bool is_plural() const override { return plural; }
bool is_noun_like() const override { return true; }
};
class Supine : public WordForm {
public:
Conjugation conjugation;
Casus casus;
bool plural;
Gender gender;
Supine(PartOfSpeech part_of_speech = PART_OF_SPEECH_SUPINE):
WordForm(part_of_speech) {}
Supine(Conjugation conjugation, Casus casus, bool plural, Gender gender):
WordForm(PART_OF_SPEECH_SUPINE),
conjugation(conjugation),
casus(casus),
plural(plural),
gender(gender) {}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
Casus get_casus() const override { return casus; }
Gender get_gender() const override { return gender; }
Conjugation get_conjugation() const override { return conjugation; }
bool is_plural() const override { return plural; }
};
class Adjective : public Noun {
public:
Degree degree;
Adjective(PartOfSpeech part_of_speech = PART_OF_SPEECH_ADJECTIVE):
Noun(part_of_speech) {}
Adjective(Declension declension, Casus casus, bool plural, Gender gender, Degree degree):
Noun(declension, casus, plural, gender),
degree(degree) {
part_of_speech = PART_OF_SPEECH_ADJECTIVE;
}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
Degree get_degree() const override { return degree; }
bool is_noun_like() const override { return false; }
};
class Adverb : public WordForm {
public:
Degree degree;
Adverb(PartOfSpeech part_of_speech = PART_OF_SPEECH_ADVERB):
WordForm(part_of_speech) {}
Adverb(Degree degree):
WordForm(PART_OF_SPEECH_ADVERB),
degree(degree) {}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
Degree get_degree() const override { return degree; }
};
class Pronoun : public Noun {
public:
Pronoun(PartOfSpeech part_of_speech = PART_OF_SPEECH_PRONOUN):
Noun(part_of_speech) {}
Pronoun(Declension declension, Casus casus, bool plural, Gender gender):
Noun(declension, casus, plural, gender) {
part_of_speech = PART_OF_SPEECH_PRONOUN;
}
std::string english_equivalent(const std::string& english_base) const override;
};
class Conjunction : public WordForm {
public:
Conjunction(PartOfSpeech part_of_speech = PART_OF_SPEECH_CONJUNCTION):
WordForm(part_of_speech) {}
std::string english_equivalent(const std::string& english_base) const override {
return english_base;
}
};
class Preposition : public WordForm {
public:
Casus casus;
Preposition(PartOfSpeech part_of_speech = PART_OF_SPEECH_PREPOSITION):
WordForm(part_of_speech) {}
Preposition(Casus casus):
WordForm(PART_OF_SPEECH_PREPOSITION),
casus(casus) {}
std::string english_equivalent(const std::string& english_base) const override {
return english_base;
}
std::string tokenize() const override;
nlohmann::json to_json() const override;
Casus get_casus() const override { return casus; }
};
class Interjection : public WordForm {
public:
Interjection(PartOfSpeech part_of_speech = PART_OF_SPEECH_INTERJECTION):
WordForm(part_of_speech) {}
std::string english_equivalent(const std::string& english_base) const override {
return english_base;
}
};
class Numeral : public Noun {
public:
NumeralType type;
Numeral(PartOfSpeech part_of_speech = PART_OF_SPEECH_NUMERAL):
Noun(part_of_speech) {}
Numeral(Declension declension, Casus casus, bool plural, Gender gender, NumeralType type):
Noun(declension, casus, plural, gender),
type(type) {
part_of_speech = PART_OF_SPEECH_NUMERAL;
}
std::string english_equivalent(const std::string& english_base) const override;
std::string tokenize() const override;
nlohmann::json to_json() const override;
NumeralType get_numeral_type() const override { return type; }
bool is_noun_like() const override { return false; }
};