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

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