summaryrefslogtreecommitdiffstats
path: root/kverbos/kverbos/verbspanish.h
blob: 8b7cf7b1d36b015633234f9091af35eea586ea83 (plain)
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
/***************************************************************************
                          verbspanish.h  -  description
                             -------------------
    begin                : Sun Dec 23 2001
    copyright            : (C) 2001 by Arnold Kraschinski
    email                : arnold.k67@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef VERBSPANISH_H
#define VERBSPANISH_H

// include qt-Header
#include <qvaluelist.h>

#define MAX_TIEMPOS 9
#define MAX_SUBTYPES 3
#define	PERSONEN 6
#define MAX_GRUPPEN 17
#define REGULAR 0
#define IRREGULAR 1
#define VERBMUSTER 3

enum endings {ar, er, ir, empty};
// dummy1 to dummy3 are standing for forms that aren't possible
enum timeTypes {presente, imperfecto, indefinido, futuro, condicional, subPresente,
                subPasado, subFuturo, imperativo,
                presentePro, imperfectoPro, indefinidoPro, futuroPro, condicionalPro,
                subPresentePro, subPasadoPro, subFuturoPro, dummy2,
                presentePer, imperfectoPer, dummy1, futuroPer, condicionalPer,
                subPresentePer, subPasadoPer, subFuturoPre, dummy3
               };
enum timeSubTypes {normal, progresivo, perfecto};
enum persons {yo, tu, el, nosotros, vosotros, ellos};

typedef QString formArray[MAX_TIEMPOS][PERSONEN];
typedef QString endingsArray[MAX_TIEMPOS][VERBMUSTER][PERSONEN];

/** This class contains all the information belonging to one verb:
  *
  *  - the foreign and the spanish meaning
  *  - the form of the gerund and the participle
  *  - the different time forms of the verb
  *  - if it is irregular or to which group the verb belongs
  *  - if the object already contains all the possible forms
  *
  *  Some information belongs to all verbs. It is stored in static variables.
  *  - a lists of the regular endings
  *  - an array with the different reflexiv pronouns
  *  - forms of the verbs estar and haber that are needed for the gerund and the perfect
  *    form of a time.
  *
  *  To the class belong some enums that are used in the class:
  *  endings are the differnet spanish verb endings, 0 = ar, 1 = er, 2 = ir.
  *  <pre>
  *  enum endings {ar, er, ir, empty};
  *  </pre>
  *
  *  'timeTypes' are the different spanish times. There are
  *  MAX_TIEMPOS (=9) * MAX_SUBTYPES (=3) = 27 different types. Types called 'dummyX'
  *  arent't existing but it is easier to use in the program.
  *  <pre>
  *  enum timeTypes {presente, imperfecto, indefinido, futuro, condicional, subPresente,
  *                subPasado, subFuturo, imperativo,
  *                presentePro, imperfectoPro, indefinidoPro, futuroPro, condicionalPro,
  *                subPresentePro, subPasadoPro, subFuturoPro, dummy2,
  *                presentePer, imperfectoPer, dummy1, futuroPer, condicionalPer,
  *                subPresentePer, subPasadoPer, subFuturoPre, dummy3
  *               };
  *  </pre>
  *
  *  timeSubTypes seperates between a normal form of the time or a progressiv, or perfekt
  *  form of the time. The verb object only stores the gerund or the participle for this
  *  forms the rest can be found in static variables of the class.
  *  <pre>
  *  enum timeSubTypes {normal, progresivo, perfecto};
  *  </pre>
  *
  *  Persons are the different grammatical persons including vosotros which is unusual
  *  in Latin America. (PERSONEN = 6)
  *  <pre>
  *  enum persons {yo, tu, el, nosotros, vosotros, ellos};
  *  </pre>
  *
  *	 The conjugated forms of the verb are stored in the array 'formArray'. The first index
  *  mentions the time and the second the person.
  *  <pre>
  *  typedef QString formArray[MAX_TIEMPOS][PERSONEN];
  *  </pre>
  *
  *  The type 'endingsArray' stores the different endings. The first index means the time,
  *  the second the type of verb (-ar, -er, -ir) and the lase one is the person.
  *  <pre>
  *  typedef QString endingsArray[MAX_TIEMPOS][MAX_SUBTYPES][PERSONEN];
  *  </pre>
  *
  *  The verbs are divided in several groups:
  *		0 -> regular
  *   1 -> irregular
  *   2 -> <e -> ie>
  *   3 -> <o -> ue>
  *   4 -> <u -> ue>
  *   5 -> <e -> i>
  *   6 -> <c -> qu>
  *   7 -> <g -> gu>
  *   8 -> <z -> c>
  *   9 -> <gu -> gü>
  *  10 -> <c -> z>
  *  11 -> <g -> j>
  *  12 -> <gu -> g>
  *  13 -> <qu -> c>
  *  14 -> <accent like 'enviar'>
  *  15 -> <accent like 'continuar'>
  *  16 -> \<missing i>
  *@author Arnold Kraschinski
  */

