(linenum→info "unix/slp.c:2238")

anthy/9100e/src-splitter/wordborder.h

    1: /* 文節境界の検出に使うデータ */
    2: #ifndef _wordborder_h_included_
    3: #define _wordborder_h_included_
    4: 
    5: 
    6: #include <anthy/dic.h>
    7: #include <anthy/alloc.h>
    8: #include <anthy/segclass.h>
    9: #include <anthy/depgraph.h>
   10: 
   11: struct splitter_context;
   12: 
   13: /*
   14:  * meta_wordの使用可能チェックのやり方
   15:  */
   16: enum mw_check {
   17:   /* なにもせず */
   18:   MW_CHECK_NONE,
   19:   /* mw->wlが無いか、wlが使える場合 */
   20:   MW_CHECK_SINGLE,
   21:   MW_CHECK_BORDER,
   22:   MW_CHECK_WRAP,
   23:   MW_CHECK_OCHAIRE,
   24:   MW_CHECK_NUMBER,
   25:   MW_CHECK_COMPOUND
   26: };
   27: 
   28: /*
   29:  * 文字列中のある場所を表し,
   30:  * そこから始まるmeta_word, word_listのセットを持つ
   31:  */
   32: struct char_node {
   33:   int max_len;
   34:   struct meta_word *mw;
   35:   struct word_list *wl;
   36: };
   37: 
   38: /*
   39:  * コンテキスト中の自立語などの情報、最初に変換キーを押したときに
   40:  * 構築される
   41:  */
   42: struct word_split_info_cache {
   43:   struct char_node *cnode;
   44: 
   45:   /* キャッシュ構成時に使う情報 */
   46:   /* 接尾辞を探すのに使う */
   47:   int *seq_len;/* そこから始まる最長の単語の長さ */
   48:   /* 接頭辞を探すのに使う */
   49:   int *rev_seq_len;/* そこで終わる最長の単語の長さ */
   50:   /* 文節境界contextからのコピー */
   51:   int *seg_border;
   52:   /* 検索で一番成績の良かったクラス */
   53:   enum seg_class* best_seg_class;
   54:   /*  */
   55:   struct meta_word **best_mw;
   56:   /* アロケータ */
   57:   allocator MwAllocator, WlAllocator;
   58: };
   59: 
   60: /*
   61:  * meta_wordの状態
   62:  */
   63: enum mw_status {
   64:   MW_STATUS_NONE,
   65:   /* mw->mw1に中身が入っている */
   66:   MW_STATUS_WRAPPED,
   67:   /* mw-mw1とmw->mw2から連結 */
   68:   MW_STATUS_COMBINED,
   69:   /* 複合語用 */
   70:   MW_STATUS_COMPOUND,
   71:   /* 複合語の個々の文節を結合して一つの文節として見たもの */
   72:   MW_STATUS_COMPOUND_PART,
   73:   /* OCHAIRE学習から取り出す */
   74:   MW_STATUS_OCHAIRE
   75: };
   76: 
   77: 
   78: 
   79: /* metawordの種類による処理の違い (metaword.c) */
   80: extern struct metaword_type_tab_ {
   81:   enum metaword_type type;
   82:   const char *name;
   83:   enum mw_status status;
   84:   enum mw_check check;
   85: } anthy_metaword_type_tab[];
   86: 
   87: /*
   88:  * 0: 接頭辞
   89:  * 1: 自立語部
   90:  * 2: 接尾辞
   91:  */
   92: #define NR_PARTS 4
   93: #define PART_PREFIX 0
   94: #define PART_CORE 1
   95: #define PART_POSTFIX 2
   96: #define PART_DEPWORD 3
   97: 
   98: struct part_info {
   99:   /* このpartの長さ */
  100:   int from, len;
  101:   /* 品詞 */
  102:   wtype_t wt;
  103:   seq_ent_t seq;
  104:   /* 頻度 */
  105:   int freq;
  106:   /* 付属語クラス */
  107:   enum dep_class dc;
  108: };
  109: 
  110: /*
  111:  * word_list: 文節を形成するもの
  112:  * 接頭語、自立語、接尾語、付属語を含む
  113:  */
  114: struct word_list {
  115:   /**/
  116:   int from, len; /* 文節全体 */
  117:   int is_compound; /* 複合語かどうか */
  118: 
  119:   /**/
  120:   int dep_word_hash;
  121:   int mw_features;
  122:   /**/
  123:   enum seg_class seg_class;
  124:   enum constraint_stat can_use; /* セグメント境界に跨がっていない */
  125: 
  126:   /* 漢字を得るためではなくて、雑多な処理に使いたい情報 */
  127:   int head_pos; /* lattice検索用の品詞 */
  128:   int tail_ct; /* meta_wordの結合用の活用形 */
  129: 
  130:   /**/
  131:   int last_part;
  132:   struct part_info part[NR_PARTS];
  133: 
  134:   /* このword_listを作った際の情報 */
  135:   int node_id; /* 付属語グラフの検索開始のnodeのid*/
  136: 
  137:   /* 同じfromを持つword_listのリスト */
  138:   struct word_list *next;
  139: };
  140: 
  141: 
  142: /* splitter.c */
  143: #define SPLITTER_DEBUG_NONE 0
  144: /* wordlistの表示 */
  145: #define SPLITTER_DEBUG_WL 1
  146: /* metawordの表示 */
  147: #define SPLITTER_DEBUG_MW 2
  148: /* latticeの nodeの表示 */
  149: #define SPLITTER_DEBUG_LN 4
  150: /* 自立語のマッチした品詞 */
  151: #define SPLITTER_DEBUG_ID 8
  152: /**/
  153: #define SPLITTER_DEBUG_CAND 16
  154: 
  155: int anthy_splitter_debug_flags(void);
  156: 
  157: 
  158: /* defined in wordseq.c */
  159: /* 自立語以降の接続の処理 */
  160: void anthy_scan_node(struct splitter_context *sc,
  161:                      struct word_list *wl,
  162:                      xstr *follow, int node);
  163: int anthy_get_node_id_by_name(const char *name);
  164: int anthy_init_depword_tab(void);
  165: void anthy_quit_depword_tab(void);
  166: 
  167: /* depgraph.c */
  168: int anthy_get_nr_dep_rule(void);
  169: void anthy_get_nth_dep_rule(int, struct wordseq_rule *);
  170: 
  171: /* defined in wordlist.c */
  172: void anthy_commit_word_list(struct splitter_context *, struct word_list *wl);
  173: struct word_list *anthy_alloc_word_list(struct splitter_context *);
  174: void anthy_print_word_list(struct splitter_context *, struct word_list *);
  175: void anthy_make_word_list_all(struct splitter_context *);
  176: 
  177: /* defined in metaword.c */
  178: void anthy_commit_meta_word(struct splitter_context *, struct meta_word *mw);
  179: void anthy_make_metaword_all(struct splitter_context *);
  180: void anthy_print_metaword(struct splitter_context *, struct meta_word *);
  181: 
  182: void anthy_mark_border_by_metaword(struct splitter_context* sc,
  183:                                    struct meta_word* mw);
  184: 
  185: 
  186: /* defined in evalborder.c */
  187: void anthy_eval_border(struct splitter_context *, int, int, int);
  188: 
  189: /* defined at lattice.c */
  190: void anthy_mark_borders(struct splitter_context *sc, int from, int to);
  191: 
  192: /* defined at seg_class.c */
  193: void anthy_set_seg_class(struct word_list* wl);
  194: 
  195: /* 品詞(anthy_init_splitterで初期化される) */
  196: extern wtype_t anthy_wtype_noun;
  197: extern wtype_t anthy_wtype_name_noun;
  198: extern wtype_t anthy_wtype_num_noun;
  199: extern wtype_t anthy_wtype_prefix;
  200: extern wtype_t anthy_wtype_num_prefix;
  201: extern wtype_t anthy_wtype_num_postfix;
  202: extern wtype_t anthy_wtype_name_postfix;
  203: extern wtype_t anthy_wtype_sv_postfix;
  204: extern wtype_t anthy_wtype_a_tail_of_v_renyou;
  205: extern wtype_t anthy_wtype_v_renyou;
  206: extern wtype_t anthy_wtype_noun_tail;/* いれ「たて」とか */
  207: extern wtype_t anthy_wtype_n1;
  208: extern wtype_t anthy_wtype_n10;
  209: 
  210: #endif
Syntax (Markdown)