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

ffutil.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 ffutil.c Implements the utility functions (declared in ffutil.c).
00027  */
00028 
00029 #include <stdlib.h>
00030 
00031 #include "fftypes.h"
00032 #include "ffutil.h"
00033 
00034 static const char* v_low = "aeiouyåäö";
00035 static const char* v_upp = "AEIOUYÅÄÖ";
00036 static const char* c_low = "bcdfghjklmnpqrstvwxz";
00037 static const char* c_upp = "BCDFGHJKLMNPQRSTVWXZ";
00038 static const ffuint32 v_len = 9;
00039 static const ffuint32 c_len = 20;
00040 
00041 ffbool ffpriv_is_vowel(const char letter)
00042 {
00043   const char* i = v_low;
00044 
00045   for (;i < v_low+v_len; ++i)
00046   {
00047     if ( letter == *i )
00048     {
00049       return 1;
00050     }
00051   }
00052 
00053   i = v_upp;
00054   for (;i < v_upp+v_len; ++i)
00055   {
00056     if ( letter == *i )
00057     {
00058       return 1;
00059     }
00060   }
00061 
00062   return 0;
00063 }
00064 
00065 ffbool ffpriv_is_consonant(const char letter)
00066 {
00067 
00068   const char* i = c_low;
00069 
00070   for (;i < c_low+c_len; ++i)
00071   {
00072     if ( letter == *i )
00073     {
00074       return 1;
00075     }
00076   }
00077 
00078   i = c_upp;
00079   for (;i < c_upp+c_len; ++i)
00080   {
00081     if ( letter == *i )
00082     {
00083       return 1;
00084     }
00085   }
00086 
00087   return 0;
00088 }
00089 
00090 ffchar* ffpriv_vowel_harmony(const ffstring* string, ffchar* back, ffchar* front) {
00091   ffint32 i = string->len -1;
00092   ffchar c;
00093   
00094   for (; i >= 0; i--) {
00095     c = string->str[i];
00096     if ( c == 'a' || c == 'A' || c == 'o' || c == 'O' || c == 'u' || c == 'U' ) {
00097       return back;
00098     } else if ( c == 'ä' || c == 'Ä' || c == 'ö' || c == 'Ö' || c == 'y' || c == 'Y' ) {
00099       return front;
00100     }
00101   }
00102   return front;
00103 }
00104 

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