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

ffpriv_consonant_gradation.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_consonant_gradation.c Implements the consonant gradation function
00027  * defined in ffpriv_consonant_gradation.h.
00028  */
00029  
00030 #include "ffstring.h"
00031 #include "ffregex.h"
00032 #include "ffpriv_consonant_gradation.h"
00033 
00034 
00035 ffint32 ffpriv_consonant_gradation(ffstring* word, ffuint32 direction, ffuint32 type)
00036 {
00037   ffint32 err;
00038   ffstring t;
00039   
00040   if ( direction == 1 && type == 1 ) {
00041     if ( ffregex_match_ci("^.*(kk|pp|tt)[aeiouyåäöÅÄÖ]$", word) ) {
00042       err = ffstring_tail(word, 2, &t);
00043       if ( err ) { return err; }
00044       err = ffstring_rfe_ff(word, 3, &t);
00045       ffstring_delete(&t);
00046       return err;
00047     }
00048     
00049     if ( ffregex_match_ci("^.*[nlr]t[aeiouyåäöÅÄÖ]$", word) ) {
00050       return -!ffregex_replace_ci("(.)t(.)$", "${1}${1}${2}", word);
00051     }
00052     
00053     if ( ffregex_match_ci("^.*[aeiouyåäöÅÄÖ]t[aeiouyåäöÅÄÖ]$", word) ) {
00054       return -!ffregex_replace_ci("t(.)$", "d${1}", word);
00055     }
00056     
00057     if ( ffregex_match_ci("^.*mp[aeiouyåäöÅÄÖ]$", word) ) {
00058       return -!ffregex_replace_ci("p(.)$", "m${1}", word);
00059     }
00060     
00061     if ( ffregex_match_ci("^.*[lr]p[aeiouyåäöÅÄÖ]$", word) ) {
00062       return -!ffregex_replace_ci("p(.)$", "v${1}", word);
00063     }
00064     
00065     if ( ffregex_match_ci("^.*[aeiouyåäöÅÄÖ]p[aeiouyåäöÅÄÖ]$", word) ) {
00066       return -!ffregex_replace_ci("p(.)$", "v${1}", word);
00067     }
00068     
00069     if ( ffregex_match_ci("^.*[lr]k[aeiouyåäöÅÄÖ]$", word) ) {
00070       return -!ffregex_replace_ci("k(.)$", "${1}", word);
00071     }
00072     
00073     if ( ffregex_match_ci("^.*nk[aeiouyåäöÅÄÖ]$", word) ) {
00074       return -!ffregex_replace_ci("k(.)$", "g${1}", word);
00075     }
00076     
00077     if ( ffregex_match_ci("^.*ht[aeiouyåäöÅÄÖ]$", word) ) {
00078       return -!ffregex_replace_ci("t(.)$", "d${1}", word);
00079     }
00080     
00081     if ( ffregex_match_ci("^.[uy]k[uy]$", word) ) {
00082       return -!ffregex_replace_ci("k(.)$", "v${1}", word);
00083     }
00084     
00085     if ( ffregex_match_ci("^([aeiouyåäöÅÄÖ]|[^aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]+)k[aeiouyåäöÅÄÖ]$", word) ) {
00086       return -!ffregex_replace_ci("k(.)$", "${1}", word);
00087     }
00088     
00089   }
00090   
00091   
00092   
00093   return 0;
00094 }
00095 

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