# /* possible improvements ation ize */ #define MAXL 3 /* number of suffix priority levels */ char word[50]; int numb 0; main(){ char *p; while( gets( word ) ) { ++numb; pword( "." , 0 ); for( p=word; *p != 0; ++p ) ; /* now, p points to the end of the word */ if( p - word <= 2 ) continue; switch( *--p ){ case 's': *p = 0; pword( "+s", 1 ); if( *--p != 'e' ) continue; if( *(p-1) == 'i' ){ *p = 0; *--p = 'y'; pword( "-y+ies" , 2 ); continue; } *p = 0; pword( "+es" , 2 ); continue; case 'd': *p = 0; if( *--p != 'e' ) continue; if( *(p-1) == 'i' ){ *p = 0; *--p = 'y'; pword( "-y+ied" , 2 ); continue; } pword( "+d" , 1 ); *p = 0; pword( "+ed" , 2 ); continue; case 'g': if( *--p != 'n' ) continue; if( *--p != 'i' ) continue; *p = 0; pword( "+ing" , 1 ); *p = 'e'; *++p = 0; pword( "-e+ing", 2 ); continue; case 'r': if( *--p != 'e' ) continue; if( *(p-1) == 'i' ){ *p = 0; *--p = 'y'; pword( "-y+ier" , 2 ); continue; } *p = 0; pword( "+er" , 1 ); continue; case 'y': if( *--p != 'l' ) continue; *p = 0; pword( "+ly", 1 ); continue; case 't': if( *--p != 's' ) continue; if( *--p != 'e' ) continue; if( *(p-1) == 'i' ){ *p = 0; *--p = 'y'; pword( "-y+iest" , 1 ); continue; } *p = 0; pword( "+est" , 1 ); continue; } } } pword(s, l ) char *s; { wword(word, "", s, l ); switch(word[0]) { case 'm': if(word[1]=='i'&&word[2]=='s') wword(word+3, "-mis", s, l+MAXL ); else if(word[1]=='u'&&word[2]=='l'&&word[3]=='t'&&word[4]=='i') wword(word+5, "-multi", s, l+MAXL); break; case 'n': if(word[1]=='o'&&word[2]=='n') wword(word+3, "-non", s, l+MAXL ); break; case 'r': if(word[1]=='e') wword(word+2, "-re", s, l+MAXL); break; case 's': if(word[1]=='u'&&word[2]=='b') wword(word+3, "-sub", s, l+MAXL ); break; case 'u': if(word[1]=='n') wword(word+2, "-un", s, l+MAXL ); break; } } wword( w, s1, s2, l ) char *w, *s1, *s2; { register char *p; for( p = w; *p != 0 ; ++p ){ if( *p == 'a' || *p == 'e' || *p == 'i' || *p == 'o' || *p == 'u' || *p == 'y' ) goto prt; } if( *s2 == '.' && w[0] != '\0' ) goto prt; return; prt: printf("%s\t%s%s\t%05d\t%d\n", w, s1, s2, numb, l ); }