moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kverbos / kverbos / verbspanish.h
blobd49ba9a8035d498a43e3fdb964599ee3927a77c7
1 /***************************************************************************
2 verbspanish.h - description
3 -------------------
4 begin : Sun Dec 23 2001
5 copyright : (C) 2001 by Arnold Kraschinski
6 email : arnold.k67@gmx.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef VERBSPANISH_H
19 #define VERBSPANISH_H
21 // include qt-Header
22 #include <qvaluelist.h>
24 #define MAX_TIEMPOS 9
25 #define MAX_SUBTYPES 3
26 #define PERSONEN 6
27 #define MAX_GRUPPEN 17
28 #define REGULAR 0
29 #define IRREGULAR 1
30 #define VERBMUSTER 3
32 enum endings {ar, er, ir, empty};
33 // dummy1 to dummy3 are standing for forms that aren't possible
34 enum timeTypes {presente, imperfecto, indefinido, futuro, condicional, subPresente,
35 subPasado, subFuturo, imperativo,
36 presentePro, imperfectoPro, indefinidoPro, futuroPro, condicionalPro,
37 subPresentePro, subPasadoPro, subFuturoPro, dummy2,
38 presentePer, imperfectoPer, dummy1, futuroPer, condicionalPer,
39 subPresentePer, subPasadoPer, subFuturoPre, dummy3
41 enum timeSubTypes {normal, progresivo, perfecto};
42 enum persons {yo, tu, el, nosotros, vosotros, ellos};
44 typedef QString formArray[MAX_TIEMPOS][PERSONEN];
45 typedef QString endingsArray[MAX_TIEMPOS][VERBMUSTER][PERSONEN];
47 /** This class contains all the information belonging to one verb:
49 * - the foreign and the spanish meaning
50 * - the form of the gerund and the participle
51 * - the different time forms of the verb
52 * - if it is irregular or to which group the verb belongs
53 * - if the object already contains all the possible forms
55 * Some information belongs to all verbs. It is stored in static variables.
56 * - a lists of the regular endings
57 * - an array with the different reflexiv pronouns
58 * - forms of the verbs estar and haber that are needed for the gerund and the perfect
59 * form of a time.
61 * To the class belong some enums that are used in the class:
62 * endings are the differnet spanish verb endings, 0 = ar, 1 = er, 2 = ir.
63 * <pre>
64 * enum endings {ar, er, ir, empty};
65 * </pre>
67 * 'timeTypes' are the different spanish times. There are
68 * MAX_TIEMPOS (=9) * MAX_SUBTYPES (=3) = 27 different types. Types called 'dummyX'
69 * arent't existing but it is easier to use in the program.
70 * <pre>
71 * enum timeTypes {presente, imperfecto, indefinido, futuro, condicional, subPresente,
72 * subPasado, subFuturo, imperativo,
73 * presentePro, imperfectoPro, indefinidoPro, futuroPro, condicionalPro,
74 * subPresentePro, subPasadoPro, subFuturoPro, dummy2,
75 * presentePer, imperfectoPer, dummy1, futuroPer, condicionalPer,
76 * subPresentePer, subPasadoPer, subFuturoPre, dummy3
77 * };
78 * </pre>
80 * timeSubTypes seperates between a normal form of the time or a progressiv, or perfekt
81 * form of the time. The verb object only stores the gerund or the participle for this
82 * forms the rest can be found in static variables of the class.
83 * <pre>
84 * enum timeSubTypes {normal, progresivo, perfecto};
85 * </pre>
87 * Persons are the different grammatical persons including vosotros which is unusual
88 * in Latin America. (PERSONEN = 6)
89 * <pre>
90 * enum persons {yo, tu, el, nosotros, vosotros, ellos};
91 * </pre>
93 * The conjugated forms of the verb are stored in the array 'formArray'. The first index
94 * mentions the time and the second the person.
95 * <pre>
96 * typedef QString formArray[MAX_TIEMPOS][PERSONEN];
97 * </pre>
99 * The type 'endingsArray' stores the different endings. The first index means the time,
100 * the second the type of verb (-ar, -er, -ir) and the lase one is the person.
101 * <pre>
102 * typedef QString endingsArray[MAX_TIEMPOS][MAX_SUBTYPES][PERSONEN];
103 * </pre>
105 * The verbs are divided in several groups:
106 * 0 -> regular
107 * 1 -> irregular
108 * 2 -> <e -> ie>
109 * 3 -> <o -> ue>
110 * 4 -> <u -> ue>
111 * 5 -> <e -> i>
112 * 6 -> <c -> qu>
113 * 7 -> <g -> gu>
114 * 8 -> <z -> c>
115 * 9 -> <gu -> gü>
116 * 10 -> <c -> z>
117 * 11 -> <g -> j>
118 * 12 -> <gu -> g>
119 * 13 -> <qu -> c>
120 * 14 -> <accent like 'enviar'>
121 * 15 -> <accent like 'continuar'>
122 * 16 -> <missing i>
123 *@author Arnold Kraschinski
126 class verbSpanish
128 public:
129 verbSpanish();
130 verbSpanish(const verbSpanish& v);
131 virtual ~verbSpanish();
132 verbSpanish& operator= (const verbSpanish& v);
133 /** If two verbs are compared only the foreign form and the spanish form are compared */
134 bool operator== (const verbSpanish& v) const;
135 /** This overloaded == operator compares the verb to a QString.
136 * Only the spanish meaning is compared.
138 bool operator== (const QString& s) const;
139 /** The spa/nisch forms of the verb are compared */
140 bool operator< (const verbSpanish& v) const;
141 /** Compares the verb objects completely, all forms and fields.
143 bool allEqual(verbSpanish v);
144 /** tests if the fields of the object contain only empty strings
146 bool isEmpty() const;
147 /** returns the foreign meaning of the verb
149 QString getForeign() const;
150 /** sets the foreign meaning of the verb
152 void setForeign(const QString &s);
153 /** returns the spanish meaning of the verb
155 QString getSpanish() const;
156 /** sets the spanish meaning of the verb
158 void setSpanish(const QString &s);
159 /** returns the gerund of the verb
161 QString getGerund();
162 /** sets the gerund form to the string given in s
164 void setGerund(const QString &s);
165 /** returns the particip of the verb
167 QString getPartizip();
168 /** sets the participe to the string given in s
170 void setPartizip(const QString &s);
171 /** returns if the verb belongs to one of the groups
173 bool isGroupVerb();
174 /** returns the group number to which the verb belongs
176 int getGroup() { return group; };
177 /** sets the field regular corresponding to b
179 void setGroup(const int g);
180 /** returns the desired verb form indicated by time, person and type. This means
181 * with this function complex forms like a progressise or a perfect form can be
182 * retrieved.
183 * The parts of the form a stored like this:
184 * parts[0] the reflexive pronoun
185 * parts[1} the auxiliary verb
186 * parts[2] the verb form
187 * The return value 'bool' indicates if the form could be formed.
189 bool getForm(int t, int p, int typ, QString parts[]);
190 /** returns the desired verb form indicated by time and person as a string
192 QString getForm(int t, int p);
193 /** sets the verb form that is indicated by time and person
195 void setForm(int t, int p, QString s);
196 /** The following function generates the regular verb forms. The forms can be
197 * generated time by time or all times in one step by using conjugateAll()
199 bool conjugateAll();
200 /** returns if the verb is a reflexive one
202 bool isReflexiv() const;
203 /** returns the reflexive pronoun that belongs to the person p
205 QString getRefPron(int p);
206 /** tests if the string is an automatic generated Form, that means the last char is '#' */
207 bool isAutoForm(QString& s) const;
208 private:
209 bool conjugatePresente();
210 bool conjugateImperfecto();
211 bool conjugateIndefinido();
212 bool conjugateFuturo();
213 bool conjugateCondicional();
214 bool conjugateSubPresente();
215 bool conjugateSubPasado();
216 bool conjugateImperativo();
217 /** returns the verb stem
219 QString getStem() const;
220 /** returns the ending of the verb
222 endings getEnding(bool& good);
223 /** bildet die Formen, d.h. hängt die Endungen an den unveränderlichen
224 * Teil an.
225 * Die Form muss bisher ein leerer String sein. Anderenfalls wird angenommen, dass
226 * bereits eine gültige Form vorliegt und diese Form eine unregelmäßige Form ist, die
227 * nicht überschrieben werden soll.
229 bool conjugateTime(const int t, const QString &s);
230 /** Es wird verglichen, ob die beiden Strings gemeinsame Bestandteile haben. Also
231 * "gehen, laufen, springen" wird etwa mit "gehen, laufen" verglichen. Die Funktion
232 * gibt in so einem Fall 'true' zurück, auch wenn im zweiten String ein Teil
233 * fehlt. Das ist nötig, um zwei Verben als gleich zu erkennen, auch wenn bei einem
234 * mehr oder weniger deutsche Bedeutungen oder die Bedeutungen in anderer Reihenfolge
235 * angegeben sind.
237 bool vergleich(const QString& s1, const QString& s2) const;
238 /** Deletes the '#' character from autogenerated forms. */
239 QString delAutoForm(QString s) const;
240 /** does the changes for group verbs
242 bool groupVerb(QString &s, int time=-1, int person=-1);
243 /** the verb in the foreign language
245 QString foreign;
246 /** the spanish verb
248 QString spanish;
249 /** the gerund form of the verb
251 QString gerund;
252 /** the partizip form of the verb
254 QString partizip;
255 /** the array for all the different forms of the verb
257 formArray forms;
258 /** tells to which group the verb belongs
260 int group;
261 /** tells if all verbforms are present or if some are missing.
263 bool conjugated;
264 /** set to true if the class has found an error in the verb structure. */
265 bool error;
267 /** In this array all the different endings for all the different times
268 * are stored.
270 static endingsArray verbEndings;
271 /** the reflexive pronouns
273 static QString refPron[PERSONEN];
274 public:
275 /** The forms of the verb estar. They are needed for the gerund form.
277 static QString estar[MAX_TIEMPOS][PERSONEN];
278 /** The forms of the verb haber. They are needed for perfect forms
280 static QString haber[MAX_TIEMPOS][PERSONEN];
281 /** This array contains the names of the time forms as strings
283 static QString timeNames[MAX_TIEMPOS*MAX_SUBTYPES];
284 /** This array contains the names of the different verb groups
286 static QString groupNames[MAX_GRUPPEN];
287 static int maxTiempos;
288 static int maxSubtypes;
289 static int persons;
290 static int maxForms;
291 /** The language that is selected at the moment. This selection affects all the instances
292 * of the class. */
293 static QString language;
296 /** Very often a list of verbs is needed. This is the type definition of a
297 * QValueList template with the verbSpanish type
299 typedef QValueList<verbSpanish> spanishVerbList;
301 #endif