1 /* ¥³¡¼¥Ñ¥¹¤«¤éÁ«°Ü¹ÔÎó¤òºî¤ë¤¿¤á¤Î¥³¡¼¥É
3 * Copyright (C) 2005-2006 TABATA Yusuke
4 * Copyright (C) 2005-2006 YOSHIDA Yuichi
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <anthy/anthy.h>
26 /* for print_context_info() */
27 #include <anthy/convdb.h>
33 static void read_file(struct test_context *tc, const char *fn);
34 extern void anthy_reload_record(void);
41 init_test_context(struct test_context *tc)
43 tc->ac = anthy_create_context();
44 anthy_set_reconversion_mode(tc->ac, ANTHY_RECONVERT_ALWAYS);
46 anthy_context_set_encoding(tc->ac, ANTHY_UTF8_ENCODING);
48 anthy_reload_record();
52 conv_sentence(struct test_context *tc, const char *str)
54 anthy_set_string(tc->ac, str);
56 anthy_print_context(tc->ac);
59 print_context_info(tc->ac, NULL);
62 /* ¹ÔËö¤Î²þ¹Ô¤òºï½ü */
66 int len = strlen(buf);
68 char c = buf[len - 1];
69 if (c == '\n' || c == '\r' || c == ' ' || c == '\t') {
79 read_fp(struct test_context *tc, FILE *fp)
82 while (fgets(buf, 1024, fp)) {
87 if (!strncmp(buf, "\\include ", 9)) {
88 read_file(tc, &buf[9]);
92 conv_sentence(tc, buf);
97 read_file(struct test_context *tc, const char *fn)
102 printf("failed to open (%s)\n", fn);
112 printf("morphological analyzer\n");
113 printf(" $ ./morphological analyzer < [text-file]\n or");
114 printf(" $ ./morphological analyzer [text-file]\n");
119 parse_args(int argc, char **argv)
122 for (i = 1; i < argc; i++) {
124 if (!strcmp(arg, "--utf8")) {
126 } else if (arg[i] == '-') {
133 main(int argc, char **argv)
135 struct test_context tc;
138 anthy_set_personality("");
139 init_test_context(&tc);
141 /*read_file(&tc, "index.txt");*/
142 parse_args(argc, argv);
145 for (i = 1; i < argc; i++) {
146 read_file(&tc, argv[i]);