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
00041
00042
00043 if(ffpriv_ie_genitive(word) > 0) {
00044 return 0;
00045 }
00046
00047
00048 if(ffpriv_ss_genitive(word) > 0) {
00049 return 0;
00050 }
00051
00052
00053 if ( ffpriv_is_vowel( ffstring_last(&word->data) ) ) {
00054
00055 if (word->metadata.cg) {
00056 if ( ffstring_tail_equals_ci(&word->data, 3, "mpi") ) {
00057 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00058 }
00059 return 0;
00060 } else {
00061 if ( !ffstring_compare_tail_ci(&word->data, 3, "mpi") ) {
00062 return ffstring_rfe(&word->data, 2, ffpriv_vowel_harmony(&word->data, "ma", "mä"));
00063 }
00064 return ffpriv_consonant_gradation(&word->data, 1, 1);
00065 }
00066 }
00067
00068
00069 if ( ffstring_last_equals_ci(&word->data,'s') ) {
00070
00071 if (ffstring_tail_equals_ci(&word->data, 3, "ias") ) {
00072 return ffstring_rfe(&word->data, 1, "a");
00073 }
00074
00075 if (ffstring_tail_equals_ci(&word->data, 3, "iäs") ) {
00076 return ffstring_rfe(&word->data, 1, "ä");
00077 }
00078
00079 if (ffstring_tail_equals_ci(&word->data, 3, "kas") ) {
00080 return ffstring_rfe(&word->data, 2, "kaa");
00081 }
00082
00083 if (ffstring_tail_equals_ci(&word->data, 3, "käs") ) {
00084 return ffstring_rfe(&word->data, 2, "kää");
00085 }
00086
00087
00088
00089 if ( ffregex_match("^.*[aeiouyåäö][bcdfghjklmnpqrstvwxz][bcdfghjklmnpqrstvwxz]?[bcdfghjklmnpqrstvwxz]?[aeiouyåäöÅÄÖ][uy]s$", &word->data)
00090 && !ffstring_tail_equals_ci(&word->data, 3, "aus") ) {
00091 return ffstring_rfe(&word->data, 1, "de");
00092 }
00093
00094 return ffstring_rfe(&word->data, 1, "kse");
00095
00096 }
00097
00098
00099 if ( ffstring_last_equals_ci(&word->data,'n') ) {
00100
00101
00102
00103 if ( !ffstring_compare_ci(&word->data, "vasen") ) {
00104 if (word->metadata.cg) {
00105 return ffstring_rfe(&word->data, 1, "mpa");
00106 } else {
00107 return ffstring_rfe(&word->data, 1, "mma");
00108 }
00109 }
00110
00111 if (ffstring_tail_equals_ci(&word->data, 3, "nen") ) {
00112 return ffstring_rfe(&word->data, 3, "se");
00113 }
00114
00115 if (ffstring_tail_equals_ci(&word->data, 3, "ton") ) {
00116 return ffstring_rfe(&word->data, 2, "toma");
00117 }
00118
00119 if ( ffstring_tail_equals_ci(&word->data, 3, "tön") ) {
00120 return ffstring_rfe(&word->data, 2, "tömä");
00121 }
00122
00123
00124
00125
00126 if ( ffstring_tail_equals_ci(&word->data, 2, "in") ) {
00127 if ( !ffregex_match("^.*(ä|ka|va|lj|t|is)in$", &word->data) ) {
00128 if (word->metadata.cg) {
00129
00130 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "mpa", "mpä"));
00131 } else {
00132 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "mma", "mmä"));
00133 }
00134 }
00135 }
00136
00137
00138 return ffstring_rfe(&word->data, 1, "me");
00139 }
00140
00141
00142 if ( ffstring_last_equals_ci(&word->data,'l') || ffstring_last_equals_ci(&word->data,'r') ) {
00143
00144 return ffstring_append(&word->data,"e");
00145 }
00146
00147
00148 if ( ffstring_last_equals_ci(&word->data,'t') ) {
00149
00150 if ( ffstring_tail_equals_ci(&word->data, 2, "ät") ) {
00151 return ffstring_rfe(&word->data, 1, "ä");
00152 }
00153
00154
00155
00156 if ( !ffregex_match("^.*(((rr|ll|n)(u|t)t)|[^t]s(u|y))t$", &word->data) ) {
00157 return ffstring_rfe(&word->data, 2, "ee");
00158 }
00159
00160 if ( ffstring_tail_equals_ci(&word->data, 2, "ut") || ffstring_tail_equals_ci(&word->data, 2, "yt") ) {
00161 return ffstring_rfe(&word->data, 2, "e");
00162 }
00163 }
00164
00165
00166
00167 return ffstring_append(&word->data,"i");
00168
00169 }
00170