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_genitive_stem.h"
00031 #include "ffutil.h"
00032 #include "ffregex.h"
00033 #include "ffpriv_consonant_gradation.h"
00034 #include "ffpriv_ie_vowel_change.h"
00035 #include "ffpriv_ss_abnormal.h"
00036
00037 ffint32 ffpriv_genitive_stem(ffword* word) {
00038
00039
00040 ffint32 err;
00041
00042 if(ffpriv_ie_genitive(word) > 0) {
00043 return 0;
00044 }
00045
00046
00047 if(ffpriv_ss_genitive(word) > 0) {
00048 return 0;
00049 }
00050
00051
00052 if (ffpriv_is_vowel( ffstring_last(&word->data))) {
00053 if (ffstring_last_equals_ci(&word->data,'e')) {
00054
00055 if (!ffstring_tail_equals_ci(&word->data, 2, "ee")
00056 && !ffstring_tail_equals_ci(&word->data, 3, "ope")
00057 && !ffstring_tail_equals_ci(&word->data, 5, "kolme")
00058 && (!ffstring_tail_equals_ci(&word->data, 3, "lle") || ffregex_match("([^nk]a|ii|[^p]e|uo)lle$", &word->data))) {
00059
00060 if ((err = ffpriv_consonant_gradation(&word->data, 2, 1))) {
00061 return err;
00062 }
00063
00064 word->metadata.relic = 1;
00065 return ffstring_append(&word->data,"e");
00066 }
00067 }
00068
00069 if (word->metadata.cg) {
00070 if (ffstring_tail_equals_ci(&word->data, 3, "mpi")) {
00071 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00072 }
00073 return 0;
00074 } else {
00075 if (!ffstring_compare_tail_ci(&word->data, 3, "mpi")) {
00076 return ffstring_rfe(&word->data, 2, ffpriv_vowel_harmony(&word->data, "ma", "mä"));
00077 }
00078 return ffpriv_consonant_gradation(&word->data, 1, 1);
00079 }
00080 }
00081
00082
00083 if (ffstring_last_equals_ci(&word->data,'s')) {
00084 if (ffstring_tail_equals_ci(&word->data, 3, "ias")) {
00085 return ffstring_rfe(&word->data, 1, "a");
00086 }
00087
00088 if (ffstring_tail_equals_ci(&word->data, 3, "iäs")) {
00089 return ffstring_rfe(&word->data, 1, "ä");
00090 }
00091
00092 if (ffstring_tail_equals_ci(&word->data, 3, "kas")) {
00093 return ffstring_rfe(&word->data, 2, "kaa");
00094 }
00095
00096 if (ffstring_tail_equals_ci(&word->data, 3, "käs")) {
00097 return ffstring_rfe(&word->data, 2, "kää");
00098 }
00099
00100
00101
00102 if (ffregex_match("^.*[aeiouyåäö][bcdfghjklmnpqrstvwxz][bcdfghjklmnpqrstvwxz]?[bcdfghjklmnpqrstvwxz]?[aeiouyåäöÅÄÖ][uy]s$", &word->data)
00103 && !ffstring_tail_equals_ci(&word->data, 3, "aus") ) {
00104 return ffstring_rfe(&word->data, 1, "de");
00105 }
00106
00107 return ffstring_rfe(&word->data, 1, "kse");
00108
00109 }
00110
00111
00112 if (ffstring_last_equals_ci(&word->data,'n')) {
00113
00114
00115 if (!ffstring_compare_ci(&word->data, "vasen")) {
00116 if (word->metadata.cg) {
00117 return ffstring_rfe(&word->data, 1, "mpa");
00118 } else {
00119 return ffstring_rfe(&word->data, 1, "mma");
00120 }
00121 }
00122
00123 if (ffstring_tail_equals_ci(&word->data, 3, "nen")) {
00124 return ffstring_rfe(&word->data, 3, "se");
00125 }
00126
00127 if (ffstring_tail_equals_ci(&word->data, 4, "ston")) {
00128
00129 return ffstring_rfe(&word->data, 1, "ma");
00130 }
00131 if (ffstring_tail_equals_ci(&word->data, 3, "ton")) {
00132 return ffstring_rfe(&word->data, 2, "toma");
00133 }
00134
00135 if (ffstring_tail_equals_ci(&word->data, 4, "stön")) {
00136
00137 return ffstring_rfe(&word->data, 1, "mä");
00138 }
00139 if (ffstring_tail_equals_ci(&word->data, 3, "tön")) {
00140 return ffstring_rfe(&word->data, 2, "tömä");
00141 }
00142
00143
00144
00145
00146 if (ffstring_tail_equals_ci(&word->data, 2, "in")) {
00147 if (!ffregex_match("^.*(ä|ka|va|lj|t|is|nn)in$", &word->data)) {
00148 if (word->metadata.cg) {
00149
00150 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "mpa", "mpä"));
00151 } else {
00152 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "mma", "mmä"));
00153 }
00154 }
00155 }
00156
00157
00158 return ffstring_rfe(&word->data, 1, "me");
00159 }
00160
00161
00162 if (ffstring_last_equals_ci(&word->data,'l') || ffstring_last_equals_ci(&word->data,'r')) {
00163 if ((err = ffpriv_consonant_gradation(&word->data, 2, 1))) {
00164 return err;
00165 }
00166 return ffstring_append(&word->data,"e");
00167 }
00168
00169
00170 if (ffstring_last_equals_ci(&word->data,'t')) {
00171 if (ffstring_tail_equals_ci(&word->data, 2, "ät")) {
00172 return ffstring_rfe(&word->data, 1, "ä");
00173 }
00174
00175
00176
00177
00178
00179
00180 if (ffstring_tail_equals_ci(&word->data, 2, "ut") || ffstring_tail_equals_ci(&word->data, 2, "yt")) {
00181
00182
00183
00184
00185 if (ffregex_match("^.*(((rr|ll|n)(u|y))|[^t]s(u|y))t$", &word->data)) {
00186 return ffstring_rfe(&word->data, 2, "ee");
00187 }
00188
00189
00190
00191
00192
00193 return ffstring_rfe(&word->data, 1, "e");
00194 }
00195 }
00196
00197
00198 word->metadata.loan = 1;
00199 return ffstring_append(&word->data,"i");
00200
00201 }
00202