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

finflect.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 finflect.c Implementations for the public API functions defined in finflect.h.
00027  */ 
00028 
00029 #include <stdlib.h>
00030 #include <string.h>
00031 #include <strings.h>
00032 
00033 #include "finflect.h"
00034 #include "ffpriv_basic_cases.h"
00035 #include "ffpriv_general_local_cases.h"
00036 #include "ffpriv_exterior_local_cases.h"
00037 #include "ffpriv_interior_local_cases.h"
00038 #include "ffpriv_means_cases.h"
00039 
00040 ffchar* ff_inflect(const ffchar* word, ffcase thecase, ffint32 count)
00041 {
00042   switch(thecase) {
00043   case FFCASE_NOMINATIVE:
00044     if(count == 1)
00045       return ff_nominative_singular(word);
00046     else
00047       return ff_nominative_plural(word);
00048     break;
00049   case FFCASE_GENITIVE:
00050     if(count == 1)
00051       return ff_genitive_singular(word);
00052     else
00053       return ff_genitive_plural(word);
00054     break;
00055   case FFCASE_PARTITIVE:
00056     if(count == 1)
00057       return ff_partitive_singular(word);
00058     else
00059       return ff_partitive_plural(word);
00060     break;
00061   case FFCASE_ESSIVE:
00062     if(count == 1)
00063       return ff_essive_singular(word);
00064     else
00065       return ff_essive_plural(word);
00066     break;
00067   case FFCASE_TRANSLATIVE:
00068     if(count == 1)
00069       return ff_translative_singular(word);
00070     else
00071       return ff_translative_plural(word);
00072     break;
00073   case FFCASE_INESSIVE:
00074     if(count == 1)
00075       return ff_inessive_singular(word);
00076     else
00077       return ff_inessive_plural(word);
00078     break;
00079   case FFCASE_ELATIVE:
00080     if(count == 1)
00081       return ff_elative_singular(word);
00082     else
00083       return ff_elative_plural(word);
00084     break;
00085   case FFCASE_ILLATIVE:
00086     if(count == 1)
00087       return ff_illative_singular(word);
00088     else
00089       return ff_illative_plural(word);
00090     break;
00091   case FFCASE_ADESSIVE:
00092     if(count == 1)
00093       return ff_adessive_singular(word);
00094     else
00095       return ff_adessive_plural(word);
00096     break;
00097   case FFCASE_ABLATIVE:
00098     if(count == 1)
00099       return ff_ablative_singular(word);
00100     else
00101       return ff_ablative_plural(word);
00102     break;
00103   case FFCASE_ALLATIVE:
00104     if(count == 1)
00105       return ff_allative_singular(word);
00106     else
00107       return ff_allative_plural(word);
00108     break;
00109   case FFCASE_ABESSIVE:
00110     if(count == 1)
00111       return ff_abessive_singular(word);
00112     else
00113       return ff_abessive_plural(word);
00114     break;
00115   case FFCASE_INSTRUCTIVE:
00116     if(count == 1)
00117       return ff_instructive_singular(word);
00118     else
00119       return ff_instructive_plural(word);
00120     break;
00121   case FFCASE_COMITATIVE:
00122     if(count == 1)
00123       /** @todo curse user? */
00124       return (ffchar*)strdup("-");
00125     else
00126       return ff_comitative_plural(word);
00127     break;
00128   default:
00129     return NULL;
00130     break;
00131   }
00132 }
00133 
00134 ffchar* ff_nominative_singular(const ffchar* word)
00135 {
00136   return (ffchar*)strdup(word);
00137 }
00138 
00139 ffchar* ff_nominative_plural(const ffchar* word)
00140 {
00141   ffword theword;
00142   ffword_create(word, &theword);
00143   ffpriv_nominative_plural(&theword);
00144   ffword_finalize(&theword);
00145   return theword.data.str;
00146 }
00147 
00148 ffchar* ff_genitive_singular(const ffchar* word)
00149 {
00150   ffword theword;
00151   ffword_create(word, &theword);
00152   ffpriv_genitive_singular(&theword);
00153   ffword_finalize(&theword);
00154   return theword.data.str;
00155 }
00156 
00157 ffchar* ff_genitive_plural(const ffchar* word)
00158 {
00159   ffword theword;
00160   ffword_create(word, &theword);
00161   ffpriv_genitive_plural(&theword);
00162   ffword_finalize(&theword);
00163   return theword.data.str;
00164 }
00165 
00166 ffchar* ff_essive_singular(const ffchar* word)
00167 {
00168   ffword theword;
00169   ffword_create(word, &theword);
00170   ffpriv_essive_singular(&theword);
00171   ffword_finalize(&theword);
00172   return theword.data.str;
00173 }
00174 
00175 ffchar* ff_essive_plural(const ffchar* word)
00176 {
00177   ffword theword;
00178   ffword_create(word, &theword);
00179   ffpriv_essive_plural(&theword);
00180   ffword_finalize(&theword);
00181   return theword.data.str;
00182 }
00183 
00184 ffchar* ff_partitive_singular(const ffchar* word)
00185 {
00186   ffword theword;
00187   ffword_create(word, &theword);
00188   ffpriv_partitive_singular(&theword);
00189   ffword_finalize(&theword);
00190   return theword.data.str;
00191 }
00192 
00193 ffchar* ff_partitive_plural(const ffchar* word)
00194 {
00195   ffword theword;
00196   ffword_create(word, &theword);
00197   ffpriv_partitive_plural(&theword);
00198   ffword_finalize(&theword);
00199   return theword.data.str;
00200 }
00201 
00202 ffchar* ff_translative_singular(const ffchar* word)
00203 {
00204   ffword theword;
00205   ffword_create(word, &theword);
00206   ffpriv_translative_singular(&theword);
00207   ffword_finalize(&theword);
00208   return theword.data.str;
00209 }
00210 
00211 ffchar* ff_translative_plural(const ffchar* word)
00212 {
00213   ffword theword;
00214   ffword_create(word, &theword);
00215   ffpriv_translative_plural(&theword);
00216   ffword_finalize(&theword);
00217   return theword.data.str;
00218 }
00219 
00220 ffchar* ff_inessive_singular(const ffchar* word)
00221 {
00222   ffword theword;
00223   ffword_create(word, &theword);
00224   ffpriv_inessive_singular(&theword);
00225   ffword_finalize(&theword);
00226   return theword.data.str;
00227 }
00228 
00229 ffchar* ff_inessive_plural(const ffchar* word)
00230 {
00231   ffword theword;
00232   ffword_create(word, &theword);
00233   ffpriv_inessive_plural(&theword);
00234   ffword_finalize(&theword);
00235   return theword.data.str;
00236 }
00237 
00238 ffchar* ff_elative_singular(const ffchar* word)
00239 {
00240   ffword theword;
00241   ffword_create(word, &theword);
00242   ffpriv_elative_singular(&theword);
00243   ffword_finalize(&theword);
00244   return theword.data.str;
00245 }
00246 
00247 ffchar* ff_elative_plural(const ffchar* word)
00248 {
00249   ffword theword;
00250   ffword_create(word, &theword);
00251   ffpriv_elative_plural(&theword);
00252   ffword_finalize(&theword);
00253   return theword.data.str;
00254 }
00255 
00256 ffchar* ff_illative_singular(const ffchar* word)
00257 {
00258   ffword theword;
00259   ffword_create(word, &theword);
00260   ffpriv_illative_singular(&theword);
00261   ffword_finalize(&theword);
00262   return theword.data.str;
00263 }
00264 
00265 ffchar* ff_illative_plural(const ffchar* word)
00266 {
00267   ffword theword;
00268   ffword_create(word, &theword);
00269   ffpriv_illative_plural(&theword);
00270   ffword_finalize(&theword);
00271   return theword.data.str;
00272 }
00273 
00274 ffchar* ff_adessive_singular(const ffchar* word)
00275 {
00276   ffword theword;
00277   ffword_create(word, &theword);
00278   ffpriv_adessive_singular(&theword);
00279   ffword_finalize(&theword);
00280   return theword.data.str;
00281 }
00282 
00283 ffchar* ff_adessive_plural(const ffchar* word)
00284 {
00285   ffword theword;
00286   ffword_create(word, &theword);
00287   ffpriv_adessive_plural(&theword);
00288   ffword_finalize(&theword);
00289   return theword.data.str;
00290 }
00291 
00292 ffchar* ff_ablative_singular(const ffchar* word)
00293 {
00294   ffword theword;
00295   ffword_create(word, &theword);
00296   ffpriv_ablative_singular(&theword);
00297   ffword_finalize(&theword);
00298   return theword.data.str;
00299 }
00300 
00301 ffchar* ff_ablative_plural(const ffchar* word)
00302 {
00303   ffword theword;
00304   ffword_create(word, &theword);
00305   ffpriv_ablative_plural(&theword);
00306   ffword_finalize(&theword);
00307   return theword.data.str;
00308 }
00309 
00310 ffchar* ff_allative_singular(const ffchar* word)
00311 {
00312   ffword theword;
00313   ffword_create(word, &theword);
00314   ffpriv_allative_singular(&theword);
00315   ffword_finalize(&theword);
00316   return theword.data.str;
00317 }
00318 
00319 ffchar* ff_allative_plural(const ffchar* word)
00320 {
00321   ffword theword;
00322   ffword_create(word, &theword);
00323   ffpriv_allative_plural(&theword);
00324   ffword_finalize(&theword);
00325   return theword.data.str;
00326 }
00327 
00328 ffchar* ff_abessive_singular(const ffchar* word)
00329 {
00330   ffword theword;
00331   ffword_create(word, &theword);
00332   ffpriv_abessive_singular(&theword);
00333   ffword_finalize(&theword);
00334   return theword.data.str;
00335 }
00336 
00337 ffchar* ff_abessive_plural(const ffchar* word)
00338 {
00339   ffword theword;
00340   ffword_create(word, &theword);
00341   ffpriv_abessive_plural(&theword);
00342   ffword_finalize(&theword);
00343   return theword.data.str;
00344 }
00345 
00346 ffchar* ff_instructive_singular(const ffchar* word)
00347 {
00348   ffword theword;
00349   ffword_create(word, &theword);
00350   ffpriv_instructive_singular(&theword);
00351   ffword_finalize(&theword);
00352   return theword.data.str;
00353 }
00354 
00355 ffchar* ff_instructive_plural(const ffchar* word)
00356 {
00357   ffword theword;
00358   ffword_create(word, &theword);
00359   ffpriv_instructive_plural(&theword);
00360   ffword_finalize(&theword);
00361   return theword.data.str;
00362 }
00363 
00364 ffchar* ff_comitative_plural(const ffchar* word)
00365 {
00366   ffword theword;
00367   ffword_create(word, &theword);
00368   ffpriv_comitative_plural(&theword);
00369   ffword_finalize(&theword);
00370   return theword.data.str;
00371 }
00372 

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