class verbSpanish
{
public:
   verbSpanish();
   verbSpanish(const verbSpanish& v);
   virtual ~verbSpanish();
   verbSpanish& operator= (const verbSpanish& v);
   /** If two verbs are compared only the foreign form and the spanish form are compared */
   bool operator== (const verbSpanish& v) const;
   /** This overloaded == operator compares the verb to a QString.
    *  Only the spanish meaning is compared.
    */
   bool operator== (const QString& s) const;
   /** The spa/nisch forms of the verb are compared */
   bool operator< (const verbSpanish& v) const;
   /** Compares the verb objects completely, all forms and fields.
    */
   bool allEqual(verbSpanish v);
   /** tests if the fields of the object contain only empty strings
    */
   bool isEmpty() const;
   /** returns the foreign meaning of the verb
    */
   QString getForeign() const;
   /** sets the foreign meaning of the verb
    */
   void setForeign(const QString &s);
   /** returns the spanish meaning of the verb
    */
   QString getSpanish() const;
   /** sets the spanish meaning of the verb
    */
   void setSpanish(const QString &s);
   /** returns the gerund of the verb
    */
   QString getGerund();
   /** sets the gerund form to the string given in s
    */
   void setGerund(const QString &s);
   /** returns the particip of the verb
    */
   QString getPartizip();
   /** sets the participe to the string given in s
    */
   void setPartizip(const QString &s);
   /** returns if the verb belongs to one of the groups
    */
   bool isGroupVerb();
   /** returns the group number to which the verb belongs
    */
   int getGroup() { return group; }
   /** sets the field regular corresponding to b
    */
   void setGroup(const int g);
   /** returns the desired verb form indicated by time, person and type. This means
    *  with this function complex forms like a progressise or a perfect form can be
    *  retrieved.
    *  The parts of the form a stored like this:
    *  parts[0] the reflexive pronoun
    *  parts[1} the auxiliary verb
    *  parts[2] the verb form
    *  The return value 'bool' indicates if the form could be formed.
    */
   bool getForm(int t, int p, int typ, QString parts[]);
   /** returns the desired verb form indicated by time and person as a string
    */
   QString getForm(int t, int p);
   /** sets the verb form that is indicated by time and person
    */
   void setForm(int t, int p, QString s);
   /** The following function generates the regular verb forms. The forms can be
    *  generated time by time or all times in one step by using conjugateAll()
    */
   bool conjugateAll();
   /** returns if the verb is a reflexive one
    */
   bool isReflexiv() const;
   /** returns the reflexive pronoun that belongs to the person p
    */
   QString getRefPron(int p);
   /** tests if the string is an automatic generated Form, that means the last char is '#' */
   bool isAutoForm(QString& s) const;
private:
   bool conjugatePresente();
   bool conjugateImperfecto();
   bool conjugateIndefinido();
   bool conjugateFuturo();
   bool conjugateCondicional();
   bool conjugateSubPresente();
   bool conjugateSubPasado();
   bool conjugateImperativo();
   /** returns the verb stem
    */
   QString getStem() const;
   /** returns the ending of the verb
    */
   endings getEnding(bool& good);
   /** bildet die Formen, d.h. hängt die Endungen an den unveränderlichen
    *  Teil an.
    *  Die Form muss bisher ein leerer String sein. Anderenfalls wird angenommen, dass
    *  bereits eine gültige Form vorliegt und diese Form eine unregelmäßige Form ist, die
    *  nicht überschrieben werden soll.
    */
   bool conjugateTime(const int t, const QString &s);
   /** Es wird verglichen, ob die beiden Strings gemeinsame Bestandteile haben. Also
    *  "gehen, laufen, springen" wird etwa mit "gehen, laufen" verglichen. Die Funktion
    *  gibt in so einem Fall 'true' zurück, auch wenn im zweiten String ein Teil
    *  fehlt. Das ist nötig, um zwei Verben als gleich zu erkennen, auch wenn bei einem
    *  mehr oder weniger deutsche Bedeutungen oder die Bedeutungen in anderer Reihenfolge
    *	 angegeben sind.
    */
   bool vergleich(const QString& s1, const QString& s2) const;
   /** Deletes the '#' character from autogenerated forms. */
   QString delAutoForm(QString s) const;
   /** does the changes for group verbs
    */
   bool groupVerb(QString &s, int time=-1, int person=-1);
   /** the verb in the foreign language
    */
   QString foreign;
   /** the spanish verb
    */
   QString spanish;
   /** the gerund form of the verb
    */
   QString gerund;
   /** the partizip form of the verb
    */
   QString partizip;
   /** the array for all the different forms of the verb
    */
   formArray forms;
   /** tells to which group the verb belongs
    */
   int group;
   /** tells if all verbforms are present or if some are missing.
    */
   bool conjugated;
   /** set to true if the class has found an error in the verb structure. */
   bool error;

   /** In this array all the different endings for all the different times
    *  are stored.
    */
   static endingsArray verbEndings;
   /** the reflexive pronouns
    */
   static QString refPron[PERSONEN];
public:
   /** The forms of the verb estar. They are needed for the gerund form.
    */
   static QString estar[MAX_TIEMPOS][PERSONEN];
   /** The forms of the verb haber. They are needed for perfect forms
    */
   static QString haber[MAX_TIEMPOS][PERSONEN];
   /** This array contains the names of the time forms as strings
    */
   static QString timeNames[MAX_TIEMPOS*MAX_SUBTYPES];
   /** This array contains the names of the different verb groups
    */
   static QString groupNames[MAX_GRUPPEN];
   static int maxTiempos;
   static int maxSubtypes;
   static int persons;
   static int maxForms;
   /** The language that is selected at the moment. This selection affects all the instances
     * of the class. */
   static QString language;
};

/** Very often a list of verbs is needed. This is the type definition of a
  * QValueList template with the verbSpanish type
  */
typedef QValueList<verbSpanish> spanishVerbList;

#endif