- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/packages/mg-1.3d/lib/frenchstem.c
r13 r29 1 /************************************************************************** 2 * 3 * frenchstem.c -- a simple french stemmer 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (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 of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * 19 * $Id$ 20 * 21 **************************************************************************/ 1 22 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'; 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'; 10 42 } 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';43 wordstart[last]='\0'; 44 last--; 45 46 } else { 47 if (wordstart[last]=='s' && last>=0) 48 {wordstart[last]='\0'; last--;} 49 if (wordstart[last]=='r' && last>=0) 50 {wordstart[last]='\0'; last--;} 51 if (wordstart[last]=='e' && last>=0) 52 {wordstart[last]='\0'; last--;} 53 if (wordstart[last]=='é' && last>=0) /* letter with accent e + ' */ 54 {wordstart[last]='\0'; last--;} 55 if (wordstart[last]==wordstart[last-1] && last>=1) 56 {wordstart[last]='\0'; last--;} 25 57 } /* end else */ 58 59 word[0] = (unsigned char)(last+1); 26 60 } /* end if (len > 4) */ 27 return(word);28 61 }
Note:
See TracChangeset
for help on using the changeset viewer.