source: trunk/gsdl/packages/mg-1.3d/lib/frenchstem.c@ 29

Last change on this file since 29 was 29, checked in by rjmcnab, 25 years ago

Incorporated the french stemmer better.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
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: frenchstem.c 29 1998-11-24 06:37:53Z rjmcnab $
20 *
21 **************************************************************************/
22
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
34void 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';
42 }
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--;}
57 } /* end else */
58
59 word[0] = (unsigned char)(last+1);
60 } /* end if (len > 4) */
61}
Note: See TracBrowser for help on using the repository browser.