summaryrefslogtreecommitdiff
path: root/anthy
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2009-02-07 16:32:56 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2009-02-07 16:32:56 +0000
commita7a06a7ccfe0af1e134357678b8fa6cf87dff3b0 (patch)
treea966aeee62e69ae3ad13275d07ddb15049b14e0e /anthy
downloadanthy-a7a06a7ccfe0af1e134357678b8fa6cf87dff3b0.tar.gz
Diffstat (limited to 'anthy')
-rw-r--r--anthy/Makefile.am12
-rw-r--r--anthy/Makefile.in409
-rw-r--r--anthy/alloc.h43
-rw-r--r--anthy/anthy.h104
-rw-r--r--anthy/conf.h11
-rw-r--r--anthy/convdb.h61
-rw-r--r--anthy/corpus.h25
-rw-r--r--anthy/depgraph.h68
-rw-r--r--anthy/dic.h80
-rw-r--r--anthy/diclib.h18
-rw-r--r--anthy/dicutil.h49
-rw-r--r--anthy/feature_set.h56
-rw-r--r--anthy/filemap.h14
-rw-r--r--anthy/input.h136
-rw-r--r--anthy/logger.h8
-rw-r--r--anthy/matrix.h26
-rw-r--r--anthy/ordering.h27
-rw-r--r--anthy/prediction.h18
-rw-r--r--anthy/record.h98
-rw-r--r--anthy/ruleparser.h19
-rw-r--r--anthy/segclass.h50
-rw-r--r--anthy/segment.h101
-rw-r--r--anthy/splitter.h126
-rw-r--r--anthy/textdict.h15
-rw-r--r--anthy/texttrie.h24
-rw-r--r--anthy/word_dic.h42
-rw-r--r--anthy/wtype.h232
-rw-r--r--anthy/xchar.h165
-rw-r--r--anthy/xstr.h109
29 files changed, 2146 insertions, 0 deletions
diff --git a/anthy/Makefile.am b/anthy/Makefile.am
new file mode 100644
index 0000000..8f905e4
--- /dev/null
+++ b/anthy/Makefile.am
@@ -0,0 +1,12 @@
+pkginclude_HEADERS = anthy.h dicutil.h input.h
+noinst_HEADERS = xstr.h xchar.h dic.h wtype.h\
+ conf.h record.h alloc.h\
+ ruleparser.h splitter.h \
+ segment.h ordering.h \
+ filemap.h \
+ logger.h segclass.h \
+ depgraph.h \
+ texttrie.h textdict.h matrix.h \
+ prediction.h word_dic.h \
+ diclib.h feature_set.h \
+ corpus.h convdb.h
diff --git a/anthy/Makefile.in b/anthy/Makefile.in
new file mode 100644
index 0000000..ad54ae7
--- /dev/null
+++ b/anthy/Makefile.in
@@ -0,0 +1,409 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = anthy
+DIST_COMMON = $(noinst_HEADERS) $(pkginclude_HEADERS) \
+ $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkgincludedir)"
+pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(noinst_HEADERS) $(pkginclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ELISP_FALSE = @ELISP_FALSE@
+ELISP_TRUE = @ELISP_TRUE@
+EMACS = @EMACS@
+EMACSLOADPATH = @EMACSLOADPATH@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+lispdir = @lispdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+pkginclude_HEADERS = anthy.h dicutil.h input.h
+noinst_HEADERS = xstr.h xchar.h dic.h wtype.h\
+ conf.h record.h alloc.h\
+ ruleparser.h splitter.h \
+ segment.h ordering.h \
+ filemap.h \
+ logger.h segclass.h \
+ depgraph.h \
+ texttrie.h textdict.h matrix.h \
+ prediction.h word_dic.h \
+ diclib.h feature_set.h \
+ corpus.h convdb.h
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu anthy/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu anthy/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+install-pkgincludeHEADERS: $(pkginclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)"
+ @list='$(pkginclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
+ $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
+ done
+
+uninstall-pkgincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkginclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgincludedir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pkgincludeHEADERS
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-pkgincludeHEADERS
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool ctags distclean distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-exec install-exec-am install-info \
+ install-info-am install-man install-pkgincludeHEADERS \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-info-am \
+ uninstall-pkgincludeHEADERS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/anthy/alloc.h b/anthy/alloc.h
new file mode 100644
index 0000000..e03d1b3
--- /dev/null
+++ b/anthy/alloc.h
@@ -0,0 +1,43 @@
+/*
+ * 構造体allocator
+ * ソースコード中ではatorと略することがある
+ */
+#ifndef _alloc_h_included_
+#define _alloc_h_included_
+
+/** アロケータのハンドル */
+typedef struct allocator_priv * allocator;
+
+/*
+ * allocatorを作る
+ * s: 構造体のsize(バイト数)
+ * dtor: =destructor 確保したオブジェクトが解放されるときに呼ばれる関数
+ * dtorの引数は解放されるオブジェクト
+ * 返り値: 作成したallocator
+ */
+allocator anthy_create_allocator(int s, void (*dtor)(void *));
+
+/*
+ * allocatorを解放する
+ * この際に、このallocatorから確保されたオブジェクトは全て解放される
+ * a: 解放するallocator
+ */
+void anthy_free_allocator(allocator a);
+
+/*
+ * オブジェクトを確保する
+ * a: allocator
+ * 返り値: 確保したオブジェクトのアドレス
+ */
+void *anthy_smalloc(allocator a);
+/*
+ * オブジェクトを解放する
+ * a: allocator
+ * p: 解放するオブジェクトのアドレス
+ */
+void anthy_sfree(allocator a, void *p);
+
+/* 全てのallocatorを破棄する */
+void anthy_quit_allocator(void);
+
+#endif
diff --git a/anthy/anthy.h b/anthy/anthy.h
new file mode 100644
index 0000000..6ee3208
--- /dev/null
+++ b/anthy/anthy.h
@@ -0,0 +1,104 @@
+/*
+ * Anthy library interface
+ * Anthy is a KanaKanji conversion engine (Library for Japanese Input Method)
+ *
+ * please read doc/LIB file in source package.
+ *
+ * Most of declarations are public interface.
+ * So, be careful if you want to modify this file.
+ *
+ * $Id: anthy.h,v 1.6 2002/03/05 02:45:32 gniibe Exp $
+ */
+#ifndef _anthy_h_included_
+#define _anthy_h_included_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Data types */
+struct anthy_conv_stat {
+ int nr_segment;
+};
+
+struct anthy_segment_stat {
+ int nr_candidate;
+ int seg_len;
+};
+
+struct anthy_prediction_stat {
+ int nr_prediction;
+};
+
+typedef struct anthy_context *anthy_context_t;
+
+
+
+/* constants */
+#define NTH_UNCONVERTED_CANDIDATE -1
+#define NTH_KATAKANA_CANDIDATE -2
+#define NTH_HIRAGANA_CANDIDATE -3
+#define NTH_HALFKANA_CANDIDATE -4
+/* encoding constants */
+#define ANTHY_COMPILED_ENCODING 0
+#define ANTHY_EUC_JP_ENCODING 1
+#define ANTHY_UTF8_ENCODING 2
+/* reconvert mode */
+#define ANTHY_RECONVERT_AUTO 0
+#define ANTHY_RECONVERT_DISABLE 1
+#define ANTHY_RECONVERT_ALWAYS 2
+
+/* Configuration */
+extern int anthy_init(void);
+extern void anthy_quit(void);
+extern void anthy_conf_override(const char *, const char *);
+extern int anthy_set_personality(const char *);
+
+
+
+/* Context management */
+extern anthy_context_t anthy_create_context(void);
+extern void anthy_reset_context(anthy_context_t);
+extern void anthy_release_context(anthy_context_t);
+
+
+
+/* Conversion control */
+extern int anthy_set_string(anthy_context_t, const char *);
+/* nth,resize ie. +1,-1 */
+extern void anthy_resize_segment(anthy_context_t, int, int);
+extern int anthy_get_stat(anthy_context_t, struct anthy_conv_stat *);
+extern int anthy_get_segment_stat(anthy_context_t, int, struct anthy_segment_stat *);
+/* context,nth segment,nth candidate,buffer,buffer len */
+extern int anthy_get_segment(anthy_context_t, int, int, char *, int);
+/* 一文節ごとにコミットする */
+extern int anthy_commit_segment(anthy_context_t, int, int);
+
+/* Prediction */
+#define HAS_ANTHY_PREDICTION
+extern int anthy_set_prediction_string(anthy_context_t, const char*);
+extern int anthy_get_prediction_stat(anthy_context_t, struct anthy_prediction_stat *);
+/* context, nth prediction, buffer, buffer len*/
+extern int anthy_get_prediction(anthy_context_t, int, char*, int);
+#define HAS_ANTHY_COMMIT_PREDICTION
+extern int anthy_commit_prediction(anthy_context_t, int);
+
+/* Etc */
+extern void anthy_print_context(anthy_context_t);
+
+extern const char *anthy_get_version_string (void);
+typedef void (*anthy_logger)(int level, const char *);
+extern void anthy_set_logger(anthy_logger , int level);
+
+/* experimental and unstable */
+#define HAS_ANTHY_CONTEXT_SET_ENCODING
+extern int anthy_context_set_encoding(anthy_context_t ac, int encoding);
+#define HAS_ANTHY_SET_RECONVERSION_MODE
+extern int anthy_set_reconversion_mode(anthy_context_t ac, int mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/anthy/conf.h b/anthy/conf.h
new file mode 100644
index 0000000..0fe5a61
--- /dev/null
+++ b/anthy/conf.h
@@ -0,0 +1,11 @@
+/* $B@_Dj$r<hF@$9$k$?$a$N%$%s%?%U%'!<%9(B */
+#ifndef _conf_h_included_
+#define _conf_h_included_
+
+void anthy_do_conf_init(void);
+void anthy_do_conf_override(const char *, const char *);
+void anthy_conf_free(void);
+
+const char *anthy_conf_get_str(const char *var);
+
+#endif
diff --git a/anthy/convdb.h b/anthy/convdb.h
new file mode 100644
index 0000000..014a8ee
--- /dev/null
+++ b/anthy/convdb.h
@@ -0,0 +1,61 @@
+/* 変換結果のデータベース */
+#ifndef _convdb_h_included_
+#define _convdb_h_included_
+
+#include <anthy/anthy.h>
+
+/* 不明, OK, 誤変換, don't careの4つのカテゴリーに分類する */
+#define CHK_UNKNOWN 0
+#define CHK_OK 1
+#define CHK_MISS 2
+#define CHK_DONTCARE 3
+
+/**/
+#define CONV_OK 0
+#define CONV_SIZE_MISS 1
+#define CONV_CAND_MISS 2
+#define CONV_INVALID 4
+
+/* 変換前と変換後の文字列、結果に対する判定を格納する */
+struct conv_res {
+ /* 検索のキー */
+ char *src_str;
+ char *res_str;
+ /* 候補を割り当てたもの */
+ char *cand_str;
+ /**/
+ int *cand_check;
+ /**/
+ int check;
+ int used;
+ /**/
+ struct conv_res *next;
+};
+
+/* 変換結果のカウント */
+struct res_stat {
+ int unknown;
+ int ok;
+ int miss;
+ int dontcare;
+};
+
+/* 変換結果のデータベース */
+struct res_db {
+ /**/
+ struct conv_res res_list;
+ struct conv_res *tail;
+ /**/
+ int total;
+ struct res_stat res, split;
+};
+
+struct res_db *create_db(void);
+void read_db(struct res_db *db, const char *fn);
+struct conv_res *find_conv_res(struct res_db *db, anthy_context_t ac,
+ const char *src, int conv);
+void print_size_miss_segment_info(anthy_context_t ac, int nth);
+void print_cand_miss_segment_info(anthy_context_t ac, int nth);
+void print_context_info(anthy_context_t ac, struct conv_res *cr);
+
+#endif
diff --git a/anthy/corpus.h b/anthy/corpus.h
new file mode 100644
index 0000000..45c8391
--- /dev/null
+++ b/anthy/corpus.h
@@ -0,0 +1,25 @@
+/* コーパスの構築及びアクセスを行う */
+#ifndef _corpus_h_included_
+#define _corpus_h_included_
+
+#include <stdio.h>
+
+struct corpus;
+
+#define ELM_NONE 0
+#define ELM_BOS 0x10000000
+#define ELM_WORD_BORDER 0x20000000
+#define ELM_INVALID 0x40000000
+
+/* hash値の下位28bitを使う */
+#define CORPUS_KEY_MASK 0x0fffffff
+
+/* コーパス構築用の関数 */
+struct corpus *corpus_new(void);
+void corpus_push_back(struct corpus *c, int *val, int nr, int flags);
+void corpus_build(struct corpus *c);
+void corpus_dump(struct corpus *c);
+void corpus_write_bucket(FILE *fp, struct corpus *c);
+void corpus_write_array(FILE *fp, struct corpus *c);
+
+#endif
diff --git a/anthy/depgraph.h b/anthy/depgraph.h
new file mode 100644
index 0000000..59f0dd5
--- /dev/null
+++ b/anthy/depgraph.h
@@ -0,0 +1,68 @@
+/* 付属語グラフのデータ構造 */
+#ifndef _depgraph_h_included_
+#define _depgraph_h_included_
+
+#include <anthy/segclass.h>
+#include <anthy/wtype.h>
+
+struct dep_transition {
+ /** 遷移先のノードの番号 0の場合は終端 */
+ int next_node;
+ /** 品詞 */
+ int pos;
+ /** 活用形 */
+ int ct;
+ /* 付属語クラス */
+ enum dep_class dc;
+
+ int head_pos;
+ int weak;
+};
+
+typedef int ondisk_xstr;
+
+struct dep_branch {
+ /* 遷移条件の付属語の配列 */
+ /** 配列長 */
+ int nr_strs;
+ /** 遷移条件の配列 */
+ xstr **str;
+ ondisk_xstr *xstrs;
+
+ /** 遷移先のノード */
+ int nr_transitions;
+ struct dep_transition *transition;
+};
+
+struct dep_node {
+ int nr_branch;
+ struct dep_branch *branch;
+};
+
+/** 自立語の品詞とその後に続く付属語のグラフ中のノードの対応 */
+struct wordseq_rule {
+ wtype_t wt; /* 自立語の品詞 */
+ int node_id; /* この自立語の後ろに続く付属語グラフ中のノードのid */
+};
+
+/** 付属語グラフのファイル上での形式 */
+struct ondisk_wordseq_rule {
+ char wt[8];
+ /* ネットワークバイトオーダー */
+ int node_id;
+};
+
+/* 付属語グラフ */
+struct dep_dic {
+ char* file_ptr;
+
+ int nrRules;
+ int nrNodes;
+
+ /* 自立語からの接続ルール */
+ struct ondisk_wordseq_rule *rules;
+ /* 付属語間の接続ルール */
+ struct dep_node* nodes;
+};
+
+#endif
diff --git a/anthy/dic.h b/anthy/dic.h
new file mode 100644
index 0000000..6105999
--- /dev/null
+++ b/anthy/dic.h
@@ -0,0 +1,80 @@
+/*
+ * 辞書モジュールのインターフェース
+ */
+#ifndef _dic_h_included_
+#define _dic_h_included_
+
+#include "xstr.h"
+#include "wtype.h"
+
+/** 辞書の読みに対するハンドル(sequence entry) */
+typedef struct seq_ent *seq_ent_t;
+/***/
+typedef struct dic_ent *compound_ent_t;
+
+/* 全体の初期化、解放 */
+int anthy_init_dic(void);
+void anthy_quit_dic(void);
+
+/* 他プロセスに対する排他制御 */
+void anthy_lock_dic(void);
+void anthy_unlock_dic(void);
+
+/**/
+void anthy_gang_load_dic(xstr *xs, int is_reverse);
+
+/* 文字列の取得 */
+seq_ent_t anthy_get_seq_ent_from_xstr(xstr *xs, int is_reverse);
+/* 文字列の情報 */
+int anthy_get_nr_dic_ents(seq_ent_t se, xstr *xs);
+int anthy_has_compound_ents(seq_ent_t se);
+int anthy_has_non_compound_ents(seq_ent_t se);
+int anthy_get_nth_dic_ent_is_compound(seq_ent_t se, int nth);
+/* 非複合語 */
+/* caller should free @res */
+int anthy_get_nth_dic_ent_str(seq_ent_t, xstr *orig, int, xstr *res);
+int anthy_get_nth_dic_ent_freq(seq_ent_t, int nth);
+int anthy_get_nth_dic_ent_wtype(seq_ent_t, xstr *, int nth, wtype_t *w);
+/* 品詞 */
+int anthy_get_seq_ent_pos(seq_ent_t, int pos);
+int anthy_get_seq_ent_ct(seq_ent_t, int pos, int ct);
+int anthy_get_seq_ent_wtype_freq(seq_ent_t, wtype_t);
+int anthy_get_seq_ent_indep(seq_ent_t se);
+/* 複合語 */
+compound_ent_t anthy_get_nth_compound_ent(seq_ent_t se, int nth);
+int anthy_get_seq_ent_wtype_compound_freq(seq_ent_t se, wtype_t wt);
+/**/
+int anthy_compound_get_wtype(compound_ent_t, wtype_t *w);
+int anthy_compound_get_freq(compound_ent_t ce);
+int anthy_compound_get_nr_segments(compound_ent_t ce);
+int anthy_compound_get_nth_segment_len(compound_ent_t ce, int nth);
+int anthy_compound_get_nth_segment_xstr(compound_ent_t ce, int nth, xstr *xs);
+
+
+
+/** 辞書セッション
+ *
+ */
+typedef struct mem_dic *dic_session_t;
+/*typedef struct dic_session *dic_session_t;*/
+
+dic_session_t anthy_dic_create_session(void);
+void anthy_dic_activate_session(dic_session_t );
+void anthy_dic_release_session(dic_session_t);
+
+/* personality */
+void anthy_dic_set_personality(const char *);
+/**/
+#define ANON_ID ""
+
+
+/** 用例辞書
+ */
+int anthy_dic_check_word_relation(int from, int to);
+
+/** 未知語の学習
+ */
+void anthy_add_unknown_word(xstr *yomi, xstr *word);
+void anthy_forget_unused_unknown_word(xstr *xs);
+
+#endif
diff --git a/anthy/diclib.h b/anthy/diclib.h
new file mode 100644
index 0000000..145f37c
--- /dev/null
+++ b/anthy/diclib.h
@@ -0,0 +1,18 @@
+#ifndef __diclib_h_included__
+#define __diclib_h_included__
+
+
+/* 全体の初期化、解放 */
+int anthy_init_diclib(void);
+void anthy_quit_diclib(void);
+
+void* anthy_file_dic_get_section(const char* section_name);
+
+/*
+ utility
+ */
+unsigned int anthy_dic_ntohl(unsigned int a);
+unsigned int anthy_dic_htonl(unsigned int a);
+
+
+#endif
diff --git a/anthy/dicutil.h b/anthy/dicutil.h
new file mode 100644
index 0000000..b75c71a
--- /dev/null
+++ b/anthy/dicutil.h
@@ -0,0 +1,49 @@
+/*
+ * Interface for personal dictionary
+ */
+#ifndef _dicutil_h_included_
+#define _dicutil_h_included_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* 返り値 / anthy_priv_dic_add_entry*/
+/* OK / 単語が登録できた */
+#define ANTHY_DIC_UTIL_OK 0
+/* 失敗 / 登録に失敗した */
+#define ANTHY_DIC_UTIL_ERROR -1
+/* 同じ単語が登録してあった、頻度だけを上書き */
+#define ANTHY_DIC_UTIL_DUPLICATE -2
+/* 辞書が存在しない */
+#define ANTHY_DIC_UTIL_INVALID -3
+
+void anthy_dic_util_init(void);
+void anthy_dic_util_quit(void);
+void anthy_dic_util_set_personality(const char *);
+const char *anthy_dic_util_get_anthydir(void);
+#define HAS_ANTHY_DICUTIL_SET_ENCODING
+int anthy_dic_util_set_encoding(int );
+
+void anthy_priv_dic_delete(void);
+int anthy_priv_dic_select_first_entry(void);
+int anthy_priv_dic_select_next_entry(void);
+int anthy_priv_dic_select_entry(const char *);/* not implemented */
+
+char *anthy_priv_dic_get_index(char *buf, int len);
+int anthy_priv_dic_get_freq(void);
+char *anthy_priv_dic_get_wtype(char *buf, int len);
+char *anthy_priv_dic_get_word(char *buf, int len);
+
+int anthy_priv_dic_add_entry(const char *yomi, const char *word,
+ const char *wt, int freq);
+
+/* experimental and unstable /usr/share/dict/wordsから単語を探す */
+#define HAS_ANTHY_DIC_SEARCH_WORDS_FILE
+char *anthy_dic_search_words_file(const char *word);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/anthy/feature_set.h b/anthy/feature_set.h
new file mode 100644
index 0000000..99a7062
--- /dev/null
+++ b/anthy/feature_set.h
@@ -0,0 +1,56 @@
+/* 素性を扱う */
+#ifndef _feature_set_h_included_
+#define _feature_set_h_included_
+
+#include <anthy/wtype.h>
+
+/* hash collisionが出たら適宜増やす */
+#define WORD_HASH_MAX 1024
+
+/**/
+#define NR_EM_FEATURES 14
+
+struct feature_list {
+ /* いまのところ、素性は14個まで */
+ int nr;
+ int size;
+ union {
+ short index[NR_EM_FEATURES];
+ short *array;
+ } u;
+};
+
+struct feature_freq {
+ int f[NR_EM_FEATURES + 2];
+};
+
+void anthy_init_features(void);
+struct feature_freq *
+anthy_find_feature_freq(const void *array,
+ const struct feature_list *fl,
+ struct feature_freq *arg);
+struct feature_freq *
+anthy_find_array_freq(const void *array,
+ int *f, int nr,
+ struct feature_freq *arg);
+
+
+/**/
+void anthy_feature_list_init(struct feature_list *fl);
+void anthy_feature_list_free(struct feature_list *fl);
+/**/
+void anthy_feature_list_add(struct feature_list *fl, int f);
+int anthy_feature_list_nr(const struct feature_list *fl);
+int anthy_feature_list_nth(const struct feature_list *fl, int nth);
+void anthy_feature_list_sort(struct feature_list *fl);
+/**/
+void anthy_feature_list_set_cur_class(struct feature_list *fl, int cc);
+void anthy_feature_list_set_class_trans(struct feature_list *fl, int pc, int cc);
+void anthy_feature_list_set_dep_word(struct feature_list *fl, int h);
+void anthy_feature_list_set_dep_class(struct feature_list *fl, int c);
+void anthy_feature_list_set_noun_cos(struct feature_list *fl, wtype_t wt);
+void anthy_feature_list_set_mw_features(struct feature_list *fl, int mask);
+/**/
+void anthy_feature_list_print(struct feature_list *fl);
+
+#endif
diff --git a/anthy/filemap.h b/anthy/filemap.h
new file mode 100644
index 0000000..867687c
--- /dev/null
+++ b/anthy/filemap.h
@@ -0,0 +1,14 @@
+/* mmapを抽象化する */
+#ifndef _filemap_h_included_
+#define _filemap_h_included_
+
+/* メモリ上にmapされたファイルのハンドル */
+struct filemapping;
+
+struct filemapping *anthy_mmap(const char *fn, int wr);
+void *anthy_mmap_address(struct filemapping *m);
+int anthy_mmap_size(struct filemapping *m);
+int anthy_mmap_is_writable(struct filemapping *m);
+void anthy_munmap(struct filemapping *m);
+
+#endif
diff --git a/anthy/input.h b/anthy/input.h
new file mode 100644
index 0000000..6c2583d
--- /dev/null
+++ b/anthy/input.h
@@ -0,0 +1,136 @@
+/*
+ * Some comments are written in Japanese.
+ *
+ * Funded by IPA未踏ソフトウェア創造事業 2001
+ *
+ * Comments are in Japanese(EUC-JP)
+ * doc/ILIB 参照
+ */
+
+#ifndef INPUT_H_INCLUDE
+#define INPUT_H_INCLUDE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct anthy_input_context;
+
+extern int anthy_input_errno;
+#define AIE_NOMEM 1
+#define AIE_INVAL 2
+#define AIE_NOIMPL 3
+
+#define ANTHY_INPUT_ST_OFF 0 /* 無効状態 */ /* anthy agent does not use this state */
+#define ANTHY_INPUT_ST_NONE 1 /* 待機状態 */
+#define ANTHY_INPUT_ST_EDIT 2 /* 編集状態 */
+#define ANTHY_INPUT_ST_CONV 3 /* 変換状態 */
+#define ANTHY_INPUT_ST_CSEG 4 /* 文節伸縮状態 */
+
+#define ANTHY_INPUT_MAP_ALPHABET 0
+#define ANTHY_INPUT_MAP_WALPHABET 1
+#define ANTHY_INPUT_MAP_HIRAGANA 2
+#define ANTHY_INPUT_MAP_KATAKANA 3
+#define ANTHY_INPUT_MAP_HANKAKU_KANA 4
+
+#define ANTHY_INPUT_SF_NONE 0x00000000
+#define ANTHY_INPUT_SF_CURSOR 0x00000001
+#define ANTHY_INPUT_SF_ENUM 0x00000002
+#define ANTHY_INPUT_SF_ENUM_REVERSE 0x00000004
+#define ANTHY_INPUT_SF_EDITING 0x00000008
+#define ANTHY_INPUT_SF_PENDING 0x00000010
+#define ANTHY_INPUT_SF_FOLLOWING 0x00000020
+ /* This have been in public API!*/
+#define ANTHY_INPUT_SF_EDITTING 0x00000008
+
+struct anthy_input_config;
+struct anthy_input_context;
+
+/*
+ * anthy_input_get_preedit();
+ * anthy_input_free_preedit();
+ */
+struct anthy_input_preedit {
+ int state;
+
+ char* commit;
+ char* cut_buf;
+
+ struct anthy_input_segment* segment;
+ struct anthy_input_segment* cur_segment;
+};
+
+/*
+ * anthy_input_get_candidate();
+ * anthy_input_free_segment();
+ */
+struct anthy_input_segment {
+ char* str;
+ int cand_no;
+ int noconv_len;
+ int nr_cand;
+ int flag;
+
+ struct anthy_input_segment* next;
+};
+
+/* initialize ... */
+int anthy_input_init(void);
+
+/* context management*/
+void anthy_input_set_personality(const char *);
+struct anthy_input_context*
+anthy_input_create_context(struct anthy_input_config* cfg);
+void anthy_input_free_context(struct anthy_input_context* ictx);
+
+/* pure function command */
+void anthy_input_str(struct anthy_input_context* ictx, const char* str);
+void anthy_input_next_candidate(struct anthy_input_context* ictx);
+void anthy_input_prev_candidate(struct anthy_input_context* ictx);
+void anthy_input_quit(struct anthy_input_context* ictx);
+void anthy_input_erase_prev(struct anthy_input_context* ictx);
+void anthy_input_erase_next(struct anthy_input_context* ictx);
+void anthy_input_commit(struct anthy_input_context* ictx);
+void anthy_input_move(struct anthy_input_context* ictx, int lr);
+void anthy_input_resize(struct anthy_input_context* ictx, int lr);
+void anthy_input_beginning_of_line(struct anthy_input_context* ictx);
+void anthy_input_end_of_line(struct anthy_input_context* ictx);
+void anthy_input_cut(struct anthy_input_context* ictx);
+
+/* key oriented command */
+void anthy_input_key(struct anthy_input_context* ictx, int c);
+void anthy_input_space(struct anthy_input_context* ictx);
+
+/* meta command */
+int anthy_input_get_state(struct anthy_input_context* ictx);
+struct anthy_input_preedit*
+anthy_input_get_preedit(struct anthy_input_context* ictx);
+void anthy_input_free_preedit(struct anthy_input_preedit* pedit);
+int anthy_input_map_select(struct anthy_input_context* ictx, int map);
+int anthy_input_get_selected_map(struct anthy_input_context* ictx);
+struct anthy_input_segment*
+anthy_input_get_candidate(struct anthy_input_context* ictx, int cand_no);
+void anthy_input_free_segment(struct anthy_input_segment* cand);
+int anthy_input_select_candidate(struct anthy_input_context* ictx, int cand);
+
+/* config */
+struct anthy_input_config* anthy_input_create_config(void);
+void anthy_input_free_config(struct anthy_input_config* cfg);
+int anthy_input_edit_toggle_config(struct anthy_input_config *cfg, char tg);
+int anthy_input_edit_rk_config(struct anthy_input_config *cfg, int map,
+ const char *from, const char *to, const char *follow);
+int anthy_input_clear_rk_config(struct anthy_input_config *cfg,
+ int use_default);
+int anthy_input_break_into_roman_config(struct anthy_input_config* cfg, int f);
+int anthy_input_preedit_mode_config(struct anthy_input_config* cfg, int f);
+void anthy_input_change_config(struct anthy_input_config* cfg);
+
+/* DEBUG API */
+anthy_context_t
+anthy_input_get_anthy_context(struct anthy_input_context *ictx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INPUT_H_INCLUDE */
diff --git a/anthy/logger.h b/anthy/logger.h
new file mode 100644
index 0000000..da5a65f
--- /dev/null
+++ b/anthy/logger.h
@@ -0,0 +1,8 @@
+/* デバッグやエラーのメッセージの出力 */
+#ifndef _logger_h_included_
+#define _logger_h_included_
+
+void anthy_do_set_logger(void (*)(int , const char*), int lv);
+void anthy_log(int lv, const char *, ...);
+
+#endif
diff --git a/anthy/matrix.h b/anthy/matrix.h
new file mode 100644
index 0000000..aae89d1
--- /dev/null
+++ b/anthy/matrix.h
@@ -0,0 +1,26 @@
+/* 疎行列を扱うためのコード */
+#ifndef _matrix_h_included_
+#define _matrix_h_included_
+
+struct matrix_image {
+ /* number of 'int elements */
+ int size;
+ /* array of 'int */
+ int *image;
+};
+
+struct sparse_matrix;
+struct sparse_array;
+
+/* 行列を構成するAPI */
+struct sparse_matrix *anthy_sparse_matrix_new(void);
+void anthy_sparse_matrix_set(struct sparse_matrix *m, int row, int column,
+ int value, void *ptr);
+int anthy_sparse_matrix_get_int(struct sparse_matrix *m, int row, int column);
+void anthy_sparse_matrix_make_matrix(struct sparse_matrix *m);
+/* 行列イメージを構築するAPI(配列はhost byte order) */
+struct matrix_image *anthy_matrix_image_new(struct sparse_matrix *s);
+/* 行列イメージにアクセスするAPI(配列はnetwork byte order) */
+int anthy_matrix_image_peek(int *im, int row, int col);
+
+#endif
diff --git a/anthy/ordering.h b/anthy/ordering.h
new file mode 100644
index 0000000..d191843
--- /dev/null
+++ b/anthy/ordering.h
@@ -0,0 +1,27 @@
+/* 候補の順序を決定するためのモジュール */
+#ifndef _ordering_h_included_
+#define _ordering_h_included_
+
+#include <anthy/xstr.h>
+
+struct segment_list;
+struct splitter_context;
+
+/** ordering_contextのwrapper構造体
+ */
+struct ordering_context_wrapper{
+ struct ordering_context *oc;
+};
+
+void anthy_proc_commit(struct segment_list *, struct splitter_context *);
+
+void anthy_sort_candidate(struct segment_list *c, int nth);
+void anthy_sort_metaword(struct segment_list *seg);
+
+void anthy_do_commit_prediction(xstr *src, xstr *xs);
+
+/**/
+void anthy_infosort_init(void);
+void anthy_relation_init(void);
+
+#endif
diff --git a/anthy/prediction.h b/anthy/prediction.h
new file mode 100644
index 0000000..d24ac5d
--- /dev/null
+++ b/anthy/prediction.h
@@ -0,0 +1,18 @@
+#ifndef __prediction_h_included__
+#define __prediction_h_included__
+
+#include "xstr.h"
+
+struct prediction_t {
+ int timestamp;
+ /* 読み */
+ xstr *src_str;
+ /* 結果の文字列 */
+ xstr *str;
+};
+
+/* 予測された文字列を格納する */
+int anthy_traverse_record_for_prediction(xstr*, struct prediction_t*);
+
+
+#endif
diff --git a/anthy/record.h b/anthy/record.h
new file mode 100644
index 0000000..df76fea
--- /dev/null
+++ b/anthy/record.h
@@ -0,0 +1,98 @@
+/* 学習の履歴などを保存するデータベース */
+#ifndef _record_h_included_
+#define _record_h_included_
+/*
+ * データベースは名前をもつ複数のsectionから構成され各セクションは
+ * 文字列をキーとして高速に取り出すことができるrowからなる。
+ *
+ * データベースはカレントsectionやカレントrowなどの状態を持ち
+ * 操作はそれに対して行われる。
+ * section中のrowは順序関係をもっている
+ * その順序関係とは別にLRUの順序をもっている
+ */
+
+#include "xstr.h"
+
+/*
+ * カレントsectionを設定する
+ * name: sectionの名前
+ * create_if_not_exist: そのsectionがなければ作るかどうかのフラグ
+ * 返り値: 成功 0 、失敗 -1
+ * 失敗の時にはカレントsectionは無効になる
+ * 常にカレントrowは無効になる
+ */
+int anthy_select_section(const char *name, int create_if_not_exist);
+
+/*
+ * カレントsection中からnameのrowをカレントrowにする
+ * name: rowの名前
+ * create_if_not_exist: そのrowがなければ作るかどうかのフラグ
+ * 返り値: 成功 0 、失敗 -1
+ * 失敗の時にはカレントrowは無効になる
+ */
+int anthy_select_row(xstr *name, int create_if_not_exist);
+
+/*
+ * カレントsection中からnameに最も長い文字数でマッチする
+ * 名前のrowをカレントrowにする
+ * name: rowの名前
+ * 返り値: 成功 0 、失敗 -1
+ * 失敗の時にはにカレントrowは無効になる
+ */
+int anthy_select_longest_row(xstr *name);
+
+/*
+ * カレントsection中の最初のrowをカレントrowにする
+ * 返り値: 成功 0 、失敗 -1
+ * 失敗の時にはカレントrowは無効になる
+ */
+int anthy_select_first_row(void);
+
+/*
+ * カレントrowの次のrowをカレントrowにする
+ * 返り値: 成功 0 、失敗 -1
+ * カレントrowに対する変更があっても、ファイルには保存されない
+ * 失敗の時にはカレントrowは無効になる
+ */
+int anthy_select_next_row(void);
+
+/*
+ * カレントsectionを解放する
+ * 常にカレントsection,rowは無効になる
+ */
+void anthy_release_section(void);
+
+/*
+ * カレントsectionのLRUリストの先頭からcount個以降を解放する
+ * 常にカレントrowは無効になる
+ */
+void anthy_truncate_section(int count);
+
+
+/* 現在のrowに対する操作 */
+xstr *anthy_get_index_xstr(void);
+int anthy_get_nr_values(void);
+int anthy_get_nth_value(int );
+xstr *anthy_get_nth_xstr(int );/* internされているxstrが返される */
+
+void anthy_set_nth_value(int nth, int val);
+void anthy_set_nth_xstr(int nth, xstr *xs);/* 内部でコピーされる */
+
+void anthy_truncate_row(int nth);/* To Be Implemented */
+
+/*
+ * カレントrowを解放する。終了後のカレントrowは不定
+ * 常にカレントrowは無効になる
+ */
+void anthy_release_row(void);
+
+/*
+ * カレントrowをLRUの先頭の方へもってくる
+ * 常にカレントrowは無効になる
+ */
+int anthy_mark_row_used(void);
+
+
+void anthy_reload_record(void);
+
+#endif
diff --git a/anthy/ruleparser.h b/anthy/ruleparser.h
new file mode 100644
index 0000000..0f05324
--- /dev/null
+++ b/anthy/ruleparser.h
@@ -0,0 +1,19 @@
+/*
+ * 汎用の設定ファイルパーザ
+ */
+#ifndef _ruleparser_h_included_
+#define _ruleparser_h_included_
+
+/*
+ * ファイル名が'/'で始まっていれば絶対パス
+ * ファイル名が'./'で始まっていればカレントディレクトリ
+ * ファイル名がNULLならば標準入力
+ * そうでなければ、ANTHYDIR中のファイルを開ける
+ */
+int anthy_open_file(const char *fn);/* returns 0 on success */
+void anthy_close_file(void);
+int anthy_read_line(char ***tokens, int *nr);/* returns 0 on success */
+int anthy_get_line_number(void);
+void anthy_free_line(void);
+
+#endif
diff --git a/anthy/segclass.h b/anthy/segclass.h
new file mode 100644
index 0000000..b8a2724
--- /dev/null
+++ b/anthy/segclass.h
@@ -0,0 +1,50 @@
+/** 文節のクラス */
+#ifndef _segclass_h_included_
+#define _segclass_h_included_
+
+enum dep_class {
+ /* 付属語なし */
+ DEP_NONE,
+ /* 付属語一般 */
+ DEP_FUZOKUGO,
+ /* 格助詞 */
+ DEP_KAKUJOSHI,
+ /* 連用 */
+ DEP_RENYOU,
+ /* 連体 */
+ DEP_RENTAI,
+ /* 終端 */
+ DEP_END,
+ /* 名詞単独 */
+ DEP_RAW
+};
+
+
+enum seg_class {
+ /* 0 */
+ SEG_HEAD,
+ SEG_TAIL,
+ SEG_BUNSETSU,
+ SEG_SETSUZOKUGO,
+ SEG_MEISHI_KAKUJOSHI,
+ SEG_MEISHI_SHUTAN,
+ SEG_DOUSHI_FUZOKUGO,
+ SEG_DOUSHI_SHUTAN,
+ SEG_KEIYOUSHI,
+ SEG_KEIYOUDOUSHI,
+ /* 10 */
+ SEG_RENYOU_SHUSHOKU,
+ SEG_RENTAI_SHUSHOKU,
+ SEG_MEISHI,
+ SEG_MEISHI_FUZOKUGO,
+ SEG_MEISHI_RENYOU,
+ SEG_DOUSHI_RENYOU,
+ SEG_DOUSHI_RENTAI,
+ SEG_SIZE
+};
+
+const char* anthy_seg_class_name(enum seg_class sc);
+const char* anthy_seg_class_sym(enum seg_class sc);
+enum seg_class anthy_seg_class_by_name(const char *name);
+
+#endif
diff --git a/anthy/segment.h b/anthy/segment.h
new file mode 100644
index 0000000..5b950a4
--- /dev/null
+++ b/anthy/segment.h
@@ -0,0 +1,101 @@
+/* segment(文節) の定義 */
+#ifndef _segment_h_included_
+#define _segment_h_included_
+
+#include <anthy/segclass.h>
+#include <anthy/wtype.h>
+#include <anthy/xstr.h>
+#include <anthy/dic.h>
+
+/** 候補の構成要素 */
+struct cand_elm {
+ int nth; /* -1のときは辞書からの割り当てをやっていない */
+ wtype_t wt;
+ seq_ent_t se;
+ int ratio;/* 頻度を評価する際に使用する比率 */
+ xstr str;/* 変換対象の文字列 */
+ int id;/* 変換結果の文字列に対するhash値 */
+};
+
+/** 一つの候補に相当する。
+ * anthy_release_cand_ent()で解放する
+ */
+struct cand_ent {
+ /** 候補のスコア */
+ int score;
+ /** 変換後の文字列 */
+ xstr str;
+ /** 要素の数 */
+ int nr_words;
+ /** 候補を構成する要素の配列 */
+ struct cand_elm *elm;
+ /** 自立語部のインデックス */
+ int core_elm_index;
+ /** 付属語のhash値 */
+ int dep_word_hash;
+ /** 候補のフラグ CEF_? */
+ unsigned int flag;
+ struct meta_word *mw;
+};
+
+/* 候補(cand_ent)のフラグ */
+#define CEF_NONE 0
+#define CEF_OCHAIRE 0x00000001
+#define CEF_SINGLEWORD 0x00000002
+#define CEF_HIRAGANA 0x00000004
+#define CEF_KATAKANA 0x00000008
+#define CEF_GUESS 0x00000010
+#define CEF_USEDICT 0x00000020
+#define CEF_COMPOUND 0x00000040
+#define CEF_COMPOUND_PART 0x00000080
+#define CEF_BEST 0x00000100
+#define CEF_CONTEXT 0x00000200
+
+/** Context内に存在する文節の列
+ * release_seg_entで解放する
+ */
+struct seg_ent {
+ /* strの実体はcontext中にある */
+ xstr str;
+ /* commitされた候補の番号、負の数の場合はまだコミットされていない */
+ int committed;
+
+ /* 候補の配列 */
+ int nr_cands;/* 候補の数 */
+ struct cand_ent **cands;/* 配列 */
+
+ int from, len;/* len == str.len */
+
+ /* 文節の構成 */
+ int nr_metaword;
+ struct meta_word **mw_array;
+
+ /* 一番成績の良かったクラス */
+ enum seg_class best_seg_class;
+ /* 一番成績の良かったmeta_word
+ * mw_array中にも、含まれることが期待できるが、保証はしない */
+ struct meta_word *best_mw;
+
+ struct seg_ent *prev, *next;
+};
+
+/** 文節のリスト */
+struct segment_list {
+ int nr_segments;
+ struct seg_ent list_head;
+};
+
+/* 候補を解放する(無駄に生成してしまったもの等) */
+void anthy_release_cand_ent(struct cand_ent *s);
+
+/**/
+struct seg_ent *anthy_get_nth_segment(struct segment_list *c, int );
+void anthy_print_candidate(struct cand_ent *ce);
+
+/* compose.c */
+/* 候補を作り出す */
+struct splitter_context;
+void anthy_do_make_candidates(struct splitter_context *sc,
+ struct seg_ent *e, int is_reverse);
+
+#endif
diff --git a/anthy/splitter.h b/anthy/splitter.h
new file mode 100644
index 0000000..e9a08b0
--- /dev/null
+++ b/anthy/splitter.h
@@ -0,0 +1,126 @@
+/* splitterモジュールのインターフェイス */
+#ifndef _splitter_h_included_
+#define _splitter_h_included_
+
+#include <anthy/dic.h>
+#include <anthy/xstr.h>
+#include <anthy/wtype.h>
+#include <anthy/segclass.h>
+
+/* パラメータ */
+#define RATIO_BASE 256
+#define OCHAIRE_SCORE 5000000
+
+/** splitterのコンテキスト.
+ * 最初の境界設定からanthy_contextの解放まで有効
+ */
+struct splitter_context {
+ /** splitter内部で使用する構造体 */
+ struct word_split_info_cache *word_split_info;
+ int char_count;
+ int is_reverse;
+ struct char_ent {
+ xchar *c;
+ int seg_border;
+ int initial_seg_len;/* 最初の文節分割の際にここから始まった文節が
+ あればその長さ */
+ enum seg_class best_seg_class;
+ struct meta_word* best_mw; /* 一番優先して使いたいmetaword */
+ }*ce;
+};
+
+/* 制約のチェックの状態 */
+enum constraint_stat {
+ unchecked, ok, ng
+};
+
+/* とりあえず、適当に増やしてみて問題が出たら分類する */
+enum metaword_type {
+ /* ダミー : seginfoを持たない */
+ MW_DUMMY,
+ /* wordlistを0個 or 一個含むもの */
+ MW_SINGLE,
+ /* 別のmetaword一個を含む: metaword + 句読点 など :seginfoはmw1から取る */
+ MW_WRAP,
+ /* 複合語先頭 */
+ MW_COMPOUND_HEAD,
+ /* 複合語用 */
+ MW_COMPOUND,
+ /* 複合語の一文節 */
+ MW_COMPOUND_LEAF,
+ /* 複合語の中の個々の文節を結合して一つの文節としてみたもの */
+ MW_COMPOUND_PART,
+ /* 動詞の連用形 + 形容詞 */
+ MW_V_RENYOU_A,
+ /* 動詞の連用形 + 名詞 */
+ MW_V_RENYOU_NOUN,
+ /* 数字 */
+ MW_NUMBER,
+ /**/
+ MW_OCHAIRE,
+ /**/
+ MW_END
+};
+
+#define MW_FEATURE_NONE 0
+#define MW_FEATURE_SV 1
+#define MW_FEATURE_WEAK_CONN 2
+#define MW_FEATURE_SUFFIX 4
+#define MW_FEATURE_NUM 16
+#define MW_FEATURE_CORE1 32
+#define MW_FEATURE_DEP_ONLY 64
+#define MW_FEATURE_HIGH_FREQ 128
+#define MW_FEATURE_WEAK_SEQ 256
+
+/*
+ * meta_word: 境界の検索の対象となるもの
+ * 単一のword_listを含むものの他にいくつかの種類がある.
+ *
+ */
+struct meta_word {
+ int from, len;
+ /* 文節境界の検出に使用するスコア */
+ int score;
+ /* 候補の生成の時に使用するスコア */
+ int struct_score;
+ /* 形式の情報 */
+ int dep_word_hash;
+ int mw_features;
+ wtype_t core_wt;
+ enum dep_class dep_class;
+ /**/
+ enum seg_class seg_class;
+ enum constraint_stat can_use; /* セグメント境界に跨がっていない */
+ enum metaword_type type;
+ struct word_list *wl;
+ struct meta_word *mw1, *mw2;
+ xstr cand_hint;
+
+ int nr_parts;
+
+ /* listのリンク */
+ struct meta_word *next;
+};
+
+int anthy_init_splitter(void);
+void anthy_quit_splitter(void);
+
+void anthy_init_split_context(xstr *xs, struct splitter_context *, int is_reverse);
+/*
+ * mark_border(context, l1, l2, r1);
+ * l1とr1の間の文節を検出する、ただしl1とl2の間は境界にしない。
+ */
+void anthy_mark_border(struct splitter_context *, int from, int from2, int to);
+void anthy_commit_border(struct splitter_context *, int nr,
+ struct meta_word **mw, int *len);
+void anthy_release_split_context(struct splitter_context *c);
+
+/* 作り出した文節の情報を取得する */
+int anthy_get_nr_metaword(struct splitter_context *, int from, int len);
+struct meta_word *anthy_get_nth_metaword(struct splitter_context *,
+ int from, int len, int nth);
+/**/
+int anthy_dep_word_hash(xstr *xs);
+
+
+#endif
diff --git a/anthy/textdict.h b/anthy/textdict.h
new file mode 100644
index 0000000..6d79bee
--- /dev/null
+++ b/anthy/textdict.h
@@ -0,0 +1,15 @@
+#ifndef _textdict_h_included_
+#define _textdict_h_included_
+
+struct textdict;
+
+struct textdict *anthy_textdict_open(const char *fn, int create);
+void anthy_textdict_close(struct textdict *td);
+/**/
+void anthy_textdict_scan(struct textdict *td, int offset, void *ptr,
+ int (*fn)(void *, int, const char *, const char *));
+int anthy_textdict_insert_line(struct textdict *td,
+ int offset, const char *line);
+int anthy_textdict_delete_line(struct textdict *td, int offset);
+
+#endif
diff --git a/anthy/texttrie.h b/anthy/texttrie.h
new file mode 100644
index 0000000..84c0ef3
--- /dev/null
+++ b/anthy/texttrie.h
@@ -0,0 +1,24 @@
+#ifndef _texttrie_h_included_
+#define _texttrie_h_included_
+
+struct text_trie;
+
+/* database manipulation */
+struct text_trie *anthy_trie_open(const char *fn, int create);
+void anthy_trie_close(struct text_trie *tt);
+void anthy_trie_update_mapping(struct text_trie *tt);
+/**/
+int anthy_trie_add(struct text_trie *tt, const char *key, const char *body);
+/* caller should free the result */
+char *anthy_trie_find(struct text_trie *a, char *key);
+void anthy_trie_delete(struct text_trie *tt, const char *key);
+/**/
+char *anthy_trie_find_next_key(struct text_trie *tt, char *buf, int len);
+/**/
+void anthy_trie_find_prefix(struct text_trie *tt, const char *str,
+ char *buf, int len,
+ int (*cb)(const char *key, const char *str));
+/**/
+void anthy_trie_print_array(struct text_trie *tt);
+
+#endif
diff --git a/anthy/word_dic.h b/anthy/word_dic.h
new file mode 100644
index 0000000..54dc2dc
--- /dev/null
+++ b/anthy/word_dic.h
@@ -0,0 +1,42 @@
+/* 辞書ライブラリ(libanthydic)と
+ * 辞書生成の両方から使う
+ * ファイル辞書の構造
+ */
+#ifndef _word_dic_h_included_
+#define _word_dic_h_included_
+
+/* 読みhashのbit mapの大きさ */
+#define YOMI_HASH_ARRAY_SIZE (65536*4)
+#define YOMI_HASH_ARRAY_SHIFT 3
+#define YOMI_HASH_ARRAY_BITS (1<<YOMI_HASH_ARRAY_SHIFT)
+
+/* 汎用のhash */
+#define VERSATILE_HASH_SIZE (128*1024)
+
+/* 1ページ内にいくつの単語を入れるか */
+#define WORDS_PER_PAGE 64
+
+/** 辞書ファイル
+ * 辞書ライブラリ用
+ */
+struct word_dic {
+ /** 辞書ファイル自体のポインタ */
+ char *dic_file;
+ /** 辞書エントリのインデックスの配列(ネットワークバイトオーダー) */
+ int *entry_index;
+ /** 辞書エントリ */
+ char *entry;
+ /** インデックスへのインデックス */
+ int *page_index;
+ /** 辞書のインデックス */
+ char *page;
+ /** 用例辞書 */
+ char *uc_section;
+
+ /* 単語辞書 */
+ int nr_pages;
+ unsigned char *hash_ent;
+};
+
+#endif
+
diff --git a/anthy/wtype.h b/anthy/wtype.h
new file mode 100644
index 0000000..fe7eb5c
--- /dev/null
+++ b/anthy/wtype.h
@@ -0,0 +1,232 @@
+/*
+ * 品詞の型 wtype_t を扱う
+ *
+ * 単語の品詞を扱う
+ * 単語は次の要素を持つ。
+ * *品詞
+ * *品詞サブタイプ
+ * *品詞サブサブタイプ
+ * *活用クラス(CC)
+ * *活用形
+ * *自立語かどうかのフラグ
+ * wtype_tは上記の情報をすべて含む。
+ *
+ * 各要素の詳細については doc/POSを参照すべし
+ */
+#ifndef _wtype_h_included_
+#define _wtype_h_included_
+
+/*品詞 Part Of Speech */
+#define POS_NONE 0
+#define POS_NOUN 1
+#define POS_PRT 2
+#define POS_XV 3
+#define POS_V 4
+#define POS_A 5
+#define POS_AJV 6
+#define POS_AV 7
+#define POS_ME 8
+#define POS_CONJ 9
+#define POS_IJ 10
+#define POS_PRE 11
+#define POS_SUC 12
+#define POS_TANKANJI 13
+#define POS_N2T 14
+#define POS_D2KY 15
+#define POS_NUMBER 16
+#define POS_INVAL 17
+#define POS_OPEN 18
+#define POS_CLOSE 19
+
+/* 活用形 Conjugate Type */
+#define CT_NONE 0
+#define CT_SYUSI 1
+#define CT_MIZEN 2
+#define CT_RENYOU 3
+#define CT_RENTAI 4
+#define CT_KATEI 5
+#define CT_MEIREI 6
+#define CT_HEAD 7
+#define CT_MEISIKA 8
+
+/* 活用クラス Conjugate Class */
+#define CC_NONE 0
+#define CC_K5 1
+#define CC_C5 2
+#define CC_G5 3
+#define CC_S5 4
+#define CC_T5 5
+#define CC_N5 6
+#define CC_M5 7
+#define CC_B5 8
+#define CC_R5 9
+#define CC_L5 10
+#define CC_W5 11
+#define CC_U5 12
+#define CC_KS1 13
+#define CC_RV 14
+#define CC_KV 15
+#define CC_SV 16
+#define CC_ZV 17
+#define CC_A 18
+#define CC_A_U 19
+#define CC_AJV 20
+#define CC_SRV 21
+
+/* 副品詞 Class Of Speech */
+#define COS_NONE 0
+/* 地名 */
+#define COS_CN 1
+/* 数詞 */
+#define COS_NN 2
+/* 人名 */
+#define COS_JN 3
+/* 団体名 */
+#define COS_KK 4
+/* 一般接頭辞・接尾辞 */
+#define COS_SUFFIX 5
+/* サ変の接尾辞 */
+#define COS_SVSUFFIX 6
+/**/
+
+/* 副々品詞 Sub Class Of Speech*/
+#define SCOS_NONE 0
+#define SCOS_FAMNAME 1
+#define SCOS_FSTNAME 2
+#define SCOS_T0 10
+#define SCOS_T2 12
+#define SCOS_T3 13
+#define SCOS_T4 14
+#define SCOS_T5 15
+#define SCOS_T7 17
+#define SCOS_T8 18
+#define SCOS_T9 19
+#define SCOS_T10 20
+#define SCOS_T12 22
+#define SCOS_T13 23
+#define SCOS_T14 24
+#define SCOS_T15 25
+#define SCOS_T17 27
+#define SCOS_T18 28
+#define SCOS_T19 29
+#define SCOS_T20 30
+#define SCOS_T22 32
+#define SCOS_T23 33
+#define SCOS_T24 34
+#define SCOS_T25 35
+#define SCOS_T27 37
+#define SCOS_T28 38
+#define SCOS_T29 39
+#define SCOS_T30 40
+#define SCOS_T32 42
+#define SCOS_T33 43
+#define SCOS_T34 44
+#define SCOS_T35 45
+#define SCOS_T37 47
+#define SCOS_T38 48
+#define SCOS_T39 49
+#define SCOS_T40 50
+#define SCOS_F0 60
+#define SCOS_F1 61
+#define SCOS_F2 62
+#define SCOS_F3 63
+#define SCOS_F4 64
+#define SCOS_F5 65
+#define SCOS_F6 66
+#define SCOS_F7 67
+#define SCOS_F8 68
+#define SCOS_F9 69
+#define SCOS_F10 70
+#define SCOS_F11 71
+#define SCOS_F12 72
+#define SCOS_F13 73
+#define SCOS_F14 74
+#define SCOS_A0 80
+#define SCOS_A1 81
+#define SCOS_N1 90
+#define SCOS_N10 91
+#define SCOS_N100 92
+#define SCOS_N1000 93
+#define SCOS_N10000 94
+
+/* FLAGS */
+#define WF_NONE 0
+/* この動詞は連体詞が名詞化する */
+#define WF_MEISI 1
+/* サ変名詞 */
+#define WF_SV 2
+/* 自立語、文節のコアとなる */
+#define WF_INDEP 4
+/* 形容動詞 */
+#define WF_AJV 8
+
+/* wtype_t中のオフセット */
+#define WT_POS 0
+#define WT_COS 1
+#define WT_SCOS 2
+#define WT_CC 3
+#define WT_CT 4
+#define WT_FLAGS 5
+
+/* 各bit fieldの幅 */
+#define POS_BITS 5
+#define COS_BITS 4
+#define SCOS_BITS 7
+#define CC_BITS 5
+#define CT_BITS 4
+#define WF_BITS 4
+/* 29bits */
+
+/** 品詞 */
+struct wtype{
+ unsigned int pos : POS_BITS;
+ unsigned int cos : COS_BITS;
+ unsigned int scos : SCOS_BITS;
+ unsigned int cc : CC_BITS;
+ unsigned int ct : CT_BITS;
+ unsigned int wf : WF_BITS;
+};
+
+typedef struct wtype wtype_t;
+
+/** anthy_wtype_include(名詞、人名)は真、逆は偽 */
+int anthy_wtype_include(wtype_t haystack, wtype_t needle);
+
+/* 二つの品詞が完全に一致するかどうかを見る */
+int anthy_wtype_equal(wtype_t lhs, wtype_t rhs);
+
+void anthy_print_wtype(wtype_t w);
+/* 辞書ファイル中の名前から品詞を得る(関数名が悪い) */
+const char *anthy_type_to_wtype(const char *name, wtype_t *w);
+/* 品詞の名前から品詞を得る */
+wtype_t anthy_init_wtype_by_name(const char *str);
+
+int anthy_wtype_get_pos(wtype_t w);
+int anthy_wtype_get_cc(wtype_t w);
+int anthy_wtype_get_ct(wtype_t w);
+int anthy_wtype_get_cos(wtype_t w);
+int anthy_wtype_get_scos(wtype_t w);
+int anthy_wtype_get_wf(wtype_t w);
+
+/* フラグの取得 */
+int anthy_wtype_get_indep(wtype_t w);
+int anthy_wtype_get_sv(wtype_t w);
+int anthy_wtype_get_meisi(wtype_t w);
+int anthy_wtype_get_ajv(wtype_t w);
+
+wtype_t anthy_get_wtype(int pos, int cos, int scos, int cc, int ct, int wf);
+wtype_t anthy_get_wtype_with_ct(wtype_t base, int ct);
+
+void anthy_wtype_set_pos(wtype_t *w, int pos);
+void anthy_wtype_set_cc(wtype_t *w, int cc);
+void anthy_wtype_set_ct(wtype_t *w, int ct);
+void anthy_wtype_set_cos(wtype_t *w, int cs);
+void anthy_wtype_set_scos(wtype_t *w, int scos);
+void anthy_wtype_set_dep(wtype_t *w, int isDep);
+
+void anthy_init_wtypes(void);
+
+extern wtype_t anthy_wt_all;/* すべてにマッチする自立語 */
+extern wtype_t anthy_wt_none;/* 品詞無しPOS_INVAL */
+
+#endif
diff --git a/anthy/xchar.h b/anthy/xchar.h
new file mode 100644
index 0000000..04859cc
--- /dev/null
+++ b/anthy/xchar.h
@@ -0,0 +1,165 @@
+/* 各種カナや文字のコードと識別関数 */
+#ifndef _xchar_h_included_
+#define _xhcar_h_included_
+
+#include <anthy/xstr.h>
+
+/* 平仮名や各種文字の文字コード */
+
+ /* UCS4 */
+#define HK_A 0x3042
+#define HK_I 0x3044
+#define HK_U 0x3046
+#define HK_E 0x3048
+#define HK_O 0x304a
+
+#define HK_KA 0x304b
+#define HK_KI 0x304d
+#define HK_KU 0x304f
+#define HK_KE 0x3051
+#define HK_KO 0x3053
+
+#define HK_SA 0x3055
+#define HK_SI 0x3057
+#define HK_SU 0x3059
+#define HK_SE 0x305b
+#define HK_SO 0x305d
+
+#define HK_TA 0x305f
+#define HK_TI 0x3061
+#define HK_TU 0x3064
+#define HK_TE 0x3066
+#define HK_TO 0x3068
+
+#define HK_NA 0x306a
+#define HK_NI 0x306b
+#define HK_NU 0x306c
+#define HK_NE 0x306d
+#define HK_NO 0x306e
+
+#define HK_HA 0x306f
+#define HK_HI 0x3072
+#define HK_HU 0x3075
+#define HK_HE 0x3078
+#define HK_HO 0x307b
+
+#define HK_MA 0x307e
+#define HK_MI 0x307f
+#define HK_MU 0x3080
+#define HK_ME 0x3081
+#define HK_MO 0x3082
+
+#define HK_YA 0x3084
+#define HK_YU 0x3086
+#define HK_YO 0x3088
+
+#define HK_RA 0x3089
+#define HK_RI 0x308a
+#define HK_RU 0x308b
+#define HK_RE 0x308c
+#define HK_RO 0x308d
+
+#define HK_WA 0x308f
+#define HK_WI 0x3090
+#define HK_WE 0x3091
+#define HK_WO 0x3092
+#define HK_N 0x3093
+
+#define HK_TT 0x3063
+
+#define HK_XA 0x3041
+#define HK_XI 0x3043
+#define HK_XU 0x3045
+#define HK_XE 0x3047
+#define HK_XO 0x3049
+
+#define HK_GA 0x304c
+#define HK_GI 0x304e
+#define HK_GU 0x3050
+#define HK_GE 0x3052
+#define HK_GO 0x3054
+
+#define HK_ZA 0x3056
+#define HK_ZI 0x3058
+#define HK_ZU 0x305a
+#define HK_ZE 0x305c
+#define HK_ZO 0x305e
+
+#define HK_DA 0x3060
+#define HK_DI 0x3062
+#define HK_DU 0x3065
+#define HK_DE 0x3067
+#define HK_DO 0x3069
+
+#define HK_BA 0x3070
+#define HK_BI 0x3073
+#define HK_BU 0x3076
+#define HK_BE 0x3079
+#define HK_BO 0x307c
+
+#define HK_PA 0x3071
+#define HK_PI 0x3074
+#define HK_PU 0x3077
+#define HK_PE 0x307a
+#define HK_PO 0x307d
+
+#define HK_XYA 0x3083
+#define HK_XYU 0x3085
+#define HK_XYO 0x3087
+
+#define HK_XWA 0x308e
+/*「゛」*/
+#define HK_DDOT 0x309b
+/* 「ー」 */
+#define HK_BAR 0x30fc
+#define KK_VU 0x30f4
+#define WIDE_COMMA 0xff0c
+
+/* 漢数字 */
+#define KJ_1 0x4e00
+#define KJ_2 0x4e8c
+#define KJ_3 0x4e09
+#define KJ_4 0x56db
+#define KJ_5 0x4e94
+#define KJ_6 0x516d
+#define KJ_7 0x4e03
+#define KJ_8 0x516b
+#define KJ_9 0x4e5d
+/* 零 */
+#define KJ_0 0x96f6
+#define KJ_10 0x5341
+#define KJ_100 0x767e
+#define KJ_1000 0x5343
+#define KJ_10000 0x4e07
+#define KJ_100000000 0x5104
+#define KJ_1000000000000 0x5146
+#define KJ_10000000000000000 0x4eac
+
+/* 全角数字 */
+#define WIDE_0 0xff10
+#define WIDE_1 0xff11
+#define WIDE_2 0xff12
+#define WIDE_3 0xff13
+#define WIDE_4 0xff14
+#define WIDE_5 0xff15
+#define WIDE_6 0xff16
+#define WIDE_7 0xff17
+#define WIDE_8 0xff18
+#define WIDE_9 0xff19
+
+#define UCS_GETA 0x3013
+#define EUC_GETA 0xa2ae
+
+/**/
+int anthy_xchar_to_num(xchar );
+xchar anthy_xchar_wide_num_to_num(xchar);
+/**/
+struct half_kana_table {
+ const int src;
+ const int dst;
+ const int mod;
+};
+const struct half_kana_table *anthy_find_half_kana(xchar xc);
+xchar anthy_lookup_half_wide(xchar xc);
+
+#endif
diff --git a/anthy/xstr.h b/anthy/xstr.h
new file mode 100644
index 0000000..1d0dd95
--- /dev/null
+++ b/anthy/xstr.h
@@ -0,0 +1,109 @@
+/*
+ * Anthy内部で使う文字列
+ * 特に実装を隠蔽しようとしているわけでは無いので、
+ * ここにある関数の使用は強制しない。
+ */
+#ifndef _xstr_h_included_
+#define _xstr_h_included_
+
+/** 文字型
+ * UCS4が入っている */
+typedef int xchar;
+
+/** 文字列
+ * xstrにtypedefされている
+ */
+typedef struct xstr_ {
+ /** 文字列へのポインタ */
+ xchar *str;
+ /** xcharの数 */
+ int len;
+} xstr;
+
+/* デバッグ用の出力関数 */
+void anthy_putxchar(xchar );
+void anthy_putxstr(xstr *);
+void anthy_putxstrln(xstr *);
+
+/* Cの文字列への書き出し */
+int anthy_sputxchar(char *, xchar , int encoding);
+int anthy_sputxstr(char *, xstr *, int encoding);
+int anthy_snputxstr(char *, int , xstr *, int encoding);
+
+/* xstrとstr共にmallocされる、freeで両方解放するかanthy_free_xstrで解放する */
+xstr *anthy_cstr_to_xstr(const char *, int );
+/* 結果はmallocで確保される */
+char *anthy_xstr_to_cstr(xstr *, int);
+
+/* xstrとstr共にmallocされる */
+xstr *anthy_xstr_dup(xstr *);
+void anthy_free_xstr(xstr *);
+
+/* 結果はmallocで確保される */
+xchar *anthy_xstr_dup_str(xstr *);
+void anthy_free_xstr_str(xstr *);
+
+/* 文字列をコピーする */
+xstr* anthy_xstrcpy(xstr *, xstr *);
+/* 文字列を比較する。strcmpと同等の動作(返り値の符号に意味がある) */
+int anthy_xstrcmp(xstr *, xstr *);
+/* n文字目まで文字列を比較する。strncmpと同等の動作(返り値の符号に意味がある) */
+int anthy_xstrncmp(xstr *, xstr *, int);
+/* s->strをreallocする */
+xstr *anthy_xstrcat(xstr *s, xstr *d);
+/* xs->strをreallocする */
+xstr *anthy_xstrappend(xstr *xs, xchar c);
+
+/* strtollのxstr版 */
+long long anthy_xstrtoll(xstr *);
+/* 全角数字から半角数字への変換 */
+xstr *anthy_xstr_wide_num_to_num(xstr *);
+/* ひらがなからカタカナへの変換 */
+xstr *anthy_xstr_hira_to_kata(xstr *);
+/**/
+xstr *anthy_xstr_hira_to_half_kata(xstr *);
+xstr *anthy_conv_half_wide(xstr *xs);
+
+/* xcharの型 */
+#define XCT_ALL 0xffffffff
+#define XCT_NONE 0
+#define XCT_HIRA 1
+#define XCT_KATA 2
+#define XCT_ASCII 4
+#define XCT_NUM 8
+#define XCT_WIDENUM 16
+#define XCT_OPEN 32
+#define XCT_CLOSE 64
+/* 直前の文字の一部 */
+#define XCT_PART 128
+/* 助詞 */
+#define XCT_DEP 256
+/* 記号 */
+#define XCT_SYMBOL 1024
+/* 漢字 */
+#define XCT_KANJI 2048
+/* 句読点 */
+#define XCT_PUNCTUATION 4096
+
+/** XCT_*が返ってくる */
+int anthy_get_xchar_type(const xchar );
+/** 全ての文字に対してXCT_*の論理積をとったもの */
+int anthy_get_xstr_type(const xstr *);
+
+/* hash */
+int anthy_xstr_hash(xstr *);
+
+/* xstr.c */
+int anthy_init_xstr(void);
+void anthy_quit_xstr(void);
+void anthy_xstr_set_print_encoding(int );
+
+int anthy_euc_to_ucs(int ec);
+int anthy_ucs_to_euc(int uc);
+
+const char *anthy_utf8_to_ucs4_xchar(const char *s, xchar *res);
+/**/
+char *anthy_conv_euc_to_utf8(const char *s);
+char *anthy_conv_utf8_to_euc(const char *s);
+
+#endif