- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/packages/mg-1.3d/lib/frenchstem.c
r29 r13 1 /**************************************************************************2 *3 * frenchstem.c -- a simple french stemmer4 *5 * This program is free software; you can redistribute it and/or modify6 * it under the terms of the GNU General Public License as published by7 * the Free Software Foundation; either version 2 of the License, or8 * (at your option) any later version.9 *10 * This program is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU General Public License16 * along with this program; if not, write to the Free Software17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.18 *19 * $Id$20 *21 **************************************************************************/22 1 23 #include "frenchstem.h" 24 25 26 27 /* ========================================================================= 28 * Function: frenchstem 29 * Description: a simple french stemmer 30 * Input: a word string with the length in the first byte 31 * Output: the stemmed word 32 * ========================================================================= */ 33 34 void frenchstem (unsigned char *word) { 35 unsigned char *wordstart = word + 1; /* points to first letter of word */ 36 int last = (int)word[0]-1; /* last points to the last character */ 37 38 if (last > 4) { 39 if (wordstart[last]=='x') { 40 if (wordstart[last-1]=='u' && wordstart[last-2]=='a') { 41 wordstart[last-1]='l'; 2 static char * frenchstem (word) 3 char *word; 4 { 5 int len = strlen(word)-1; 6 if (len > 4) { 7 if (word[len]=='x') { 8 if (word[len-1]=='u' && word[len-2]=='a') { 9 word[len-1]='l'; 42 10 } 43 word start[last]='\0';44 last--;45 46 }else {47 if (word start[last]=='s' && last>=0)48 {word start[last]='\0'; last--;}49 if (word start[last]=='r' && last>=0)50 {word start[last]='\0'; last--;}51 if (word start[last]=='e' && last>=0)52 {word start[last]='\0'; last--;}53 if (word start[last]=='é' && last>=0)/* letter with accent e + ' */54 {word start[last]='\0'; last--;}55 if (word start[last]==wordstart[last-1] && last>=1)56 {wordstart[last]='\0'; last--;}11 word[len]='\0'; 12 return(word); 13 } 14 else { 15 if (word[len]=='s') 16 {word[len]='\0';len--;} 17 if (word[len]=='r') 18 {word[len]='\0';len--;} 19 if (word[len]=='e') 20 {word[len]='\0';len--;} 21 if (word[len]=='é') /* letter with accent e + ' */ 22 {word[len]='\0';len--;} 23 if (word[len] == word[len-1]) 24 word[len]='\0'; 57 25 } /* end else */ 58 59 word[0] = (unsigned char)(last+1);60 26 } /* end if (len > 4) */ 27 return(word); 61 28 }
Note:
See TracChangeset
for help on using the changeset viewer.