1 /* $Id: misc-types.h,v 1.12 2011/01/26 02:03:28 sarrazip Exp $
2 misc-types.h - Miscellaneous types used by the dictionary class.
4 verbiste - French conjugation system
5 Copyright (C) 2003-2010 Pierre Sarrazin <http://sarrazip.com/>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 #include <verbiste/c-api.h>
40 INVALID_MODE = VERBISTE_INVALID_MODE,
41 INFINITIVE_MODE = VERBISTE_INFINITIVE_MODE,
42 INDICATIVE_MODE = VERBISTE_INDICATIVE_MODE,
43 CONDITIONAL_MODE = VERBISTE_CONDITIONAL_MODE,
44 SUBJUNCTIVE_MODE = VERBISTE_SUBJUNCTIVE_MODE,
45 IMPERATIVE_MODE = VERBISTE_IMPERATIVE_MODE,
46 PARTICIPLE_MODE = VERBISTE_PARTICIPLE_MODE,
47 GERUND_MODE = VERBISTE_GERUND_MODE,
50 PRESENT_INDICATIVE = VERBISTE_PRESENT_INDICATIVE,
51 PRESENT_SUBJUNCTIVE = VERBISTE_PRESENT_SUBJUNCTIVE,
52 PRESENT_IMPERATIVE = VERBISTE_PRESENT_IMPERATIVE,
53 PRESENT_GERUND = VERBISTE_PRESENT_GERUND,
54 PAST_IMPERFECT_INDICATIVE = VERBISTE_PAST_IMPERFECT_INDICATIVE,
55 PAST_PERFECT_INDICATIVE = VERBISTE_PAST_PERFECT_INDICATIVE,
56 PAST_PERFECT_SUBJUNCTIVE = VERBISTE_PAST_PERFECT_SUBJUNCTIVE,
57 PAST_PERFECT_IMPERATIVE = VERBISTE_PAST_PERFECT_IMPERATIVE,
58 PAST_PERFECT_INFINITIVE = VERBISTE_PAST_PERFECT_INFINITIVE
67 INVALID_TENSE = VERBISTE_INVALID_TENSE,
68 PRESENT_TENSE = VERBISTE_PRESENT_TENSE,
69 PAST_TENSE = VERBISTE_PAST_TENSE,
70 IMPERFECT_TENSE = VERBISTE_IMPERFECT_TENSE,
71 FUTURE_TENSE = VERBISTE_FUTURE_TENSE,
74 ACTIVE_TENSE = VERBISTE_ACTIVE_TENSE,
75 PASSIVE_TENSE = VERBISTE_PASSIVE_TENSE,
76 IMPERATIVE_ACTIVE_TENSE = VERBISTE_IMPERATIVE_ACTIVE_TENSE,
77 IMPERATIVE_PASSIVE_TENSE = VERBISTE_IMPERATIVE_PASSIVE_TENSE,
78 PAST_PERFECT = VERBISTE_PAST_PERFECT
83 Description of a verb inflection.
84 Gives the mode, tense and person of a conjugated verb.
85 The person is 1, 2 or 3 for je/nous, tu/vous, il/ils, except in
86 infinitive and participle mode, where it is always 0
87 since it does not apply.
89 class ModeTensePersonNumber
93 /** Mode (infinitive, indicative, etc). */
96 /** Tense (present, past, etc). */
99 /** Person (1, 2 or 3, or 0 in infinitive mode).
100 In participle mode, 1..4 means masc sing, masc plur,
103 unsigned char person;
105 /** Number (true for plural, false for singular). */
108 /** Indicates if this termination is correct or an error. */
112 ModeTensePersonNumber(Mode m = INVALID_MODE,
113 Tense t = INVALID_TENSE,
114 unsigned char pers = 0,
116 bool isCorrect = true)
117 : mode(m), tense(t), person(pers), plural(plur), correct(isCorrect)
119 assert(mode <= PARTICIPLE_MODE);
120 assert(tense <= FUTURE_TENSE);
125 /** Constructs an object from English mode and tense names.
126 Calls the set() method.
127 @param modeName mode name known to method
128 FrenchVerbDictionary::convertModeName()
129 @param tenseName tense name known to method
130 FrenchVerbDictionary::convertTenseName()
131 @param personNum person "counter" (1--6, except for imperative
132 mode, where it must be 1--3; ignored for
133 infinitive and participle modes)
134 @param isCorrect indicates if this termination is correct
137 ModeTensePersonNumber(const char *modeName,
138 const char *tenseName,
142 : mode(INVALID_MODE), tense(INVALID_TENSE), person(0), plural(false), correct(false)
144 set(modeName, tenseName, personNum, isCorrect, isItalian);
148 /** Initializes an object from English mode and tense names.
149 Call the set() method.
150 @param modeName mode name known to method
151 FrenchVerbDictionary::convertModeName()
152 @param tenseName tense name known to method
153 FrenchVerbDictionary::convertTenseName()
154 @param personNum person "counter" (1--6, except for imperative
155 mode, where it must be 1--3; ignored for
156 infinitive mode); for participle mode, must be
157 1..4 (masc sing, masc plur, fem sing, fem plur)
158 @param isCorrect indicates if this termination is correct
160 @param isItalian true for Italian, false for French
162 void set(const char *modeName, const char *tenseName, int personNum, bool isCorrect, bool isItalian);
166 Dumps the fields of this object into those of the destination object.
167 @param destination object whose fields (mode, tense, person,
168 number) are assigned with values taken
171 void dump(Verbiste_ModeTensePersonNumber &destination) const;
175 struct InflectionSpec
177 std::string inflection;
180 InflectionSpec(const std::string &inf, bool c) : inflection(inf), isCorrect(c) {}
184 /** List of inflections. */
185 typedef std::vector<InflectionSpec> PersonSpec;
188 /** List of persons (1, 3 or 6 persons depending on the mode and tense). */
189 typedef std::vector<PersonSpec> TenseSpec;
194 Contains tense specifications indexed by Tense values.
196 typedef std::map<Tense, TenseSpec> ModeSpec;
200 Conjugation template specification.
201 Contains mode specifications indexed by Mode values.
203 typedef std::map<Mode, ModeSpec> TemplateSpec;
207 Conjugation system for the known verbs of a language.
208 Contains conjugation templates indexed by template names.
210 typedef std::map<std::string, TemplateSpec> ConjugationSystem;
214 Table of template names indexed by verb infinitive.
215 If the verb "abaisser" follows the "aim:er" conjugation template,
216 then a VerbTable would contain an entry where the key is "abaisser"
217 and the value is a set containing "aim:er".
218 An infinitive can be associated with more than one template.
220 typedef std::map< std::string, std::set<std::string> > VerbTable;
224 Table that describes the mode, tense and person of a number of inflections.
225 For example, in the "aim:er" conjugation template, the inflection
226 (termination) "e" is associated with:
228 - the 1st person singular of the indicative present;
230 - the 3rd person singular of the indicative present;
232 - the 1st person singular of the subjunctive present;
234 - the 3rd person singular of the subjunctive present;
236 - the 2nd person singular of the imperative present.
238 Thus, in this table, the key "e" would be be associated with a vector
239 of five objects representing these five mode-tense-person combinations.
241 typedef std::map<std::string, std::vector<ModeTensePersonNumber> >
242 TemplateInflectionTable;
246 Table of template inflection tables, indexed by template names.
247 For example, a key "aim:er" would be associated with a template
248 inflection table that gives all inflections (terminations) that are
249 accepted by the "aim:er" conjugation template (e.g., "e", "es",
252 typedef std::map<std::string, TemplateInflectionTable> InflectionTable;
256 Description of a conjugated verb's inflection.
262 /** Infinitive form of the conjugated verb (UTF-8). */
263 std::string infinitive;
265 /** Conjugated template used by the verb (e.g. "aim:er") (UTF-8). */
266 std::string templateName;
268 /** Mode, tense, person and number of the inflection. */
269 ModeTensePersonNumber mtpn;
272 Constructs an inflection description from optional arguments.
274 InflectionDesc(const std::string &inf = "",
275 const std::string &tname = "",
276 ModeTensePersonNumber m = ModeTensePersonNumber())
285 #endif /* _H_misc_types */