Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

ffpriv_interior_local_cases.c

Go to the documentation of this file.
00001 /*
00002  * finflect - Algorithms and tools for inflecting Finnish nouns
00003  * Copyright (C) 2004, 2005  The FinFlect Team
00004  * 
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  * 
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  * 
00019  * 
00020  * For the complete legal text of the GNU Lesser General Public License,
00021  * see the file LICENSE. For a complete list of authors and copyright
00022  * holders, see the file AUTHORS.
00023  */
00024 
00025 /**
00026  * @file ffpriv_interior_local_cases.c Implements functions for inflecting
00027  * words in interior local cases. They are declared in ffpriv_interior_local_cases.h.
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     /** TODO: Relic
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 

Generated on Thu Jun 2 23:16:59 2005 for FinFlect by  doxygen 1.4.2