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

ffpriv_ss_abnormal.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_ss_abnormal.c Contains the exception list for words that end in s
00027  * and behave abnormally, and implements the functions for getting information
00028  * from it with binary search. The functions are declared in ffpriv_ss_abnormal.h.
00029  */
00030 
00031 #include "ffpriv_ss_abnormal.h"
00032 #include "ffstring.h"
00033 
00034 #define SS_LIST_LEN 107
00035 
00036 static ffchar* ss_list[SS_LIST_LEN][2] = {
00037   {"ahdas", "ahtaa"},
00038   {"allas", "altaa"},
00039   {"ahnas", "ahnaa"},
00040   {"altis", "alttii"},
00041   {"armas", "armaa"},
00042   {"aulis", "aulii"},
00043   {"autuas", "autuaa"},
00044   {"hammas", "hampaa"},
00045   {"harras", "hartaa"},
00046   {"hauras", "hauraa"},
00047   {"hidas", "hitaa"},
00048   {"hirvas", "hirvaa"},
00049   {"ies", "ikee"},
00050   {"kangas", "kankaa"},
00051   {"kallis", "kallii"},
00052   {"kalvas", "kalvaa"},
00053   {"karsas", "karsaa"},
00054   {"karvas", "karvaa"},
00055   {"katras", "katraa"},
00056   {"kaunis", "kaunii"},
00057   {"kauris", "kaurii"},
00058   {"keidas", "keitaa"},
00059   {"kernas", "kernaa"},
00060   {"kinnas", "kintaa"},
00061   {"kiivas", "kiivaa"},
00062   {"kirves", "kirvee"},
00063   {"kitsas", "kitsaa"},
00064   {"kiuas", "kiukaa"},
00065   {"koiras", "koiraa"},
00066   {"kokelas", "kokelaa"},
00067   {"kuhilas", "kuhilaa"},
00068   {"kuningas", "kuninkaa"},
00069   {"kunnas", "kunnaa"},
00070   {"kuulas", "kuulaa"},
00071   {"kuvaus", "kuvaukse"},
00072   {"lammas", "lampaa"},
00073   {"lipas", "lippaa"},
00074   {"lounas", "lounaa"},
00075   {"lunnas", "lunnaa"},
00076   {"mallas", "maltaa"},
00077   {"marras", "martaa"},
00078   {"mies", "miehe"},
00079   {"naaras", "naaraa"},
00080   {"nauris", "naurii"},
00081   {"opas", "oppaa"},
00082   {"oas", "okaa"},
00083   {"oinas", "oinaa"},
00084   {"olas", "olaa"},
00085   {"oppilas", "oppilaa"},
00086   {"oras", "oraa"},
00087   {"parras", "partaa"},
00088   {"paljas", "paljaa"},
00089   {"paras", "parhaa"},
00090   {"patsas", "patsaa"},
00091   {"pensas", "pensaa"},
00092   {"piiras", "piiraa"},
00093   {"porras", "portaa"},
00094   {"porsas", "porsaa"},
00095   {"potilas", "potilaa"},
00096   {"pudas", "putaa"},
00097   {"puhdas", "puhtaa"},
00098   {"ratas", "rattaa"},
00099   {"raavas", "raavaa"},
00100   {"rahvas", "rahvaa"},
00101   {"raitis", "raittii"},
00102   {"raihnas", "raihnaa"},
00103   {"rastas", "rastaa"},
00104   {"ratsas", "ratsaa"},
00105   {"rengas", "renkaa"},
00106   {"reipas", "reippaa"},
00107   {"rietas", "riettaa"},
00108   {"ruhtinas", "ruhtinaa"},
00109   {"ruis", "rukii"},
00110   {"runsas", "runsaa"},
00111   {"ruumis", "ruumii"},
00112   {"saapas", "saappaa"},
00113   {"saalis", "saalii"},
00114   {"sairas", "sairaa"},
00115   {"sees", "sekee"},
00116   {"sotilas", "sotilaa"},
00117   {"tahdas", "tahtaa"},
00118   {"taivas", "taivaa"},
00119   {"tehdas", "tehtaa"},
00120   {"teuras", "teuraa"},
00121   {"tiivis", "tiivii"},
00122   {"toipilas", "toipilaa"},
00123   {"tupas", "tuppaa"},
00124   {"tuores", "tuoree"},
00125   {"turilas", "turilaa"},
00126   {"tursas", "tursaa"},
00127   {"tyyris", "tyyrii"},
00128   {"uros", "uroo"},
00129   {"uuras", "uuraa"},
00130   {"valpas", "valppaa"},
00131   {"varas", "varkaa"},
00132   {"varras", "vartaa"},
00133   {"varvas", "varpaa"},
00134   {"valas", "valaa"},
00135   {"valmis", "valmii"},
00136   {"vauras", "vauraa"},
00137   {"vehmas", "vehmaa"},
00138   {"vilpas", "vilppaa"},
00139   {"vieras", "vieraa"},
00140   {"viisas", "viisaa"},
00141   {"vitsas", "vitsaa"},
00142   {"vuolas", "vuolaa"},
00143   {"äes", "äkee"},
00144 };
00145 
00146 ffint32 ffpriv_ss_genitive(ffword* word)
00147 {
00148   ffint32 result = 0;
00149   int high, low, i;
00150 
00151   for(high = SS_LIST_LEN-1, low = -1; high - low > 1; ) {
00152     i = (high + low) / 2;
00153     if(ffstring_compare(&word->data, ss_list[i][0]) < 1)
00154       high = i;
00155     else
00156       low = i;
00157   }
00158   if(ffstring_equals(&word->data, ss_list[high][0])) {
00159     if((result = ffstring_delete(&word->data)))
00160       return result;
00161     else if((result = ffstring_create(ss_list[high][1], &word->data)))
00162       return result;
00163     else return 1;  
00164   }  
00165   else
00166     return 0;
00167 }
00168 

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