コード例 #1
0
void InitDictionary()
{
	TNode *head= NULL;
	head = CreateNode();

	ReadData(head);

	cout<<SearchDictionary("a", head)<<endl;

}
コード例 #2
0
ファイル: imcrvmgr.cpp プロジェクト: kozo2/tsf-tutcode
void SrvProc(WCHAR command, const std::wstring &argument, std::wstring &result)
{
	SKKDICCANDIDATES sc;
	std::wstring fmt, key, keyorg, okuri, candidate, annotation, conv;
	std::wregex re;

	result.clear();

	switch(command)
	{
	case REQ_SEARCH:
	case REQ_SEARCHUSER:
		re.assign(L"(.*)\t(.*)\t(.*)\n");
		fmt.assign(L"$1");
		key = std::regex_replace(argument, re, fmt);
		fmt.assign(L"$2");
		keyorg = std::regex_replace(argument, re, fmt);
		fmt.assign(L"$3");
		okuri = std::regex_replace(argument, re, fmt);

		switch(command)
		{
		case REQ_SEARCH:
			SearchDictionary(key, okuri, sc);
			break;
		case REQ_SEARCHUSER:
			candidate = SearchUserDic(key, okuri);
			re.assign(L"[\\x00-\\x19]");
			fmt.assign(L"");
			candidate = std::regex_replace(candidate, re, fmt);
			ParseSKKDicCandiate(candidate, sc);
			break;
		default:
			break;
		}

		if(!sc.empty())
		{
			result = REP_OK;
			result += L"\n";
			FORWARD_ITERATION_I(sc_itr, sc)
			{
				result += ConvertCandidate(keyorg, sc_itr->first, okuri) + L"\t" +
					sc_itr->first + L"\t" +
					ConvertCandidate(keyorg, sc_itr->second, okuri) + L"\t" +
					sc_itr->second + L"\n";
			}
		}
コード例 #3
0
ファイル: lang.c プロジェクト: dervish77/adgf
/*  ParseSentence	- parses specified sentence into separate words
 *
 *  Parameters:
 *	dictionary	- pointer to dictionary structure
 *	sentence	- pointer to sentence structure
 *
 *  Returns:
 *	error flag	- TRUE, if there was an error
 */
BOOLEAN_T 
ParseSentence( DICTIONARY_S_T *dictionary, SENTENCE_S_T *sentence )
{
   int i, word_count, index;
   char *buffer, *word_array[MAX_WORDS_IN_SENT];


   printf( "\nParsing sentence ->   %s\n", sentence->sentence );

   buffer = &sentence->sentence[0];
   sentence->sentence[SENTENCE_LEN - 1] = '\0';

   word_count = ParseString( buffer, word_array );

   sentence->num_words = word_count;

   for (i = 0; i < sentence->num_words; i++)
   {
      sentence->list[i].length = strlen( word_array[i] );

      strcpy(sentence->list[i].word, word_array[i]);

      if (SearchDictionary( &sentence->list[i].word[0], dictionary, &index ))
      {
         sentence->list[i].type = dictionary->list[index].type;
         sentence->list[i].str = dictionary->list[index].str;
      }
      else
      {
         sentence->list[i].type = UNKN_WT;
         sentence->list[i].str = ' ';

         printf("\nwarning:  %s not found in dictionary\n", word_array[i]);
      }
   }

   return(FALSE);
}