From a7a06a7ccfe0af1e134357678b8fa6cf87dff3b0 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Sat, 7 Feb 2009 16:32:56 +0000 Subject: anthy-9100h --- test/prediction.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/prediction.c (limited to 'test/prediction.c') diff --git a/test/prediction.c b/test/prediction.c new file mode 100644 index 0000000..dfcaae6 --- /dev/null +++ b/test/prediction.c @@ -0,0 +1,57 @@ +#include +#include +#include + + +/* Makefile の $(srcdir) (静的データファイルの基準ディレクトリ) */ +#ifndef SRCDIR +# define SRCDIR "." +#endif + +static void +init_lib(void) +{ + /* 既にインストールされているファイルの影響を受けないようにする */ + anthy_conf_override("CONFFILE", "../anthy-conf"); + anthy_conf_override("DEPWORD", "master.depword"); + anthy_conf_override("DEPGRAPH", "../depgraph/anthy.dep"); + anthy_conf_override("DIC_FILE", "../mkanthydic/anthy.dic"); + anthy_conf_override("ANTHYDIR", SRCDIR "/../depgraph"); + if (anthy_init()) { + printf("failed to init anthy\n"); + exit(0); + } +} + + +int main(int argc, char** argv) +{ + struct anthy_prediction_stat ps; + anthy_context_t ac; + int i; + + if (argc == 1) { + return 0; + } + init_lib(); + ac = anthy_create_context(); + + anthy_set_prediction_string(ac, argv[1]); + anthy_get_prediction_stat(ac, &ps); + for (i = 0; i < ps.nr_prediction; ++i) { + char* buf; + int len; + len = anthy_get_prediction(ac, i, NULL, 0); + buf = malloc(sizeof(char) * (len + 1)); + len = anthy_get_prediction(ac, i, buf, len + 1); + printf("%s, %d\n", buf, len); + free(buf); + } + anthy_commit_prediction(ac, 0); + + anthy_release_context(ac); + + anthy_quit(); + + return 0; +} -- cgit v1.2.1