00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "ffpriv_basic_cases.h"
00031 #include "ffpriv_genitive_stem.h"
00032 #include "ffpriv_partitive_stem.h"
00033 #include "ffpriv_plural_stem.h"
00034 #include "ffpriv_ie_vowel_change.h"
00035 #include "ffutil.h"
00036 #include "ffregex.h"
00037 #include "ffcase.h"
00038 #include "ffpriv_single_letter.h"
00039
00040 ffint32 ffpriv_nominative_singular(ffword* word) {
00041 return 0;
00042 }
00043
00044 ffint32 ffpriv_nominative_plural(ffword* word) {
00045 ffint32 err;
00046
00047 if (word->data.len < 2) {
00048 return ffpriv_single_letter(word, FFCASE_NOMINATIVE, FFCOUNT_PLURAL);
00049 }
00050
00051 if ((err = ffpriv_genitive_stem(word))) {
00052 return err;
00053 }
00054
00055 return ffstring_append(&word->data,"t");
00056 }
00057
00058 ffint32 ffpriv_genitive_singular(ffword* word) {
00059 ffint32 err;
00060
00061 if (word->data.len < 2) {
00062 return ffpriv_single_letter(word, FFCASE_GENITIVE, FFCOUNT_SINGULAR);
00063 }
00064
00065 if ((err = ffpriv_genitive_stem(word))) {
00066 return err;
00067 }
00068
00069 return ffstring_append(&word->data,"n");
00070 }
00071
00072 ffint32 ffpriv_genitive_plural(ffword* word) {
00073 ffint32 err;
00074
00075 if (word->data.len < 2) {
00076 return ffpriv_single_letter(word, FFCASE_GENITIVE, FFCOUNT_PLURAL);
00077 }
00078
00079
00080
00081
00082
00083
00084 word->metadata.cg = 1;
00085
00086 if(!word->metadata.loan) {
00087
00088
00089
00090
00091 ffword orig;
00092
00093
00094
00095
00096
00097 if((err = ffword_copy(word, &orig))) {
00098 return err;
00099 }
00100
00101
00102
00103
00104 if((err = ffpriv_plural_stem(word))) {
00105 ffword_delete(&orig);
00106 return 0;
00107 }
00108
00109
00110
00111
00112 if(word->metadata.loan) {
00113 ffword_delete(&orig);
00114 return ffstring_rfe(&word->data, 2, "ien");
00115 }
00116
00117
00118
00119
00120 if (ffpriv_is_vowel( ffstring_last(&orig.data))) {
00121
00122
00123
00124
00125
00126
00127 if(ffregex_match("^.*[bcdfghjklmnpqrstvwxz][aeiouyåäö]{2}$", &orig.data)) {
00128 ffword_delete(&orig);
00129 return ffstring_append(&word->data, "den");
00130 }
00131
00132
00133
00134
00135
00136
00137
00138 if(ffregex_match("^.*[aeiouyåäö][bcdfghjklmnpqrstvwxz]{1,2}[aeiouyåäö]{1,2}[vm][aä]$", &orig.data)) {
00139 ffword_delete(&orig);
00140 return ffstring_rfe(&word->data, 1, "ien");
00141 }
00142
00143
00144
00145
00146
00147
00148
00149
00150 if(ffregex_match("^.*[aeiouyåäö][bcdfghjklmnpqrstvwxz]{1,3}[aeiouyåäö][bcdfghjklmnpqrstvwxz]{1,2}[aä]$", &orig.data)
00151 && (!ffstring_tail_equals(&word->data, 2, "ji"))) {
00152 ffword_delete(&orig);
00153 return ffstring_append(&word->data, "den");
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 if(ffregex_match("^.*[aeouyäö]$", &orig.data)) {
00163 ffword_delete(&orig);
00164
00165 if(ffpriv_is_vowel(word->data.str[word->data.len - 2])) {
00166
00167
00168
00169
00170 return ffstring_rfe(&word->data, 1, "jen");
00171 }
00172
00173 return ffstring_append(&word->data, "en");
00174 }
00175
00176
00177
00178
00179
00180 if(ffstring_tail_equals(&word->data, 2, "ei")) {
00181 ffword_delete(&orig);
00182 return ffstring_rfe(&word->data, 2, "ien");
00183 }
00184 }
00185
00186
00187
00188
00189 if(ffstring_last_equals(&orig.data, 'i')) {
00190 ffword_delete(&orig);
00191 return ffstring_append(&word->data, "en");
00192 }
00193
00194
00195
00196
00197 if(ffregex_match("^.*[lnr]$", &orig.data)) {
00198 ffword_delete(&orig);
00199 return ffstring_append(&word->data, "en");
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 if(ffstring_last_equals(&orig.data, 's')) {
00211
00212 if((err = ffpriv_partitive_stem(&orig))) {
00213 ffword_delete(&orig);
00214 return err;
00215 }
00216
00217 if(ffstring_last_equals(&orig.data, 's')) {
00218 ffword_delete(&orig);
00219
00220 if(ffregex_match("^.*[bcdfghjklmnpqrstvwxz][aeiouyåäö]$", &word->data)) {
00221 return ffstring_append(&word->data, "en");
00222 } else if(ffregex_match("^.*[aeiouyåäö]{2}$", &word->data)) {
00223 return ffstring_append(&word->data, "den");
00224 }
00225 }
00226
00227 ffword_delete(&orig);
00228 return ffstring_append(&word->data, "en");
00229 }
00230
00231
00232
00233
00234 if(ffstring_last_equals(&orig.data, 't')) {
00235 ffword_delete(&orig);
00236
00237 if(ffregex_match("^.*(yi|öi|äi|ui|oi|ai|äy|au|yö|uo|ou|ie|ei|eu|iu|aa|ää|oo|öö|uu|yy|ee|ii)$", &word->data)) {
00238 return ffstring_append(&word->data, "den");
00239 } else {
00240 return ffstring_append(&word->data, "en");
00241 }
00242 }
00243
00244 ffword_delete(&orig);
00245 }
00246
00247
00248
00249
00250
00251 if((err = ffpriv_partitive_stem(word))) {
00252 return err;
00253 } else {
00254 return ffstring_append(&word->data, "en");
00255 }
00256
00257 }
00258