コード例 #1
0
ファイル: tree.c プロジェクト: chiehwen/libchewing
static void LoadChar( ChewingData *pgdata, char *buf, int buf_len, uint16_t phoneSeq[], int nPhoneSeq )
{
	int i;
	Word word;

	memset(buf, 0, buf_len);
	for ( i = 0; i < nPhoneSeq; i++ ) {
		GetCharFirst( pgdata, &word, phoneSeq[ i ] );
		strncat(buf, word.word, buf_len - strlen(buf) - 1);
	}
	buf[ buf_len - 1 ] = '\0';
}
コード例 #2
0
ファイル: tree.c プロジェクト: Seachaos/libchewing
static void LoadChar( char *buf, int buf_len, uint16 phoneSeq[], int nPhoneSeq )
{
	int i;
	Word word;

	memset(buf, 0, buf_len);
	for ( i = 0; i < nPhoneSeq; i++ ) {
		GetCharFirst( &word, phoneSeq[ i ] );
		strncat(buf, word.word, buf_len);
	}
	buf[ buf_len - 1 ] = '\0';
}
コード例 #3
0
ファイル: choice.c プロジェクト: kanru/libchewing
static void ChoiceInfoAppendChi( ChewingData *pgdata,  ChoiceInfo *pci, uint16_t phone )
{
	Word tempWord;
	GetCharFirst( pgdata, &tempWord, phone );
	do {
		if ( ChoiceTheSame( pci, tempWord.word,
		                    ueBytesFromChar( tempWord.word[ 0 ] ) * sizeof( char ) ) )
			continue;
		memcpy( 
			pci->totalChoiceStr[ pci->nTotalChoice ],
			tempWord.word, ueBytesFromChar( tempWord.word[ 0 ] ) * sizeof( char ) );
		assert( pci->nTotalChoice <= MAX_CHOICE );
		pci->totalChoiceStr[ pci->nTotalChoice ]
		                   [ ueBytesFromChar( tempWord.word[ 0 ] ) ] = '\0';
		pci->nTotalChoice++;
	} while ( GetCharNext( pgdata, &tempWord ) );
}
コード例 #4
0
ファイル: choice.c プロジェクト: Brli/libchewing
static void ChoiceInfoAppendChi(ChewingData *pgdata, ChoiceInfo *pci, uint16_t phone)
{
    Phrase tempWord;
    int len;

    if (GetCharFirst(pgdata, &tempWord, phone)) {
        do {
            len = ueBytesFromChar(tempWord.phrase[0]);
            if (ChoiceTheSame(pci, tempWord.phrase, len))
                continue;
            assert(pci->nTotalChoice < MAX_CHOICE);
            memcpy(pci->totalChoiceStr[pci->nTotalChoice], tempWord.phrase, len);
            pci->totalChoiceStr[pci->nTotalChoice]
                [len] = '\0';
            pci->nTotalChoice++;
        } while (GetVocabNext(pgdata, &tempWord));
    }
}
コード例 #5
0
ファイル: zuin.c プロジェクト: descent/jmcce
int EndKeyProcess(ZuinData *pZuin, int key, int searchTimes)
{
  uint16 u16Pho ;
  Word tempword ;

  if(pZuin->pho_inx[0]==0 && pZuin->pho_inx[1]==0 && pZuin->pho_inx[2]==0)
    return ZUIN_KEY_ERROR ;

  pZuin->pho_inx[3] = Key2PhoneInx(key, 3, pZuin->kbtype, searchTimes) ;
  u16Pho = PhoneInx2Uint(pZuin->pho_inx) ;
  if( GetCharFirst(&tempword, u16Pho)==0 ) {
    ZuinRemoveAll(pZuin);
    return ZUIN_NO_WORD;
  }
  else {
    pZuin->phone = u16Pho;
    memset(pZuin->pho_inx, 0, sizeof(pZuin->pho_inx)) ;
    return ZUIN_COMMIT;
  }
}
コード例 #6
0
ファイル: choice.c プロジェクト: bryanyuan2/citc
/** @brief Loading all possible phrases of certain length.
 *
 *	   Loading all possible phrases of certain length into ChoiceInfo structure from static
 *	   and dynamic dictionaries,\n
 *	   including number of total pages and the number of current page.\n
 */
static void SetChoiceInfo(
		ChoiceInfo *pci,AvailInfo *pai, uint16 *phoneSeq, int cursor,
		int candPerPage )
{
	Word tempWord;
	Phrase tempPhrase;
	int len;
	UserPhraseData *pUserPhraseData;
	uint16 userPhoneSeq[ MAX_PHONE_SEQ_LEN ];
	
	/* Clears previous candidates. */
	memset( pci->totalChoiceStr, '\0', sizeof(char) * MAX_CHOICE * MAX_PHRASE_LEN * MAX_UTF8_SIZE + 1);

	pci->nTotalChoice = 0;
	len = pai->avail[ pai->currentAvail ].len;
	assert(len);

	/* secondly, read tree phrase */
	if ( len == 1 ) { /* single character */
		GetCharFirst( &tempWord, phoneSeq[ cursor ] );
		do {
			if ( ChoiceTheSame( pci, tempWord.word, ueBytesFromChar( tempWord.word[0] ) * sizeof( char ) ) ) 
				continue;
			memcpy( 
				pci->totalChoiceStr[ pci->nTotalChoice ],
				tempWord.word, ueBytesFromChar( tempWord.word[0] ) * sizeof( char ) );
			assert(pci->nTotalChoice <= MAX_CHOICE);
			pci->totalChoiceStr[ pci->nTotalChoice ][ ueBytesFromChar( tempWord.word[0] ) ] = '\0';
			pci->nTotalChoice++;
		} while( GetCharNext( &tempWord ) );
	}
	/* phrase */
	else {
		if ( pai->avail[ pai->currentAvail ].id != -1 ) {
			GetPhraseFirst( &tempPhrase, pai->avail[ pai->currentAvail ].id );
			do {
				if ( ChoiceTheSame( 
					pci, 
					tempPhrase.phrase, 
					len * ueBytesFromChar( tempPhrase.phrase[0] ) * sizeof( char ) ) ) {
					continue;
				}
				ueStrNCpy( pci->totalChoiceStr[ pci->nTotalChoice ],
						tempPhrase.phrase, len, 1);
				pci->nTotalChoice++;
			} while( GetPhraseNext( &tempPhrase ) );
		}

		memcpy( userPhoneSeq, &phoneSeq[ cursor ], sizeof( uint16 ) * len );
		userPhoneSeq[ len ] = 0;
		pUserPhraseData = UserGetPhraseFirst( userPhoneSeq );
		if ( pUserPhraseData ) {
			do {
				/* check if the phrase is already in the choice list */
				if ( ChoiceTheSame( 
					pci, 
					pUserPhraseData->wordSeq, 
					len * ueBytesFromChar( pUserPhraseData->wordSeq[0] ) * sizeof( char ) ) )
					continue;
				/* otherwise store it */
				ueStrNCpy(
						pci->totalChoiceStr[ pci->nTotalChoice ],
						pUserPhraseData->wordSeq,
						len, 1);
				pci->nTotalChoice++;
			} while( ( pUserPhraseData = 
				UserGetPhraseNext( userPhoneSeq ) ) != NULL );
		}

	}

	/* magic number */
	pci->nChoicePerPage = candPerPage;
	if ( pci->nChoicePerPage > MAX_SELKEY )
		pci->nChoicePerPage = MAX_SELKEY;
	pci->nPage = CEIL_DIV( pci->nTotalChoice, pci->nChoicePerPage );
	pci->pageNo = 0;
}