static char* StemSpell(char* word,unsigned int i)
{
    static char word1[MAX_WORD_SIZE];
    strcpy(word1,word);
    size_t len = strlen(word);

	char* ending = NULL;
    char* best = NULL;
    
	//   suffixes
	if (len < 5){;} // too small to have a suffix we care about (suffix == 2 at min)
    else if (!strnicmp(word+len-3,(char*)"ing",3))
    {
        word1[len-3] = 0;
        best = SpellFix(word1,0,VERB,ENGLISH); 
        if (best && FindWord(best,0,LOWERCASE_LOOKUP)) return GetPresentParticiple(best);
	}
    else if (!strnicmp(word+len-2,(char*)"ed",2))
    {
        word1[len-2] = 0;
        best = SpellFix(word1,0,VERB,ENGLISH); 
        if (best)
        {
			char* past = GetPastTense(best);
			if (!past) return NULL;
			size_t pastlen = strlen(past);
			if (past[pastlen-1] == 'd') return past;
			ending = "ed";
        }
    }
	else
	{
		unsigned int i = 0;
		char* suffix;
		while ((suffix = stems[i].word))
		{
			uint64 kind = stems[i++].flags;
			size_t suffixlen = strlen(suffix);
			if (!strnicmp(word+len-suffixlen,suffix,suffixlen))
			{
				word1[len-suffixlen] = 0;
				best = SpellFix(word1,0,kind,ENGLISH); 
				if (best) 
				{
					ending = suffix;
					break;
				}
			}
		}
	}
	if (!ending && word[len-1] == 's')
    {
        word1[len-1] = 0;
        best = SpellFix(word1,0,VERB|NOUN,ENGLISH); 
        if (best)
        {
			WORDP F = FindWord(best,0,(tokenControl & ONLY_LOWERCASE) ?  PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP);
			if (F && F->properties & NOUN) return GetPluralNoun(F);
			ending = "s";
        }
   }
   if (ending)
   {
		strcpy(word1,best);
		strcat(word1,ending);
		return word1;
   }
   return NULL;
}
static char* StemSpell(char* word,unsigned int i,uint64& base)
{
    static char word1[MAX_WORD_SIZE];
    strcpy(word1,word);
    size_t len = strlen(word);

	char* ending = NULL;
    char* best = NULL;
    
	//   suffixes
	if (len < 5){;} // too small to have a suffix we care about (suffix == 2 at min)
    else if (!strnicmp(word+len-3,(char*)"ing",3))
    {
        word1[len-3] = 0;
        best = SpellFix(word1,0,VERB); 
        base = VERB;
        if (best && FindWord(best,0,LOWERCASE_LOOKUP)) return GetPresentParticiple(best);
	}
    else if (!strnicmp(word + len - 3, (char*)"ies", 3))
    {
        word1[len - 3] = 'y';
        word1[len - 2] = 0;
        best = SpellFix(word1, 0, NOUN);
        if (best)
        {
            base = NOUN | NOUN_PLURAL;
            char* plu = GetPluralNoun(FindWord(best));
            return (plu) ? plu : NULL;
        }
    }
    else if (!strnicmp(word+len-2,(char*)"ed",2))
    {
        word1[len-2] = 0;
        best = SpellFix(word1,0,VERB); 
        if (best)
        {
			char* past = GetPastTense(best);
            base = VERB;
			return past ? past : NULL;
        }
    }
	else
	{
		unsigned int i = 0;
		char* suffix;
		if (!stricmp(language, "english")) 
		{
			while ((suffix = stems[i].word))
			{
				uint64 kind = stems[i++].flags;
				size_t suffixlen = strlen(suffix);
				if (!strnicmp(word+len-suffixlen,suffix,suffixlen))
				{
					word1[len-suffixlen] = 0;
					best = SpellFix(word1,0,kind); 
					if (best) 
					{
						ending = suffix;
	                    base = stems[i].flags;
						break;
					}
				}
			}
		}
		else if (!stricmp(language, "french")) 
		{
			while ((suffix = stems_french[i].word))
			{
				uint64 kind = stems_french[i++].flags;
				size_t suffixlen = strlen(suffix);
				if (!strnicmp(word+len-suffixlen,suffix,suffixlen))
				{
					word1[len-suffixlen] = 0;
					best = SpellFix(word1,0,kind); 
					if (best) 
					{
						ending = suffix;
	                    base = stems_french[i].flags;
						break;
					}
				}
			}
		}
	}
	if (!ending && word[len-1] == 's')
    {
        word1[len-1] = 0;
        best = SpellFix(word1,0,VERB|NOUN); 
        if (best)
        {
			WORDP F = FindWord(best,0,(tokenControl & ONLY_LOWERCASE) ?  PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP);
            if (F && F->properties & NOUN)
            {
                base = NOUN | NOUN_PLURAL;
                return GetPluralNoun(F);
            }
            base = VERB | VERB_PRESENT_3PS;
			ending = "s";
        }
   }
   if (ending)
   {
		strcpy(word1,best);
		strcat(word1,ending);
		return word1;
   }
   return NULL;
}