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

ffpriv_essive_stem.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_essive_stem.c Implements the essive stem function declared in
00027  * ffpriv_essive_stem.h.
00028  */
00029 
00030 #include "ffpriv_essive_stem.h"
00031 #include "ffutil.h"
00032 #include "ffstring.h"
00033 #include "ffpriv_genitive_stem.h"
00034 #include "ffpriv_ie_vowel_change.h"
00035 #include "ffregex.h"
00036 
00037 ffint32 ffpriv_essive_stem(ffword* word) {
00038   /*@@v ESSb-02 **/
00039   ffword copy;
00040   ffint32 err;
00041 
00042   if ((err = ffword_copy(word, &copy))) {
00043     return err;
00044   }
00045 
00046   if (ffpriv_is_vowel(ffstring_last(&word->data))) {
00047 
00048     if (ffstring_last_equals_ci(&word->data,'e')) {
00049 
00050       /* copy = genitive stem */
00051       if ((err = ffpriv_genitive_stem(&copy))) { return err; }
00052 
00053       if (copy.metadata.relic) {
00054         ffword_swap_delete(&copy, word);
00055         return /*@GENb*/ 0;
00056       } else {
00057         ffword_delete(&copy);
00058         return /*@NOMb*/ 0;
00059       }
00060 
00061     } else if (ffstring_last_equals_ci(&word->data,'i')) {
00062 
00063       if(ffpriv_ie_partitive(&copy) > 0) {
00064 
00065         if (ffpriv_is_consonant(ffstring_last(&copy.data))) {
00066           ffword_swap_delete(&copy, word);
00067           return ffstring_append(&word->data, "e"); /*@@v ESSb--01 **/
00068         } else {
00069           ffword_swap_delete(&copy, word); /*@@v ESSb--02 **/
00070           return 0;
00071         }
00072 
00073         /* TODO: -ksi */
00074         if (ffregex_match("^.*([aeiouyåäö]mi|(t|p)s)i$", &word->data)) {
00075           if ((err = ffpriv_genitive_stem(word))) {
00076             return err;
00077           }
00078           ffword_delete(&copy);
00079           return /*@GENb*/ 0; /*@@v ESSb--03 **/
00080         }
00081 
00082         ffword_delete(&copy);
00083         return /*@NOMb*/ 0; /*@@v ESSb--04 **/
00084       }
00085     }
00086 
00087     ffword_delete(&copy);
00088     return /*@NOMb*/ 0;
00089 
00090   } else {
00091     /*
00092      * Words not ending in a vowel
00093      */
00094     copy.metadata.cg = 0;
00095 
00096     if ((err = ffpriv_genitive_stem(&copy))) {
00097       ffword_delete(&copy);
00098       return err;
00099     }
00100 
00101     if (ffstring_tail_equals_ci(&copy.data, 3, "mma")) {
00102       ffword_swap_delete(&copy, word);
00103       return /*@GENb*/ ffstring_rfe(&word->data, 2, "pa"); /*@@v ESSb--06 **/
00104     }
00105 
00106     if (ffstring_last_equals_ci(&word->data,'s') && ffstring_tail_equals_ci(&copy.data, 2, "de")) {
00107       ffword_delete(&copy);
00108       return /*@NOMb*/ ffstring_rfe(&word->data, 1, "te"); /*@@v ESSb--07 **/
00109     }
00110 
00111     if ((ffstring_last_equals_ci(&word->data,'s') || ffstring_last_equals_ci(&word->data,'t')) && ffstring_tail_equals_ci(&copy.data, 3, "nne")) {
00112       ffword_delete(&copy);
00113       return /*@NOMb*/ ffstring_rfe(&word->data, 1, "nte"); /*@@v ESSb--08 **/
00114     }
00115 
00116     ffword_swap_delete(&copy, word);
00117     return /*@GENb*/ 0; /*@@v ESSb--09 **/
00118 
00119   }
00120 }
00121 
00122 /*
00123  
00124         if { [isvokaali [last $word]] } {
00125         
00126 # Vowel change
00127                 set ie [vokaalinvaihtelu $word par]
00128                 if { $ie != ""} {
00129                         regsub t?\[aä\]$ $ie "" ie
00130                         
00131                         if { [regexp ${v}mi$ $word] } {
00132                                 return [general_genitive_stem $word 0 $ops]
00133 }
00134                         
00135                         if { [last $word 3] == "ksi" } {
00136                                 return [general_genitive_stem $word 1 $ops]
00137 }
00138                         
00139                         if { [last $word 3] == "psi" || [last $word 3] == "tsi" } {
00140                                 return [general_genitive_stem $word 0 $ops]
00141 }
00142                         
00143                         if { [isvokaali [last $ie]] } {
00144                                 return $ie
00145 }
00146                         return ${ie}e
00147 }
00148                 
00149                 if { ![is loan $ops] } {
00150 # Relic consonant
00151                         set rel [relic_consonant $word gen]
00152                         if { $rel != "" } {
00153                                 return $rel             
00154 }}
00155                 return $word
00156 } else {
00157 */

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