home *** CD-ROM | disk | FTP | other *** search
- /*
- * IXFrenchReader.m
- *
- * You may freely copy, distribute, and reuse the code in this example.
- * NeXT disclaims any warranty of any kind, expressed or implied, as to its
- * fitness for any particular use.
- *
- * Written by: Mai Nguyen, NeXT Developer Support
- *
- * Note that the example only shows what steps are needed in order
- * to build a reader. It doesn't take into account the French language
- * semantics in order to build a useful reader for the French language.
- * This exercise is left to the native French readers (no pun!).
- */
-
-
- #import <ansi/ansi.h>
- #import "IXFrenchReader.h"
-
- #define CLASSVERSION 1
-
- @implementation IXFrenchReader
-
- + initialize
- {
- if (self != [IXFrenchReader class]) return self;
- return [[super initialize] setVersion:CLASSVERSION];
- }
-
- /* This method simplifies plural words. For example, words like 'maisons',
- * 'midis', 'papas', 'mademoiselles' etc. can be reduced to their singular
- * form: 'maison', 'midi', 'papa', 'mademoiselle'.
- * This method can be made much more sophisticated to handle other forms of
- * French plurals such as 'animaux' --> 'animal', etc.
- */
- - (unsigned)foldPlural:(char *)string inLength:(unsigned)length
- {
- unsigned theLength;
-
- if ((theLength = strlen(string)) < 3 || string[theLength - 1] != 's')
- return theLength;
-
- switch(string[theLength - 2])
- {
- case 's': case '\'': break;
- case 'e': case 'i': case 'u': case 'a': case 'o': case 'n': case 'l':
- string[theLength = theLength - 1] = '\0';
- break;
- default: string[theLength = theLength - 1] = '\0';
- }
-
- return theLength;
- }
-
- @end
-
-