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_general_local_cases.h"
00031 #include "ffpriv_genitive_stem.h"
00032 #include "ffpriv_partitive_stem.h"
00033 #include "ffpriv_essive_stem.h"
00034 #include "ffpriv_plural_stem.h"
00035 #include "ffregex.h"
00036 #include "ffutil.h"
00037 #include "ffpriv_single_letter.h"
00038
00039 ffint32 ffpriv_partitive_singular(ffword* word) {
00040 ffint32 err;
00041
00042 if (word->data.len < 2) {
00043 return ffpriv_single_letter(word, FFCASE_PARTITIVE, FFCOUNT_SINGULAR);
00044 }
00045
00046 if ((err = ffpriv_partitive_stem(word))) {
00047 return err;
00048 }
00049
00050
00051
00052 if (ffstring_tail_equals_ci(&word->data, 2, "ea") || ffstring_tail_equals_ci(&word->data, 2, "eä")) {
00053 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00054 }
00055
00056 if (ffpriv_is_consonant(ffstring_last(&word->data)) || ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &word->data)) {
00057 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ta", "tä"));
00058 } else {
00059 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00060 }
00061 }
00062
00063 ffint32 ffpriv_partitive_plural(ffword* word) {
00064 ffint32 err;
00065 ffword stem;
00066
00067 if (word->data.len < 2) {
00068 return ffpriv_single_letter(word, FFCASE_PARTITIVE, FFCOUNT_PLURAL);
00069 }
00070
00071 if ((err = ffword_copy(word, &stem))) {
00072 return err;
00073 }
00074
00075 stem.metadata.cg = 1;
00076
00077 if ((err = ffpriv_plural_stem(&stem))) {
00078 ffword_delete(&stem);
00079 return err;
00080 }
00081
00082
00083
00084
00085 if(stem.metadata.loan) {
00086 ffword_swap_delete(&stem,word);
00087 return ffstring_rfe(&word->data, 2, ffpriv_vowel_harmony(&word->data, "eja", "ejä"));
00088 }
00089
00090
00091 if (ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &stem.data) && (
00092 ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][^aeiouyåäöÅÄÖ]+[aeiouyåäöÅÄÖ][^aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &word->data) ||
00093 ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &word->data) ||
00094 ffpriv_is_consonant(ffstring_last(&word->data)))) {
00095 ffword_swap_delete(&stem,word);
00096 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ta", "tä"));
00097 } else {
00098 if (ffpriv_is_vowel( stem.data.str[stem.data.len - 2] )) {
00099 ffword_swap_delete(&stem,word);
00100 return ffstring_rfe(&word->data, 1, ffpriv_vowel_harmony(&word->data, "ja", "jä"));
00101 } else {
00102 ffword_swap_delete(&stem,word);
00103 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00104 }
00105 }
00106 }
00107
00108 ffint32 ffpriv_essive_singular(ffword* word) {
00109 ffint32 err;
00110
00111 if (word->data.len < 2) {
00112 return ffpriv_single_letter(word, FFCASE_ESSIVE, FFCOUNT_SINGULAR);
00113 }
00114
00115 if ((err = ffpriv_essive_stem(word))) {
00116 return err;
00117 }
00118
00119 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "na", "nä"));
00120 }
00121
00122 ffint32 ffpriv_essive_plural(ffword* word) {
00123 ffint32 err;
00124 word->metadata.cg = 1;
00125
00126 if (word->data.len < 2) {
00127 return ffpriv_single_letter(word, FFCASE_ESSIVE, FFCOUNT_PLURAL);
00128 }
00129
00130 if ((err = ffpriv_plural_stem(word))) {
00131 return err;
00132 }
00133
00134 return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "na", "nä"));;
00135 }
00136
00137 ffint32 ffpriv_translative_singular(ffword* word) {
00138 ffint32 err;
00139
00140 if (word->data.len < 2) {
00141 return ffpriv_single_letter(word, FFCASE_TRANSLATIVE, FFCOUNT_SINGULAR);
00142 }
00143
00144 if ((err = ffpriv_genitive_stem(word))) {
00145 return err;
00146 }
00147
00148 return ffstring_append(&word->data,"ksi");
00149 }
00150
00151 ffint32 ffpriv_translative_plural(ffword* word) {
00152 ffint32 err;
00153
00154 if (word->data.len < 2) {
00155 return ffpriv_single_letter(word, FFCASE_TRANSLATIVE, FFCOUNT_PLURAL);
00156 }
00157
00158 if ((err = ffpriv_plural_stem(word))) {
00159 return err;
00160 }
00161
00162 return ffstring_append(&word->data,"ksi");
00163 }