Ejemplo n.º 1
0
void JoinMatch(int start, int end,int index,bool inpattern)
{
	// concatenate the match value
	bool started = false;
	for (int i = start; i <= end; ++i)
	{
		if (i < 1 || i > wordCount) continue;	// ignore off end
		if (unmarked[i]) continue; // ignore words masked
		char* word = wordStarts[i];
		if (started)
		{
			strcat(wildcardOriginalText[index], wildcardSeparator);
			strcat(wildcardCanonicalText[index], wildcardSeparator);
		}
		else started = true;
		strcat(wildcardOriginalText[index], word);
		if (wordCanonical[i]) strcat(wildcardCanonicalText[index], wordCanonical[i]);
		else strcat(wildcardCanonicalText[index], word);
	}
	if (strstr(wildcardCanonicalText[index], "unknown-word")) strcpy(wildcardCanonicalText[index], "unknown-word"); // if any are unknown, the composite is unknown
	// force a particular case? do we know the word?
	int lookup = STANDARD_LOOKUP;
	if (uppercaseFind > 0) 
		lookup = UPPERCASE_LOOKUP;
	else if (uppercaseFind == 0) lookup = LOWERCASE_LOOKUP;
	WORDP D = FindWord(wildcardCanonicalText[index], 0, lookup);
	if (D) strcpy(wildcardCanonicalText[index], D->word); // but may not be found if original has plural or such or if uses _
	D = FindWord(wildcardOriginalText[index], 0, lookup);
	if (D) strcpy(wildcardOriginalText[index], D->word); // but may not be found if original has plural or such or if uses _

	if (trace & TRACE_OUTPUT && !inpattern && CheckTopicTrace()) Log(STDTRACELOG, (char*)"_%d=%s/%s ", index, wildcardOriginalText[index], wildcardCanonicalText[index]);
}
Ejemplo n.º 2
0
static char* SpellCheck( int i, int language)
{
    //   on entry we will have passed over words which are KnownWord (including bases) or isInitialWord (all initials)
    //   wordstarts from 1 ... wordCount is the incoming sentence words (original). We are processing the ith word here.
    char* word = wordStarts[i];
	if (!*word) return NULL;
	if (!stricmp(word,loginID) || !stricmp(word,computerID)) return word; //   dont change his/our name ever

	size_t len = strlen(word);
	if (len > 2 && word[len-2] == '\'') return word;	// dont do anything with ' words

    //   test for run togetherness like "talkabout fingers"
    int breakAt = SplitWord(word);
    if (breakAt > 0)//   we found a split, insert 2nd word into word stream
    {
		char* tokens[3];
		WORDP D = FindWord(word,breakAt,PRIMARY_CASE_ALLOWED);
		tokens[1] = D->word;
		tokens[2] = word+breakAt;
		ReplaceWords(i,1,2,tokens);
		fixedSpell = true;
		return NULL;
    }

	// now imagine partial runtogetherness, like "talkab out fingers"
	if (i < wordCount)
	{
		char tmp[MAX_WORD_SIZE];
		strcpy(tmp,word);
		strcat(tmp,wordStarts[i+1]);
		breakAt = SplitWord(tmp);
		if (breakAt > 0) // replace words with the dual pair
		{
			char* tokens[3];
			WORDP D = FindWord(tmp,breakAt,PRIMARY_CASE_ALLOWED);
			tokens[1] = D->word;
			tokens[2] = tmp+breakAt;
			ReplaceWords(i,2,2,tokens);
			fixedSpell = true;
			return NULL;
		}
	}

    //   remove any nondigit characters repeated more than once. Dont do this earlier, we want substitutions to have a chance at it first.  ammmmmmazing
	static char word1[MAX_WORD_SIZE];
    char* ptr = word-1; 
	char* ptr1 = word1;
    while (*++ptr)
    {
	   *ptr1 = *ptr;
	   while (ptr[1] == *ptr1 && ptr[2] == *ptr1 && (*ptr1 < '0' || *ptr1 > '9')) ++ptr; // skip double repeats
	   ++ptr1;
    }
	*ptr1 = 0;
	if (FindCanonical(word1,0,true) && !IsUpperCase(*word1)) return word1; // this is a different form of a canonical word so its ok

	//   now use word spell checker 
    char* d = SpellFix(word,i,PART_OF_SPEECH,language); 
    return (d) ? d : NULL;
}
Ejemplo n.º 3
0
static int SplitWord(char* word)
{
	WORDP D2;
	bool good;
	int breakAt = 0;
	if (IsDigit(*word))
    {
		while (IsDigit(word[++breakAt]) || word[breakAt] == '.'){;} //   find end of number
        if (word[breakAt]) // found end of number
		{
			D2 = FindWord(word+breakAt,0,PRIMARY_CASE_ALLOWED);
			if (D2)
			{
				good = (D2->properties & (PART_OF_SPEECH|FOREIGN_WORD)) != 0 || (D2->internalBits & HAS_SUBSTITUTE) != 0; 
				if (good && (D2->systemFlags & AGE_LEARNED))// must be common words we find
				{
					char number[MAX_WORD_SIZE];
					strncpy(number,word,breakAt);
					number[breakAt] = 0;
					StoreWord(number,ADJECTIVE|NOUN|ADJECTIVE_NUMBER|NOUN_NUMBER); 
					return breakAt; // split here
				}
			}
		}
    }

	//  try all combinations of breaking the word into two known words
	breakAt = 0;
	size_t len = strlen(word);
    for (unsigned int k = 1; k < len-1; ++k)
    {
        if (!stricmp(language,"english") && k == 1 && *word != 'a' && *word != 'A' && *word != 'i' && *word != 'I') continue; //   only a and i are allowed single-letter words
        else if (!stricmp(language,"french") && k == 1 && *word != 'y' && *word != 'a' && *word != 'A' && !SameUTF(word,"à") && !SameUTF(word, "À") && !SameUTF(word, "ô") && !SameUTF(word,"Ô")) continue; //   in french only y, a and ô are allowed single-letter words
		WORDP D1 = FindWord(word,k,PRIMARY_CASE_ALLOWED);
        if (!D1) continue;
		good = (D1->properties & (PART_OF_SPEECH|FOREIGN_WORD)) != 0 || (D1->internalBits & HAS_SUBSTITUTE) != 0; 
		if (!good || !(D1->systemFlags & AGE_LEARNED)) continue; // must be normal common words we find

        D2 = FindWord(word+k,len-k,PRIMARY_CASE_ALLOWED);
        if (!D2) continue;
        good = (D2->properties & (PART_OF_SPEECH|FOREIGN_WORD)) != 0 || (D2->internalBits & HAS_SUBSTITUTE) != 0;
		if (!good || !(D2->systemFlags & AGE_LEARNED) ) continue; // must be normal common words we find

        if (!breakAt) breakAt = k; // found a split
		else // found multiple places to split... dont know what to do
        {
           breakAt = -1; 
           break;
		}
    }
	return breakAt;
}
Ejemplo n.º 4
0
static char* SpellCheck(unsigned int i)
{
    //   on entry we will have passed over words which are KnownWord (including bases) or isInitialWord (all initials)
    //   wordstarts from 1 ... wordCount is the incoming sentence words (original). We are processing the ith word here.
    char* word = wordStarts[i];
	if (!*word) return NULL;
	if (!stricmp(word,loginID) || !stricmp(word,computerID)) return word; //   dont change his/our name ever

	size_t len = strlen(word);
	if (len > 2 && word[len-2] == '\'') return word;	// dont do anything with ' words

    //   test for run togetherness like "talkabout fingers"
    int breakAt = SplitWord(word);
    if (breakAt > 0)//   we found a split, insert 2nd word into word stream
    {
        ++wordCount;
		memmove(wordStarts+i+1,wordStarts+i,sizeof(char*) * (wordCount-i)); // open up a slot for a new word
        wordStarts[i+1] = reuseAllocation(wordStarts[i+1],wordStarts[i]+breakAt); // set this to the second word (shared from within 1st word)
        return FindWord(wordStarts[i],breakAt,PRIMARY_CASE_ALLOWED)->word; //   1st word gets replaced, we added valid word after
    }

	// now imagine partial runtogetherness, like "talkab out fingers"
	if (i < wordCount)
	{
		char tmp[MAX_WORD_SIZE];
		strcpy(tmp,word);
		strcat(tmp,wordStarts[i+1]);
		breakAt = SplitWord(tmp);
		if (breakAt > 0) // replace words with the dual pair
		{
			wordStarts[i+1] = reuseAllocation(wordStarts[i+1],StoreWord(tmp+breakAt)->word); // set this to the second word (shared from within 1st word)
			return FindWord(tmp,breakAt,PRIMARY_CASE_ALLOWED)->word; // 1st word gets replaced, we added valid word after
		}
	}

    //   remove any nondigit characters repeated more than once. Dont do this earlier, we want substitutions to have a chance at it first.  ammmmmmazing
	static char word1[MAX_WORD_SIZE];
    char* ptr = word-1; 
	char* ptr1 = word1;
    while (*++ptr)
    {
	   *ptr1 = *ptr;
	   while (ptr[1] == *ptr1 && ptr[2] == *ptr1 && (*ptr1 < '0' || *ptr1 > '9')) ++ptr; // skip double repeats
	   ++ptr1;
    }
	*ptr1 = 0;
	if (FindCanonical(word1,0,true) && !IsUpperCase(*word1)) return word1; // this is a different form of a canonical word so its ok

	//   now use word spell checker 
    char* d = SpellFix(word,i,PART_OF_SPEECH); 
    return (d) ? d : NULL;
}
Ejemplo n.º 5
0
pDICT FindWord(pDICT root, char KeyWord[])
{
	if(root == NULL)
		return root;
	else
	{
		if(strcmp(KeyWord, root->data.word)<0)
			root ->leftlink = FindWord(root->leftlink, KeyWord);
		else
		{
			if(strcmp(KeyWord,root->data.word)>0)
				root->rightlink = FindWord(root->rightlink,KeyWord);
			else
			{
				if(root ->leftlink ==NULL && root->rightlink ==NULL) 
				{
				//	pDICT temp= NULL;
					//temp->leftlink= root;
					free(root);
					root = NULL;
				}
				else
				{
					if(root -> leftlink ==NULL)
					{//has right link
						pDICT temp = root;
						root = root->rightlink;
						free(temp);
					}
					else
					{
							if(root ->rightlink ==NULL)
							{//has left link
								pDICT temp = root;
								root = root->leftlink;
								free(temp);		
							} 
							else
							{//have two links
								pDICT temp = FirstWord(root->rightlink); 
								root->data = temp->data;			
								root ->rightlink = FindWord(root->rightlink,temp->data.word);				
							}
				}
			}
		}
	}
}
	return root;
}
Ejemplo n.º 6
0
bool bgParserASE::ReadHelperObject()
{
	bool hr = true;

	TCHAR szWordArray[2][MAX_PATH * 4];
	D3DXVECTOR3 v3Data;
	FaceInfo i4Data;
	int iData;
	int iLoop, iLoopMax;

	int iNumObj = m_pModel->m_ObjectList.size();
	m_pModel->m_ObjectList.resize(iNumObj + 1);
	m_pModel->m_ObjectList[iNumObj].vpObj = new HelperObject;
	m_pModel->m_ObjectList[iNumObj].eNodeType = OBJECT_NODE_TYPE_HELPEROBJECT;

	IF_FALSE_RETURN(ReadNodeInfo(iNumObj));

	IF_FALSE_RETURN(FindWord(_T("*BOUNDINGBOX_MIN")));
	_stscanf(m_szLine, _T("%s %f%f%f"), m_szWord, &v3Data.x, &v3Data.z, &v3Data.y);
	static_cast<HelperObject*>(m_pModel->m_ObjectList[iNumObj].vpObj)->vBBoxMin = v3Data;

	IF_FALSE_RETURN(FindWord(_T("*BOUNDINGBOX_MAX")));
	_stscanf(m_szLine, _T("%s %f%f%f"), m_szWord, &v3Data.x, &v3Data.z, &v3Data.y);
	static_cast<HelperObject*>(m_pModel->m_ObjectList[iNumObj].vpObj)->vBBoxMax = v3Data;

	///// TM_ANIMATION - 애니메이션
	_tcscpy(szWordArray[0], _T("*TM_ANIMATION"));
	_tcscpy(szWordArray[1], _T("}"));
	switch (FindWordArray(szWordArray, 2))
	{
	case 0:		// *TM_ANIMATION	애니메이션이 있다면 ====================================
	{
		m_pModel->m_ObjectList[iNumObj].bAnim = true;
		IF_FALSE_RETURN(ReadTMAnimation(iNumObj));
	}
	break;
	case 1:		// }				애니메이션 없이 끝난다면 ===============================
	{
		m_pModel->m_ObjectList[iNumObj].bAnim = false;
	}
	break;
	case -1:	// 찾는 단어 없음 =========================================================
	default:	// 나머지 (배열 요소가 2개이므로 나올 수 없음)
		return false;
		break;
	}

	return hr;
}
Ejemplo n.º 7
0
//This should find a word inside a phrase, not considering variants of my word (For ex 'tris' won't be found inside 'i love tetris')
int FindWord(char str[], char myWord[], int p)
{
    if (strlen(str)-strlen(myWord)<p)    return 0;
    
    if (!(((p==0)||(str[p-1]==' '))&&((str[p+strlen(myWord)]==' ')||(str[p+strlen(myWord)]=='\0'))))    return FindWord(str, myWord, p+1);
    
    int i;
    for (i=0; myWord[i]!='\0'; i++)
    {
        if (myWord[i]!=str[p+i]) return FindWord(str, myWord, p+1);
    }
        
    return 1 + FindWord(str, myWord, p+1);
    
}
Ejemplo n.º 8
0
int ProcessExpress(char *instring) /*对原表达式进行预处理*/
{
	int len,pos;
	inlength=-1;
	parencount=0;
	tokencount=LASTOPERAND;
	len=strlen(instring);
	instring[len]='\0';
	for (pos=0;pos<len;)
	{
		if (instring[pos]==' ')				/*忽略空格字符*/
			pos++;
		else if (isalpha(instring[pos]))	/*处理字母*/
			pos=FindWord(instring,pos);
		else if (isdigit(instring[pos]) || instring[pos]=='.') /*处理数字*/
			pos=FindNumber(instring,pos);
		else			/*处理符号*/
			pos=FindSymbol(instring,pos);
		if (pos==-1)
			return 0;
	}
	if (parencount!=0)
		printf("左右括号不匹配\n");
	PutToken(0);	/*在infix中添加ENDEXPR*/
	return 1;
}
Ejemplo n.º 9
0
void DuminoSolver::Play(const std::vector<std::vector<unsigned char>> &grid,
                        const Dictionary &dict)
{
	for (int i = 0; i < 5; ++i)
	{
		for (int j = 0; j < 5; ++j)
		{
			used[i][j] = false;
		}
	}

	found_words = new Dictionary();
	vhid = new VirtualHID();
	
	for (int i = 0; i < 5; ++i)
	{
		for (int j = 0; j < 5; ++j)
		{
			FindWord(grid, dict.root, cv::Point(j, i), "");
		}
	}

	delete found_words;
	delete vhid;
}
Ejemplo n.º 10
0
static bool FindPhrase(char* word, int start,bool reverse, int & actualStart, int& actualEnd)
{   // Phrases are dynamic, might not be marked, so have to check each word separately. -- faulty in not respecting ignored(unmarked) words
	if (start > wordCount) return false;
	bool matched = false;
	actualEnd = start;
	int oldend;
	oldend = start = 0; // allowed to match anywhere or only next

	unsigned int n = BurstWord(word);
	for (int i = 0; i < n; ++i) // use the set of burst words - but "Andy Warhol" might be a SINGLE word.
	{
		WORDP D = FindWord(GetBurstWord(i));
		bool junk;
		matched = MatchTest(reverse,D,actualEnd,NULL,NULL,0,junk,actualStart,actualEnd);
		if (matched)
		{
			if (oldend > 0 && actualStart != (oldend + 1)) // do our words match in sequence NO. retry later in sentence
			{
				++start;
				actualStart = actualEnd = start;
				i = -1;
				oldend = start = 0;
				matched = false;
				continue;
			}
			if (i == 0) start = actualStart; // where we matched INITIALLY
			oldend = actualEnd;
		}
		else break;
	}
	if (matched) actualStart = start;
	return matched;
}
Ejemplo n.º 11
0
int main( void )
{
	char *text, *word, *ptr, *wordEnd;
	size_t len;
	char chr, tmpchr;
	puts( "This program search character in a text and print all words, that contain given character." );
	puts( "Enter character(a-z, A-Z, 0-9):" );
	while( 1 )
	{
		chr = (char)getchar();
		if( IsGraph( tmpchr = (char)getchar() ) ) {
			ungetc( tmpchr, stdin );
		}
		if( IsAlnum( chr ) == false )
		{
			puts( "Wrong character, try again:" );
		}
		else
		{
			break;
		}
	}

	text = Input();
	if( text == NULL )
	{
		puts( "Not enough memory." );
		return 1;
	}

	ptr = text;
	while( wordEnd = FindWord( ptr, chr ) )
	{
		len = 1;
		word = wordEnd;
		while( IsAlnum( word[-1] )  && word >= text )
		{
			word--;
			len++;
		}
		word = memcpy( malloc( len + 1 ), word, len );
		if( word == NULL )
		{
			puts( "Memory is not enough" );
			break;
		}
		else
		{
			word[len] = 0;

			printf( "\"%s\" is the word, that contain '%c'\n", word, chr );
			free( word );
		}
		ptr = wordEnd + 1;
	}
	free( text );

	return 0;
}
Ejemplo n.º 12
0
int main(int argc, const char * argv[])
{

    char str[]="Just testing this code out", myWord[]="test";
    printf("FindWord:\t %i\n", FindWord(str, myWord, 0));
    
    return 0;
}
Ejemplo n.º 13
0
bool bgParserASE::ReadScene()
{
	bool hr = true;

	IF_FALSE_RETURN(FindWord(_T("*SCENE_FIRSTFRAME")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iFirstFrame);
	IF_FALSE_RETURN(FindWord(_T("*SCENE_LASTFRAME")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iLastFrame);
	IF_FALSE_RETURN(FindWord(_T("*SCENE_FRAMESPEED")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iFrameSpeed);
	IF_FALSE_RETURN(FindWord(_T("*SCENE_TICKSPERFRAME")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iTicksPerFrame);

	IF_FALSE_RETURN(FindWord(_T("}"))); // SCENE 탈출

	return hr;
}
Ejemplo n.º 14
0
void SpellCheck::NextWord(void)
{
  if (FindWord(false) == false)
  {
    ShowWindow(SW_HIDE);
    DoneMessage();
  }
  else
    ShowWordFromSelection();
}
Ejemplo n.º 15
0
static void CompleteWildcard()
{
	WORDP D = FindWord(wildcardCanonicalText[wildcardIndex]);
	if (D && D->properties & D->internalBits & UPPERCASE_HASH)  // but may not be found if original has plural or such or if uses _
	{
		strcpy(wildcardCanonicalText[wildcardIndex],D->word);
	}

    ++wildcardIndex;
	if (wildcardIndex > MAX_WILDCARDS) wildcardIndex = 0; 
}
Ejemplo n.º 16
0
bool bgParserASE::Read()
{
	bool hr = true;

	TCHAR szWordArray[2][MAX_PATH * 4];

	// m_ASE 데이터 초기화
	ZeroMemory(&m_pModel->m_Scene, sizeof(SceneInfo));
	m_pModel->m_MaterialList.clear();
	m_pModel->m_ObjectList.clear();

	// 파일 앞부분 1회만 등장하는 섹션 읽기
	IF_FALSE_RETURN(FindWord(_T("*SCENE")));
	IF_FALSE_RETURN(ReadScene());
	IF_FALSE_RETURN(FindWord(_T("*MATERIAL_LIST")));
	IF_FALSE_RETURN(ReadMaterial());

	// 여러번 등장하는 섹션 반복해서 읽기
	_tcscpy(szWordArray[0], _T("*GEOMOBJECT"));
	_tcscpy(szWordArray[1], _T("*HELPEROBJECT"));
	while (!feof(m_pFile))
	{
		switch (FindWordArray(szWordArray, 2))
		{
		case 0:	IF_FALSE_RETURN(ReadGeomObject());		break;
		case 1:	IF_FALSE_RETURN(ReadHelperObject());	break;
		case -1:	// 찾는 단어 없음 (파일의 끝)
		{
			ConvertToModel();	// 읽은 데이터를 모델용 데이터로 컨버팅
			LinkNode();			// 노드 관계 연결
			OperationTM();		// 노드 관계에 따른 행렬 연산
		}
		break;
		default:	// 나머지 (배열 요소가 2개이므로 나올 수 없음)
			return false;
			break;
		}
	}

	return hr;
}
Ejemplo n.º 17
0
//pDICT FindWord(pDICT root, char key[])
//{
//	if (root == NULL)
//		return root;
//	if(strcmp(key,root->data.word)<0)
//		root->leftlink = FindWord(root->leftlink,key);
//
//	else if(strcmp(key,root->data.word)>0)
//		root->rightlink =FindWord(root->rightlink,key);
//	else
//	{
//		if(root->leftlink==NULL)
//		{
//			pDICT temp = root ->rightlink;
//			free(root);
//			return temp;
//		}
//		else if(root->rightlink ==NULL)
//		{
//			pDICT temp = root->leftlink;
//			free(root);
//			return temp;
//		}
//		pDICT temp = FirstWord(root->rightlink);
//		root->data = temp ->data;
//		root ->rightlink = FindWord(root->rightlink,temp->data.word);
//	}
//	return root;
//}
void DeleteWord(pDICT root)
{
	pDICT temp;
	char Key[1024];
	printf("Enter Keyword to delete: " );
	gets(Key);
	flushall();
	temp = FindWord(root,Key);
	if(temp == root)
		printf("The word has been deleted.\n");
	else
		printf("No word in dictionary.\n");
}
Ejemplo n.º 18
0
void ReadComputerID()
{
	strcpy(computerID,"anonymous");
	WORDP D = FindWord("defaultbot",0); // do we have a FACT with the default bot in it as verb
	if (D)
	{
		FACT* F = GetVerbHead(D);
		if (F)
		{
			D = Meaning2Word(F->subject);
			strcpy(computerID,D->word);
		}
	}
}
Ejemplo n.º 19
0
/*
 * Manual page at function.def
 */
INT16 CGEN_PUBLIC CFunction::OnGet()
{
  // Delegate to running function                                               // ------------------------------------
  FNC_DELEGATE OnGet();                                                         // Use a weird macro (see function.def)

  // Initialize                                                                 // ------------------------------------
  CDlpObject* iCont = GetActiveInstance();                                      // Determine field container
  const char* lpsId = GetNextToken(TRUE);                                       // Determine field name

  // Validate                                                                   // ------------------------------------
  DLPASSERT(iCont);                                                             // Check set target
  if (!dlp_strlen(lpsId))                                                       // If no field name committed
    return IERROR(this,FNC_EXPECT,"field identifier after -get",0,0);           //   Error
  SWord* lpWrd = iCont->FindWord(lpsId,WL_TYPE_FIELD);                          // Find field in container
  if (!lpWrd)                                                                   // If not found
  {                                                                             // >>
    iCont = this;                                                               //   Use this instance as container
    lpWrd = FindWord(lpsId,WL_TYPE_FIELD);                                      //   And seek again
  }                                                                             // <<
  if (!lpWrd) return IERROR(this,ERR_NOTFIELD,lpsId,0,0);                       // If still not found --> Error

  // Push field value                                                           // ------------------------------------
  switch (lpWrd->ex.fld.nType)                                                  // Branch for field variable type
  {                                                                             // >>
    case T_BOOL    : { PushLogic   (      *(     BOOL*)lpWrd->lpData);  break; }// - Boolean
    case T_UCHAR   : { PushNumber  (CMPLX(*(    UINT8*)lpWrd->lpData)); break; }// - Unsigned character
    case T_CHAR    : { PushNumber  (CMPLX(*(     INT8*)lpWrd->lpData)); break; }// - Signed character
    case T_USHORT  : { PushNumber  (CMPLX(*(   UINT16*)lpWrd->lpData)); break; }// - Unsigned short integer
    case T_SHORT   : { PushNumber  (CMPLX(*(    INT16*)lpWrd->lpData)); break; }// - Signed short integer
    case T_UINT    : { PushNumber  (CMPLX(*(   UINT32*)lpWrd->lpData)); break; }// - Unsigned integer
    case T_INT     : { PushNumber  (CMPLX(*(    INT32*)lpWrd->lpData)); break; }// - Signed integer
    case T_ULONG   : { PushNumber  (CMPLX(*(   UINT64*)lpWrd->lpData)); break; }// - Unsigned long integer
    case T_LONG    : { PushNumber  (CMPLX(*(    INT64*)lpWrd->lpData)); break; }// - Signed long integer
    case T_FLOAT   : { PushNumber  (CMPLX(*(  FLOAT32*)lpWrd->lpData)); break; }// - Single precision floating point
    case T_DOUBLE  : { PushNumber  (CMPLX(*(  FLOAT64*)lpWrd->lpData)); break; }// - Double precision floating point
    case T_COMPLEX : { PushNumber  (      *(COMPLEX64*)lpWrd->lpData);  break; }// - Double precision complex floating point
    case T_INSTANCE: { PushInstance(*(CDlpObject**) lpWrd->lpData);     break; }// - Instance
    case T_TEXT    : /* Fall through */                                         // - Text (deprecated type!)
    case T_CSTRING : /* Fall through */                                         // - Constant string
    case T_STRING  : { PushString(*(char**)         lpWrd->lpData); break;     }// - String
    default        : {                                                          // - Other types
      if (lpWrd->ex.fld.nType > 0 && lpWrd->ex.fld.nType <= 256)                //     Character array?
        PushString((char*)lpWrd->lpData);                                       //       Push value
      else                                                                      //     Type unknown!
        DLPASSERT(FMSG("Unknown field type"));                                  //       Error
    }                                                                           //   <<
  }                                                                             // <<

  return O_K;                                                                   // Done.
}
Ejemplo n.º 20
0
bool FindWord(char* word)
{
    char arr[256];
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            ResetBitMap();
            if (FindWord(arr, 256, word, strlen(word), i, j, 0))
            {
                return true;
            }
        }
    }
}
Ejemplo n.º 21
0
// loading simple list of words from a file, lemmatizing it, and storing
void CMorphDictionary::LoadFrequentRoots(string path)
{
	string load_path = path+"predictroots.txt";
	FILE*fp =  fopen (load_path.c_str(), "r");
	if (!fp) return;
	char buffer[1000];
	while (fgets (buffer, 1000, fp))
	{
		string WordStr = buffer;
		Trim(WordStr);
		if (WordStr.empty()) continue;
		RmlMakeUpper (WordStr, m_Language);
		vector<CFindWordNode> FindResults;
		bool retval = FindWord(WordStr, true, false, false, FindResults);
		if (!retval) continue;
		set<size_t> UsedFlexia;
		for (size_t i=0; i<FindResults.size(); i++)
		{
				CFormInfo P;
				P.Create(	this, 
							FindResults[i].m_nBase,
							FindResults[i].m_LemmaInfo,
							FindResults[i].m_nFlex
						);
				for (size_t j=0; j < P.GetCount(); j++)
				{
					size_t FlexNo = P.GetFlexNoOfForm(j);
					if (UsedFlexia.find(FlexNo) == UsedFlexia.end())
					{
						CPredictEndRoot R;
						R.m_BaseNo = FindResults[i].m_nBase;
						R.m_LemmaInfo = FindResults[i].m_LemmaInfo;
						R.m_EndRoot = P.GetWordForm(j);
						reverse(R.m_EndRoot.begin(),R.m_EndRoot.end());
						
						R.m_FlexNo = FlexNo;
						UsedFlexia.insert(FlexNo);
						m_PredictEndRoots.push_back(R);
					};
				};
			

		};

	};
	fclose(fp);
	sort(m_PredictEndRoots.begin(), m_PredictEndRoots.end());
};
Ejemplo n.º 22
0
bool wordBreak(string strtomatch, unordered_set<string> &myset) {
    unsigned strlength = strtomatch.length();

    BuildMatrix(&pmatrix,strlength,strlength);

    for(int i=0;i<strlength;++i){
        for(int j=i;j<strlength;++j){
            pmatrix[i][j] = false;
        }
    }

    for(unsigned i=0;i<strlength;++i){
        for(unsigned j=i;j<strlength;++j){
            string strdata;
            strdata.assign(strtomatch,i,j-i+1);
            if(myset.find(strdata)!=myset.end()){
                pmatrix[i][j] = true;
            }
        }
    }

    for(int i=strlength-1;i>=0;--i){
        bool isallfalse = true;
        for(int j = i;j<strlength;++j){
            if(pmatrix[i][j]){
                isallfalse = false;
                break;
            }
        }

        if(isallfalse&&(i-1>=0)){
            for(int j = 0;j<strlength;++j){
                pmatrix[j][i-1] = false;
            }
        }
    }

    bool ret = FindWord(strlength);

    ReleaseMatrix(&pmatrix,strtomatch.length());
    
    return ret;
}
Ejemplo n.º 23
0
void Engine::ExecuteWord(const std::string &word)
{
	Word *w = FindWord(word);
	if(w != NULL)
	{
		w->Execute(false);
		return;
	}

	// integer?
	std::istringstream is(word);
	int number;
	if(is >> number)
	{
		LiteralWord lit(number);
		lit.Execute(false);
		return;
	}

	throw std::string("unknown word");
}
Ejemplo n.º 24
0
//align 1居中 3左对齐
//currentView 10页脚 9页眉
void CmyWord::SetSeekView(const CString& text,long align, long currentView, const CString& findW)
{
	Pane mPane;
	m_activeWind = m_wdApp.GetActiveWindow();
	mPane = m_activeWind.GetActivePane();
	m_view = mPane.GetView();
	m_view.SetSeekView(currentView);
	if(!findW.IsEmpty())
	{
		FindWord(findW,text);
	}
	else
	{
		m_wdSel.TypeText(text);
	}
	_ParagraphFormat parafm = m_wdSel.GetParagraphFormat();
	parafm.SetAlignment(align);
	m_wdSel.SetParagraphFormat(parafm);
	m_view.SetSeekView(wdSeekMainDocument);
	mPane.ReleaseDispatch();
}
Ejemplo n.º 25
0
void ReadNewUser()
{
	userFirstLine = 1;
	inputCount = 0;
	ClearUserVariables();
	ResetTopicSystem();

	//   set his random seed
	bool hasUpperCharacters;
	unsigned int rand = (unsigned int) Hashit((unsigned char *) loginID,strlen(loginID),hasUpperCharacters);
	char word[MAX_WORD_SIZE];
	randIndex = rand & 4095;
    sprintf(word,"%d",randIndex);
	SetUserVariable("$randindex",word ); 
	strcpy(word,computerID);
	word[0] = toUppercaseData[(unsigned char)word[0]];
	SetUserVariable("$bot",word ); 
	SetUserVariable("$login",loginName);

	sprintf(readBuffer,"^%s",computerID);
	WORDP D = FindWord(readBuffer,0,LOWERCASE_LOOKUP);
	if (!D) 
	{
		ReportBug("Cannot find bot %s\r\n",computerID);
		return;
	}

	int oldjump = jumpIndex;
	char* macroArgumentList = AllocateBuffer();
	*macroArgumentList = 0;
	globalDepth = 2;
	unsigned int result;
	currentOutputBase = macroArgumentList;
	DoFunction(D->word,macroArgumentList,macroArgumentList,result);
	globalDepth = 0;
	jumpIndex = oldjump; //   return to  old error handler
	FreeBuffer();
}
Ejemplo n.º 26
0
/* Add one word to the dictionary.
*/
static int IndexWord(char *Word,int Follows)
{
	WORD *thisWord,*lastWord;
	int wordIndex;

	if(Word != END_SENTENCE)
	{
		thisWord = FindWord(Word);
		if(!thisWord)
		{
			thisWord = AddWord(Word);
			if(!thisWord) Niall_Error("Out of memory.");
		}
		wordIndex = WordIndex(thisWord);	
	}
	else wordIndex = -1;

	lastWord = GetWord(Follows);
	if(!lastWord) Niall_Error("Corrupted brain (Can't find last word).");
	Associate(lastWord,wordIndex);

	return(wordIndex);
}
Ejemplo n.º 27
0
void DuminoSolver::FindWord(const DuminoGrid &grid,
              DictionaryItem* item,
              cv::Point p,
              std::string word)
{

	for (int i = 0; i < 8; ++i)
	{
		cv::Point new_p = p + nbrs[i];

		if(new_p.x < 0 || new_p.x >= 5 || new_p.y < 0 || new_p.y >= 5)
			continue;

		int index = grid[new_p.y][new_p.x];
		if((item->children[index] != NULL) && !used[new_p.y][new_p.x])
		{
			used[new_p.y][new_p.x] = true;
			word.push_back(item->children[index]->value);

			if(item->children[index]->endOfWord && word.length() > 2)
			{
				if(!found_words->ContainsWord(word))
				{
					found_words->InsertWord(word);
					Type(word);	
					usleep(1000 * 100);
				}
			}

			FindWord(grid, item->children[index], new_p, word);

			word.pop_back();
			used[new_p.y][new_p.x] = false;
		}		
	}
}
Ejemplo n.º 28
0
char* SpellFix(char* originalWord,int start,uint64 posflags,int language)
{
    size_t len = strlen(originalWord);
	if (len >= 100 || len == 0) return NULL;
	if (IsDigit(*originalWord)) return NULL; // number-based words and numbers must be treated elsewhere
	char letterLow = GetLowercaseData(*originalWord);
	char letterHigh = GetUppercaseData(*originalWord);
	bool hasUnderscore = (strchr(originalWord,'_')) ? true : false;
	bool isUpper = IsUpperCase(originalWord[0]);
	if (IsUpperCase(originalWord[1])) isUpper = false;	// not if all caps
	if (trace == TRACE_SPELLING) Log(STDTRACELOG,(char*)"Spell: %s\r\n",originalWord);

	char word[MAX_WORD_SIZE];
	MakeLowerCopy(word,originalWord);

	// mark positions of the letters and make lower case
    char base[257];
    memset(base,0,257);
    char* ptr = word - 1;
    char c;
    int position = 0;
    while ((c = *++ptr) && position < 255)
    {
        base[position++ + 1] = GetLowercaseData(c);
   }

	//   Priority is to a word that looks like what the user typed, because the user probably would have noticed if it didnt and changed it. So add/delete  has priority over tranform
    WORDP choices[4000];
    WORDP bestGuess[4000];
    unsigned int index = 0;
    unsigned int bestGuessindex = 0;
    int min = 30;
	unsigned char realWordLetterCounts[LETTERMAX];
	memset(realWordLetterCounts,0,LETTERMAX); 
	for (int  i = 0; i < (int)len; ++i)  ++realWordLetterCounts[(unsigned char)letterIndexData[(unsigned char)word[i]]]; // compute number of each kind of character
	
	uint64  pos = PART_OF_SPEECH;  // all pos allowed
    WORDP D;
    if (posflags == PART_OF_SPEECH && start < wordCount) // see if we can restrict word based on next word
    {
        D = FindWord(wordStarts[start+1],0,PRIMARY_CASE_ALLOWED);
        uint64 flags = (D) ? D->properties : (-1); //   if we dont know the word, it could be anything
        if (flags & PREPOSITION) pos &= -1 ^ (PREPOSITION|NOUN);   //   prep cannot be preceeded by noun or prep
        if (!(flags & (PREPOSITION|VERB|CONJUNCTION|ADVERB)) && flags & DETERMINER) pos &= -1 ^ (DETERMINER|ADJECTIVE|NOUN|ADJECTIVE_NUMBER|NOUN_NUMBER); //   determiner cannot be preceeded by noun determiner adjective
        if (!(flags & (PREPOSITION|VERB|CONJUNCTION|DETERMINER|ADVERB)) && flags & ADJECTIVE) pos &= -1 ^ (NOUN); 
        if (!(flags & (PREPOSITION|NOUN|CONJUNCTION|DETERMINER|ADVERB|ADJECTIVE)) && flags & VERB) pos &= -1 ^ (VERB); //   we know all helper verbs we might be
        if (D && *D->word == '\'' && D->word[1] == 's' ) pos &= NOUN;    //   we can only be a noun if possessive - contracted 's should already be removed by now
    }
    if (posflags == PART_OF_SPEECH && start > 1)
    {
        D = FindWord(wordStarts[start-1],0,PRIMARY_CASE_ALLOWED);
        uint64 flags = (D) ? D->properties : (-1); // if we dont know the word, it could be anything
        if (flags & DETERMINER) pos &= -1 ^ (VERB|CONJUNCTION|PREPOSITION|DETERMINER);  
    }
    posflags &= pos; //   if pos types are known and restricted and dont match
	static int range[] = {0,-1,1,-2,2};
	for (unsigned int i = 0; i < 5; ++i)
	{
		if (language == ENGLISH && i >= 3) break;	// only allow +-2 for spanish
		MEANING offset = lengthLists[len + range[i]];
		if (trace == TRACE_SPELLING) Log(STDTRACELOG,(char*)"\r\n  Begin offset %d\r\n",i);
		while (offset)
		{
			D = Meaning2Word(offset);
			offset = D->spellNode;
			if (PART_OF_SPEECH == posflags  && D->systemFlags & PATTERN_WORD){;} // legal generic match
			else if (!(D->properties & posflags)) continue; // wrong kind of word
			if (*D->word != letterLow && *D->word != letterHigh && language == ENGLISH) continue;	// we assume no one misspells starting letter
			char* under = strchr(D->word,'_');
			// SPELLING lists have no underscore or space words in them
			if (hasUnderscore && !under) continue;	 // require keep any underscore
			if (!hasUnderscore && under) continue;	 // require not have any underscore
			if (isUpper && !(D->internalBits & UPPERCASE_HASH) && start != 1) continue;	// dont spell check to lower a word in upper
			int val = EditDistance(D, D->length, len, base+1,min,realWordLetterCounts,language);
			if (val <= min) // as good or better
			{
				if (val < min)
				{
					if (trace == TRACE_SPELLING) Log(STDTRACELOG,(char*)"    Better: %s against %s value: %d\r\n",D->word,originalWord,val);
					index = 0;
					min = val;
				}
				else if ( val == min && trace == TRACE_SPELLING) Log(STDTRACELOG,(char*)"    Equal: %s against %s value: %d\r\n",D->word,originalWord,val);

				if (!(D->internalBits & BEEN_HERE)) 
				{
					choices[index++] = D;
					if (index > 3998) break; 
					AddInternalFlag(D,BEEN_HERE);
				}
			}
		}
	}
	// try endings ing, s, etc
	if (start) // no stem spell if COMING from a stem spell attempt (start == 0)
	{
		char* stem = StemSpell(word,start);
		if (stem) 
		{
			WORDP D = FindWord(stem,0,(tokenControl & ONLY_LOWERCASE) ?  PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP);
			if (D) 
			{
				for (unsigned int j = 0; j < index; ++j) 
				{
					if (choices[j] == D) // already in our list
					{
						D = NULL; 
						break;
					}
				}
			}
			if (D) choices[index++] = D;
		}
	}

    if (!index)  return NULL; 

	// take our guesses, and pick the most common (earliest learned or most frequently used) word
    uint64 commonmin = 0;
    bestGuess[0] = NULL;
	for (unsigned int j = 0; j < index; ++j) RemoveInternalFlag(choices[j],BEEN_HERE);
    if (index == 1) 
	{
		if (trace == TRACE_SPELLING) Log(STDTRACELOG,(char*)"    Single best spell: %s\r\n",choices[0]->word);
		return choices[0]->word;	// pick the one
	}
    for (unsigned int j = 0; j < index; ++j) 
    {
        uint64 common = choices[j]->systemFlags & COMMONNESS;
        if (common < commonmin) continue;
		if (choices[j]->internalBits & UPPERCASE_HASH && index > 1) continue;	// ignore proper names for spell better when some other choice exists
        if (common > commonmin)
        {
            commonmin = common;
            bestGuessindex = 0;
        }
        bestGuess[bestGuessindex++] = choices[j];
    }
	if (bestGuessindex) 
	{
		if (trace == TRACE_SPELLING) Log(STDTRACELOG,(char*)"    Pick spell: %s\r\n",bestGuess[0]->word);
		return bestGuess[0]->word; 
	}
	return NULL;
}
Ejemplo n.º 29
0
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;
}
Ejemplo n.º 30
0
bool SpellCheckSentence()
{
	WORDP D,E;
	fixedSpell = false;
	bool lowercase = false;
	int language = ENGLISH;
	char* lang = GetUserVariable((char*)"$cs_language");
	if (lang && !stricmp(lang,(char*)"spanish")) language = SPANISH;
	
	// check for all uppercase
	for (int i = FindOOBEnd(1) + 1; i <= wordCount; ++i) // skip start of sentence
	{
		char* word = wordStarts[i];
		size_t len = strlen(word);
		for (int j = 0; j < (int)len; ++j) 
		{
			if (IsLowerCase(word[j])) 
			{
				lowercase = true;
				i = j = 1000;
			}
		}
	}
	if (!lowercase && wordCount > 2) // must have several words in uppercase
	{
		for (int i = FindOOBEnd(1); i <= wordCount; ++i)
		{
			char* word = wordStarts[i];
			MakeLowerCase(word);
		}
	}

	int startWord = FindOOBEnd(1);
	for (int i = startWord; i <= wordCount; ++i)
	{
		char* word = wordStarts[i];
		if (!word || !word[1] || *word == '"' ) continue; // illegal or single char or quoted thingy 
		size_t len = strlen(word);

		// dont spell check uppercase not at start or joined word
		if (IsUpperCase(word[0]) && (i != startWord || strchr(word,'_')) && tokenControl & NO_PROPER_SPELLCHECK) continue; 
		//  dont  spell check email or other things with @ or . in them
		if (strchr(word,'@') || strchr(word,'.') || strchr(word,'$')) continue;

		// dont spell check names of json objects or arrays
		if (!strnicmp(word,"ja-",3) || !strnicmp(word,"jo-",3)) continue;

		char* known = ProbableKnownWord(word);
		if (known && !strcmp(known,word)) continue;	 // we know it
		if (known && strcmp(known,word)) 
		{
			char* tokens[2];
			if (!IsUpperCase(*known)) // revised the word to lower case (avoid to upper case like "fields" to "Fields"
			{
				WORDP D = FindWord(known,0,LOWERCASE_LOOKUP);
				if (D) 
				{
					tokens[1] = D->word;
					ReplaceWords(i,1,1,tokens);
					fixedSpell = true;
					continue;
				}
			}
			else // is uppercase a concept member? then revise upwards
			{
				WORDP D = FindWord(known,0,UPPERCASE_LOOKUP);
				if (IsConceptMember(D))
				{
					tokens[1] = D->word;
					ReplaceWords(i,1,1,tokens);
					fixedSpell = true;		
					continue;
				}
			}
		}

		char* p = word -1;
		unsigned char c;
		char* hyphen = 0;
		while ((c = *++p) != 0)
		{ 
			++len;
			if (c == '-') hyphen = p; // note is hyphenated - use trailing
		}
		if (len == 0 || GetTemperatureLetter(word)) continue;	// bad ignore utf word or llegal length - also no composite words
		if (c && c != '@' && c != '.') // illegal word character
		{
			if (IsDigit(word[0]) || len == 1){;} // probable numeric?
			// accidental junk on end of word we do know immedately?
			else if (i > 1 && !IsAlphaUTF8OrDigit(wordStarts[i][len-1]) )
			{
				WORDP entry,canonical;
				char word[MAX_WORD_SIZE];
				strcpy(word,wordStarts[i]);
				word[len-1] = 0;
				uint64 sysflags = 0;
				uint64 cansysflags = 0;
				WORDP revise;
				GetPosData(i,word,revise,entry,canonical,sysflags,cansysflags,true,true); // dont create a non-existent word
				if (entry && entry->properties & PART_OF_SPEECH)
				{
					wordStarts[i] = reuseAllocation(wordStarts[i],entry->word);
					fixedSpell = true;
					continue;	// not a legal word character, leave it alone
				}
			}
		}

		// see if we know the other case
		if (!(tokenControl & (ONLY_LOWERCASE|STRICT_CASING)) || (i == startSentence && !(tokenControl & ONLY_LOWERCASE)))
		{
			WORDP E = FindWord(word,0,SECONDARY_CASE_ALLOWED);
			bool useAlternateCase = false;
			if (E && E->systemFlags & PATTERN_WORD) useAlternateCase = true;
			if (E && E->properties & (PART_OF_SPEECH|FOREIGN_WORD))
			{
				// if the word we find is UPPER case, and this might be a lower case noun plural, don't change case.
				size_t len = strlen(word);
				if (word[len-1] == 's' ) 
				{
					WORDP F = FindWord(word,len-1);
					if (!F || !(F->properties & (PART_OF_SPEECH|FOREIGN_WORD))) useAlternateCase = true;
					else continue;
				}
				else useAlternateCase = true;
			}
			else if (E) // does it have a member concept fact
			{
				if (IsConceptMember(E)) 
				{
					useAlternateCase = true;
					break;
				}
			}
			if (useAlternateCase)
			{
				char* tokens[2];
				tokens[1] = E->word;
				ReplaceWords(i,1,1,tokens);
				fixedSpell = true;
				continue;	
			}
		}
		
		// merge with next token?
		char join[MAX_WORD_SIZE * 3];
		if (i != wordCount && *wordStarts[i+1] != '"' )
		{
			// direct merge as a single word
			strcpy(join,word);
			strcat(join,wordStarts[i+1]);
			WORDP D = FindWord(join,0,(tokenControl & ONLY_LOWERCASE) ?  PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP);

			strcpy(join,word);
			if (!D || !(D->properties & PART_OF_SPEECH) ) // merge these two, except "going to" or wordnet composites of normal words  // merge as a compound word
			{
				strcat(join,(char*)"_");
				strcat(join,wordStarts[i+1]);
				D = FindWord(join,0,(tokenControl & ONLY_LOWERCASE) ?  PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP);
			}

			if (D && D->properties & PART_OF_SPEECH && !(D->properties & AUX_VERB)) // merge these two, except "going to" or wordnet composites of normal words
			{
				WORDP P1 = FindWord(word,0,LOWERCASE_LOOKUP);
				WORDP P2 = FindWord(wordStarts[i+1],0,LOWERCASE_LOOKUP);
				if (!P1 || !P2 || !(P1->properties & PART_OF_SPEECH) || !(P2->properties & PART_OF_SPEECH)) 
				{
					char* tokens[2];
					tokens[1] = D->word;
					ReplaceWords(i,2,1,tokens);
					fixedSpell = true;
					continue;
				}
			}
		}   

		// break apart slashed pair like eat/feed
		char* slash = strchr(word,'/');
		if (slash && slash != word && slash[1]) //   break apart word/word
		{
			if ((wordCount + 2 ) >= REAL_SENTENCE_LIMIT) continue;	// no room
			*slash = 0;
			D = StoreWord(word);
			*slash = '/';
			E = StoreWord(slash+1);
			char* tokens[4];
			tokens[1] = D->word;
			tokens[2] = "/";
			tokens[3] = E->word;
			ReplaceWords(i,1,3,tokens);
			fixedSpell = true;
			--i;
			continue;
		}

		// see if hypenated word should be separate or joined (ignore obvious adjective suffix)
		if (hyphen &&  !stricmp(hyphen,(char*)"-like"))
		{
			StoreWord(word,ADJECTIVE_NORMAL|ADJECTIVE); // accept it as a word
			continue;
		}
		else if (hyphen && (hyphen-word) > 1)
		{
			char test[MAX_WORD_SIZE];
			char first[MAX_WORD_SIZE];

			// test for split
			*hyphen = 0;
			strcpy(test,hyphen+1);
			strcpy(first,word);
			*hyphen = '-';

			WORDP E = FindWord(test,0,LOWERCASE_LOOKUP);
			WORDP D = FindWord(first,0,LOWERCASE_LOOKUP);
			if (*first == 0) 
			{
				wordStarts[i] = AllocateString(wordStarts[i] + 1); // -pieces  want to lose the leading hypen  (2-pieces)
				fixedSpell = true;
			}
			else if (D && E) //   1st word gets replaced, we added another word after
			{
				if ((wordCount + 1 ) >= REAL_SENTENCE_LIMIT) continue;	// no room
				char* tokens[3];
				tokens[1] = D->word;
				tokens[2] = E->word;
				ReplaceWords(i,1,2,tokens);
				fixedSpell = true;
				--i;
			}
			else if (!stricmp(test,(char*)"old") || !stricmp(test,(char*)"olds")) //   break apart 5-year-old
			{
				if ((wordCount + 1 ) >= REAL_SENTENCE_LIMIT) continue;	// no room
				D = StoreWord(first);
				E = StoreWord(test);
				char* tokens[3];
				tokens[1] = D->word;
				tokens[2] = E->word;
				ReplaceWords(i,1,2,tokens);
				fixedSpell = true;
				--i;
			}
			else // remove hyphen entirely?
			{
				strcpy(test,first);
				strcat(test,hyphen+1);
				D = FindWord(test,0,(tokenControl & ONLY_LOWERCASE) ?  PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP);
				if (D) 
				{
					wordStarts[i] = D->word;
					fixedSpell = true;
					--i;
				}
			}
			continue; // ignore hypenated errors that we couldnt solve, because no one mistypes a hypen
		}
		
		// leave uppercase in first position if not adjusted yet... but check for lower case spell error
		if (IsUpperCase(word[0])  && tokenControl & NO_PROPER_SPELLCHECK) 
		{
			char lower[MAX_WORD_SIZE];
			MakeLowerCopy(lower,word);
			WORDP D = FindWord(lower,0,LOWERCASE_LOOKUP);
			if (!D && i == startWord)
			{
				char* okword = SpellFix(lower,i,PART_OF_SPEECH,language); 
				if (okword)
				{
					char* tokens[2];
					WORDP E = StoreWord(okword);
					tokens[1] = E->word;
					ReplaceWords(i,1,1,tokens);
					fixedSpell = true;
				}
			}
			continue; 
		}

		if (*word != '\'' && (!FindCanonical(word, i,true) || IsUpperCase(word[0]))) // dont check quoted or findable words unless they are capitalized
		{
			word = SpellCheck(i,language);

			// dont spell check proper names to improper, if word before or after is lower case originally
			if (word && i != 1 && originalCapState[i] && !IsUpperCase(*word))
			{
				if (!originalCapState[i-1]) return false;
				else if (i != wordCount && !originalCapState[i+1]) return false;
			}

			if (word && !*word) // performed substitution on prior word, restart this one
			{
				fixedSpell = true;
				--i;
				continue;
			}
			if (word) 
			{
				char* tokens[2];
				tokens[1] = word;
				ReplaceWords(i,1,1,tokens);
				fixedSpell = true;
				continue;
			}
		}
    }
	return fixedSpell;
}