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 
00037 static ffint32 ffpriv_general_illative(ffword* word, ffbool plural) 
00038 {
00039   ffword stem;
00040   ffchar end2[] = ".n";
00041   ffchar end3[] = "h.n";
00042   
00043   ffstring_copy(&word->data, &stem.data);
00044   stem.metadata = word->metadata;
00045   
00046   if ( plural ) {
00047     stem.metadata.cg = 1;
00048     ffpriv_plural_stem(&stem);
00049   } else {
00050     ffpriv_essive_stem(&stem);
00051   }
00052   
00053   if ( ffpriv_is_vowel(ffstring_last(&stem.data)) ) {
00054     /** TODO: Relic
00055      */
00056 
00057     if ( ffregex_match_ci("^.*((aa|ää|ee|ii|oo|öö|uu|yy)|[yöäuoae]i|äy|au|yö|öy|uo|ou|ie|eu|iu)$", &stem.data) ) {
00058 
00059       if ( plural ) {
00060         end3[1] = ffstring_last(&stem.data);
00061         ffstring_append(&stem.data, end3);
00062         ffstring_delete(&word->data);
00063         word->data = stem.data;
00064         return 0;
00065 
00066       } else {
00067 
00068         if ( stem.data.len < 4 ) {
00069           end3[1] = ffstring_last(&stem.data);
00070           ffstring_append(&stem.data, end3);
00071           ffstring_delete(&word->data);
00072           word->data = stem.data;
00073           return 0;
00074         } else {
00075           ffstring_append(&stem.data, "seen");
00076           ffstring_delete(&word->data);
00077           word->data = stem.data;
00078           return 0;
00079         }
00080       }
00081     }
00082 
00083     end2[0] = ffstring_last(&stem.data);
00084     ffstring_append(&stem.data, end2);
00085     ffstring_delete(&word->data);
00086     word->data = stem.data;
00087     return 0;
00088 
00089   } else {
00090     end2[0] = ffstring_last(&stem.data);
00091     ffstring_append(&stem.data, end2);
00092     ffstring_delete(&word->data);
00093     word->data = stem.data;
00094     return 0;
00095   }
00096 }
00097 
00098 ffint32 ffpriv_inessive_singular(ffword* word)
00099 {
00100   ffint32 err;
00101   
00102   if ( (err = ffpriv_genitive_stem(word)) ) {
00103     return err;
00104   } else {
00105     return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ssa", "ssä"));
00106   }
00107 }
00108 
00109 ffint32 ffpriv_inessive_plural(ffword* word)
00110 {
00111   word->metadata.cg = 0;
00112   ffpriv_plural_stem(word);
00113   ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ssa", "ssä"));
00114   return 0;
00115 }
00116 
00117 
00118 ffint32 ffpriv_elative_singular(ffword* word)
00119 {
00120   ffint32 err;
00121   
00122   if ( (err = ffpriv_genitive_stem(word)) ) {
00123     return err;
00124   } else {
00125     return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "sta", "stä"));
00126   }
00127 }
00128 
00129 ffint32 ffpriv_elative_plural(ffword* word)
00130 {
00131   word->metadata.cg = 0;
00132   ffpriv_plural_stem(word);
00133   ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "sta", "stä"));
00134   return 0;
00135 }
00136 
00137 
00138 ffint32 ffpriv_illative_singular(ffword* word)
00139 {
00140   ffpriv_general_illative(word, 0);
00141   return 0;
00142 }
00143 
00144 ffint32 ffpriv_illative_plural(ffword* word)
00145 {
00146   
00147   ffpriv_general_illative(word, 1);
00148   return 0;
00149 }
00150 

Generated on Sun May 15 21:50:47 2005 for FinFlect by  doxygen 1.4.1