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

ffpriv_general_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_general_local_cases.c Implements functions for inflecting
00027  * words in general local cases. They are declared in ffpriv_general_local_cases.c.
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  
00038 ffint32 ffpriv_partitive_singular(ffword* word)
00039 {
00040   ffint32 err;
00041 
00042 
00043   if ( (err = ffpriv_partitive_stem(word)) ) {
00044     return err;
00045   }
00046 
00047   /* TODO: Version 2+n, update to multiple return vales */
00048 
00049   if ( ffstring_tail_equals_ci(&word->data, 2, "ea") || ffstring_tail_equals_ci(&word->data, 2, "eä")) {
00050        return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00051   }
00052 
00053   if ( ffpriv_is_consonant(ffstring_last(&word->data)) || ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &word->data) ) {
00054     return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "ta", "tä"));
00055   } else {
00056     return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "a", "ä"));
00057   }
00058 }
00059 
00060 ffint32 ffpriv_partitive_plural(ffword* word)
00061 {
00062   ffword stem;
00063   ffstring_copy(&word->data,&stem.data);
00064   stem.metadata = word->metadata;
00065   stem.metadata.cg = 1;
00066   ffpriv_plural_stem(&stem);
00067 
00068   if (
00069     ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &stem.data) && (
00070       ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][^aeiouyåäöÅÄÖ]+[aeiouyåäöÅÄÖ][^aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &word->data) ||
00071       ffregex_match_ci("^.*[aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]$", &word->data) ||
00072       ffpriv_is_consonant(ffstring_last(&word->data)) /* TODO RELIC CONSONANT aND LOAN || */
00073       )
00074    ) {
00075      ffstring_append(&stem.data, ffpriv_vowel_harmony(&stem.data, "ta", "tä"));
00076      ffstring_delete(&word->data);
00077      word->data = stem.data;
00078      return 0;
00079   } else {
00080     if ( ffpriv_is_vowel( stem.data.str[stem.data.len - 2] ) ) {
00081        ffstring_rfe(&stem.data, 1, ffpriv_vowel_harmony(&stem.data, "ja", "jä") );
00082        ffstring_delete(&word->data);
00083        word->data = stem.data;
00084        return 0;
00085 
00086     } else {
00087       ffstring_append(&stem.data, ffpriv_vowel_harmony(&stem.data, "a", "ä") );
00088       ffstring_delete(&word->data);
00089       word->data = stem.data;
00090       return 0;
00091 
00092     }
00093 
00094   }
00095 
00096 
00097 }
00098 
00099 ffint32 ffpriv_essive_singular(ffword* word)
00100 {
00101   ffint32 err;
00102   
00103   if ( (err = ffpriv_essive_stem(word)) ) {
00104     
00105     return err;
00106   }
00107   
00108   return ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "na", "nä"));
00109 }
00110 
00111 ffint32 ffpriv_essive_plural(ffword* word)
00112 {
00113   word->metadata.cg = 1;
00114   ffpriv_plural_stem(word);
00115   ffstring_append(&word->data, ffpriv_vowel_harmony(&word->data, "na", "nä"));
00116   return 0;
00117 }
00118 
00119 ffint32 ffpriv_translative_singular(ffword* word)
00120 {
00121   ffint32 err;
00122   
00123   if ( (err = ffpriv_genitive_stem(word)) ) {
00124     return err;
00125   } else {
00126     return ffstring_append(&word->data,"ksi");
00127   }
00128 }
00129 
00130 ffint32 ffpriv_translative_plural(ffword* word)
00131 {
00132   ffpriv_plural_stem(word);
00133   ffstring_append(&word->data,"ksi");
00134   return 0;
00135 }

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