char* LibpinyinGetSentence(FcitxLibpinyin* libpinyin) { char* sentence = NULL; pinyin_get_sentence(libpinyin->inst, &sentence); return sentence; }
int main(int argc, char * argv[]){ pinyin_context_t * context = pinyin_init("../data", "../data"); pinyin_instance_t * instance = pinyin_alloc_instance(context); char* linebuf = NULL; size_t size = 0; ssize_t read; while( (read = getline(&linebuf, &size, stdin)) != -1 ){ if ( '\n' == linebuf[strlen(linebuf) - 1] ) { linebuf[strlen(linebuf) - 1] = '\0'; } if ( strcmp ( linebuf, "quit" ) == 0) break; pinyin_parse_more_chewings (instance, linebuf); pinyin_guess_sentence(instance); char * sentence = NULL; pinyin_get_sentence (instance, &sentence); if (sentence) printf("%s\n", sentence); g_free(sentence); pinyin_train(instance); pinyin_reset(instance); pinyin_save(context); } pinyin_free_instance(instance); pinyin_mask_out(context, 0x0, 0x0); pinyin_save(context); pinyin_fini(context); free(linebuf); return 0; }