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_interior_local_cases.h"
00031 #include "ffpriv_genitive_stem.h"
00032 #include "ffutil.h"
00033 #include "ffregex.h"
00034 #include "ffpriv_plural_stem.h"
00035 #include "ffpriv_essive_stem.h"
00036 #include "ffcase.h"
00037 #include "ffpriv_single_letter.h"
00038
00039 static ffint32 ffpriv_general_illative(ffword* word, ffbool plural) {
00040 ffint32 err;
00041 ffword stem;
00042 ffchar end2[] = ".n";
00043 ffchar end3[] = "h.n";
00044
00045 if ((err = ffword_copy(word, &stem))) {
00046 return err;
00047 }
00048
00049 if (plural ) {
00050 stem.metadata.cg = 1;
00051 if ((err = ffpriv_plural_stem(&stem))) {
00052 ffword_delete(&stem);
00053 return err;
00054 }
00055 } else {
00056 if ((err = ffpriv_essive_stem(&stem))) {
00057 ffword_delete(&stem);
00058 return err;
00059 }
00060 }
00061
00062 if (ffpriv_is_vowel(ffstring_last(&stem.data))) {
00063
00064
00065
00066 if (ffregex_match_ci("^.*((aa|ää|ee|ii|oo|öö|uu|yy)|[yöäuoae]i|äy|au|yö|öy|uo|ou|ie|eu|iu)$", &stem.data)) {
00067 if (plural ) {
00068 end3[1] = ffstring_last(&stem.data);
00069 ffword_swap_delete(&stem, word);
00070 return ffstring_append(&word->data, end3);
00071
00072 } else {
00073 if (stem.data.len < 4 ) {
00074 end3[1] = ffstring_last(&stem.data);
00075 ffword_swap_delete(&stem, word);
00076 return ffstring_append(&word->data, end3);
00077 } else {
00078 ffword_swap_delete(&stem, word);
00079 return ffstring_append(&word->data, "seen");
00080 }
00081 }
00082 }
00083 end2[0] = ffstring_last(&stem.data);
00084 ffword_swap_delete(&stem, word);
00085 return ffstring_append(&word->data, end2);
00086
00087 } else {
00088 end2[0] = ffstring_last(&stem.data);
00089 ffword_swap_delete(&stem, word);
00090 return ffstring_append(&word->data, end2);
00091 }
00092 }
00093
00094 ffint32 ffpriv_inessive_singular(ffword* word) {
00095 ffint32 err;
00096
00097 if (word->data.len < 2) {
00098 return ffpriv_single_letter(word, FFCASE_INESSIVE, FFCOUNT_SINGULAR);
00099 }
00100
00101 if ((err = ffpriv_genitive_stem(word))) {
00102 return err;
00103 }
00104
00105 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ssa", "ssä"));
00106 }
00107
00108 ffint32 ffpriv_inessive_plural(ffword* word) {
00109 ffint32 err;
00110
00111 if (word->data.len < 2) {
00112 return ffpriv_single_letter(word, FFCASE_INESSIVE, FFCOUNT_PLURAL);
00113 }
00114
00115 word->metadata.cg = 0;
00116
00117 if ((err = ffpriv_plural_stem(word))) {
00118 return err;
00119 }
00120
00121 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ssa", "ssä"));
00122 }
00123
00124
00125 ffint32 ffpriv_elative_singular(ffword* word) {
00126 ffint32 err;
00127
00128 if (word->data.len < 2) {
00129 return ffpriv_single_letter(word, FFCASE_ELATIVE, FFCOUNT_SINGULAR);
00130 }
00131
00132 if ((err = ffpriv_genitive_stem(word))) {
00133 return err;
00134 }
00135
00136 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "sta", "stä"));
00137 }
00138
00139 ffint32 ffpriv_elative_plural(ffword* word) {
00140 ffint32 err;
00141
00142 if (word->data.len < 2) {
00143 return ffpriv_single_letter(word, FFCASE_ELATIVE, FFCOUNT_PLURAL);
00144 }
00145
00146 word->metadata.cg = 0;
00147 if ((err = ffpriv_plural_stem(word))) {
00148 return err;
00149 }
00150
00151 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "sta", "stä"));
00152 }
00153
00154
00155 ffint32 ffpriv_illative_singular(ffword* word) {
00156
00157 if (word->data.len < 2) {
00158 return ffpriv_single_letter(word, FFCASE_ILLATIVE, FFCOUNT_SINGULAR);
00159 }
00160
00161 return ffpriv_general_illative(word, 0);
00162 }
00163
00164 ffint32 ffpriv_illative_plural(ffword* word) {
00165
00166 if (word->data.len < 2) {
00167 return ffpriv_single_letter(word, FFCASE_ILLATIVE, FFCOUNT_PLURAL);
00168 }
00169
00170 return ffpriv_general_illative(word, 1);
00171 }
00172