| 1 | ;;; | 
|---|
| 2 | ;;; mecablib.stub | 
|---|
| 3 | ;;; | 
|---|
| 4 | ;;;  2009.3.13 by naoya_t | 
|---|
| 5 | ;;; | 
|---|
| 6 |  | 
|---|
| 7 | " | 
|---|
| 8 | #include <gauche.h> | 
|---|
| 9 | #include <gauche/extend.h> | 
|---|
| 10 |  | 
|---|
| 11 | #include <mecab.h> | 
|---|
| 12 | #include \"mecab.h\" | 
|---|
| 13 | " | 
|---|
| 14 |  | 
|---|
| 15 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 
|---|
| 16 |  | 
|---|
| 17 | (define-cclass <mecab> "ScmMeCab*" "Scm_MeCabClass" () ()) | 
|---|
| 18 | (define-cclass <mecab-node> "ScmMeCabNode*" "Scm_MeCabNodeClass" () ()) | 
|---|
| 19 | (define-cclass <mecab-dictionary-info> "ScmMeCabDictionaryInfo*" "Scm_MeCabDictionaryInfoClass" () ()) | 
|---|
| 20 |  | 
|---|
| 21 | (define-type <mecab-t> "mecab_t*" "mecab_t" | 
|---|
| 22 |   "SCM_MECABP" "unwrap_mecab_t" "wrap_mecab_t") | 
|---|
| 23 | (define-type <const-mecab-node-t> "const mecab_node_t*" "const mecab_node_t" | 
|---|
| 24 |   "SCM_MECAB_NODEP" "unwrap_mecab_node_t" "wrap_mecab_node_t") | 
|---|
| 25 | (define-type <const-mecab-dictionary-info-t> "const mecab_dictionary_info_t*" "const mecab_dictionary_info_t" | 
|---|
| 26 |   "SCM_MECAB_DICTIONARY_INFOP" "unwrap_mecab_dictionary_info_t" "wrap_mecab_dictionary_info_t") | 
|---|
| 27 |  | 
|---|
| 28 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 
|---|
| 29 |  | 
|---|
| 30 | ;; mecab-do | 
|---|
| 31 | (define-cproc mecab-do (&rest args) | 
|---|
| 32 |   (expr <int> "mecab_call_int_func(&mecab_do,args)")) | 
|---|
| 33 |  | 
|---|
| 34 | ;;mecab_t *mecab_new (int argc, char **argv) | 
|---|
| 35 | ;;    mecab のインスタンスを生成します. | 
|---|
| 36 | ;;    引数には, C 言語の, main 関数で使用される argc, argv スタイルの引数を与えます. | 
|---|
| 37 | ;;    この引数は, mecab コマンドと同じ方法で処理されます. | 
|---|
| 38 | ;;    成功すれば, mecab_t 型のポインタが返ってきます. このポインタを通して解析 を行います. 失敗すれば NULL が返ってきます. | 
|---|
| 39 | (define-cproc mecab-new (&rest args) | 
|---|
| 40 |   (expr <mecab-t> "mecab_call_mecab_func(&mecab_new,args)")) | 
|---|
| 41 |  | 
|---|
| 42 | ;;mecab_t *mecab_new2 (const char *arg) | 
|---|
| 43 | ;;    mecab のインスタンスを生成します. | 
|---|
| 44 | ;;    引数には, 一つの文字列として表現したパラメータを与えます. | 
|---|
| 45 | ;;    成功すれば, mecab_t 型のポインタが返ってきます. このポインタを通して解析を行います. | 
|---|
| 46 | (define-cproc mecab-new2 (arg::<const-cstring>) | 
|---|
| 47 |   (call <mecab-t> "mecab_new2")) | 
|---|
| 48 |  | 
|---|
| 49 | ;;const char *mecab_version() | 
|---|
| 50 | ;;    mecab の version を文字列として取得します. | 
|---|
| 51 | (define-cproc mecab-version () | 
|---|
| 52 |   (call <const-cstring> "mecab_version")) | 
|---|
| 53 |  | 
|---|
| 54 | ;;const char *mecab_strerror (mecab_t* m) | 
|---|
| 55 | ;;    エラーの内容を文字列として取得します. mecab_sparse_tostr 等で, NULL が返ってきた場合に, mecab_strerror を呼ぶことで, エラーの内容を取得できます.  | 
|---|
| 56 | ;;    mecab_new,mecab_new2 のエラーは, m を NULL と指定してください.  | 
|---|
| 57 | (define-cproc mecab-strerror (m) | 
|---|
| 58 |   (expr <const-cstring> | 
|---|
| 59 |                 "mecab_strerror( SCM_MECABP(m)? unwrap_mecab_t(m) : NULL )")) | 
|---|
| 60 | ; (call <const-cstring> "mecab_strerror")) | 
|---|
| 61 |  | 
|---|
| 62 | ;;const char *mecab_sparse_tostr (mecab_t *m, const char *str) | 
|---|
| 63 | ;;    解析を行います. 引数には, mecab_new で得られた mecab_t 型のポインタと, | 
|---|
| 64 | ;;    解析したい文を char 型のポインタ文字列として与えます. | 
|---|
| 65 | ;;    成功すれば, 解析後の結果が char 型のポインタとして返り, 失敗すれば, NULL が返ってきます | 
|---|
| 66 | ;;    戻り値のポインタが指すメモリ領域は, 呼び出し側で管理する必要はありませんが, | 
|---|
| 67 | ;;    mecab_sparse_tostr を呼ぶ度に上書きされます. | 
|---|
| 68 | ;;    また, mecab_destroy を呼ぶと解放されます.  | 
|---|
| 69 | (define-cproc mecab-sparse-tostr (mecab::<mecab-t> str::<const-cstring>) | 
|---|
| 70 |   (call <const-cstring> "mecab_sparse_tostr")) | 
|---|
| 71 |  | 
|---|
| 72 | ;;const char *mecab_sparse_tostr2 (mecab_t *m, const char *str, size_t len) | 
|---|
| 73 | ;;    mecab_sparse_tostr とほぼ同じですが, len にて, 解析する文の長さを指定できます.  | 
|---|
| 74 | (define-cproc mecab-sparse-tostr2 (mecab::<mecab-t> str::<const-cstring> len::<uint>) | 
|---|
| 75 |   (call <const-cstring> "mecab_sparse_tostr2")) | 
|---|
| 76 |  | 
|---|
| 77 | ;;char *mecab_sparse_tostr3 (mecab_t *m, const char *istr,size_t ilen char *ostr, size_t olen) | 
|---|
| 78 | ;;    mecab_sparse_tostr2 に加え, 出力用のバッファ領域 (ostr), 及びその長さ (olen) を指定できます. ostr の領域の管理は, 呼び出し側が行います. 成功すれば, 解析後の | 
|---|
| 79 | ;;    結果が char 型のポインタとして返ってきます. これは, ostr と同じになります. もし, 解析結果の長さが olen 以上になった場合は, 解析失敗とみなし, NULL を返します.  | 
|---|
| 80 | ;;(define-cproc mecab-sparse-tostr3 (mecab::<mecab-t> str::<const-cstring> len::<uint> ostr::<const-cstring> olen::<uint>) | 
|---|
| 81 | ;;  (call <const-cstring> "mecab_sparse_tostr3")) | 
|---|
| 82 |  | 
|---|
| 83 | ;;const char *mecab_nbest_sparse_tostr  (mecab_t *m, size_t N, const char *str) | 
|---|
| 84 | ;;    mecab_sparse_tostr () の N-Best 解出力 version です. N にて解析結果の個数を指定します. また, N-Best の機能を使う場合は, 必ず mecab_new にて -l 1 オプションを指定する必要があります.  | 
|---|
| 85 | (define-cproc mecab-nbest-sparse-tostr (mecab::<mecab-t> n::<uint> str::<const-cstring>) | 
|---|
| 86 |   (call <const-cstring> "mecab_nbest_sparse_tostr")) | 
|---|
| 87 |  | 
|---|
| 88 | ;;const char *mecab_nbest_sparse_tostr2 (mecab_t *m, size_t N, const char *str, size_t len) | 
|---|
| 89 | ;;    mecab_sparse_tostr2 () の N-Best 解出力 version です. N にて解析結果の個数を指定します.  | 
|---|
| 90 | (define-cproc mecab-nbest-sparse-tostr2 (mecab::<mecab-t> n::<uint> str::<const-cstring> len::<uint>) | 
|---|
| 91 |   (call <const-cstring> "mecab_nbest_sparse_tostr2")) | 
|---|
| 92 |  | 
|---|
| 93 | ;;char *mecab_nbest_sparse_tostr3 (mecab_t *m, size_t N, const char *str, size_t len, char *ostr, size_t olen) | 
|---|
| 94 | ;;    mecab_sparse_tostr3 () の N-Best 解出力 version です. N にて解析結果の個数を指定します. | 
|---|
| 95 | ;;(define-cproc mecab-nbest-sparse-tostr3 (mecab::<mecab-t> n::<uint> str::<const-cstring> len::<uint> ostr::<const-cstring> olen::<uint>) | 
|---|
| 96 | ;;  (call <const-cstring> "mecab_nbest_sparse_tostr3")) | 
|---|
| 97 |  | 
|---|
| 98 | ;;int mecab_nbest_init (mecab_t* m, const char* str); | 
|---|
| 99 | ;;    解析結果を, 確からしいものから順番に取得する場合にこの関数で初期化を行います. 解析したい文を str に指定します. 初期化に成功すると 1 を, 失敗すると 0 を返します. 失敗の原因は, mecab_strerror で取得できます.  | 
|---|
| 100 | (define-cproc mecab-nbest-init (mecab::<mecab-t> str::<const-cstring>) | 
|---|
| 101 |   (call <int> "mecab_nbest_init")) | 
|---|
| 102 |  | 
|---|
| 103 | ;;int mecab_nbest_init2 (mecab_t* m, const char* str, len); | 
|---|
| 104 | ;;    mecab_nbest_init () とほぼ同じですが, len にて文の長さを指定できます. | 
|---|
| 105 | (define-cproc mecab-nbest-init2 (mecab::<mecab-t> str::<const-cstring> len::<uint>) | 
|---|
| 106 |   (call <int> "mecab_nbest_init2")) | 
|---|
| 107 |  | 
|---|
| 108 | ;;const char *mecab_nbest_next_tostr (mecab_t* m) | 
|---|
| 109 | ;;    mecab_nbest_init() の後, この関数を順次呼ぶことで, 確からしい解析結果 を, 順番に取得できます. 失敗すると (これ以上の解が存在しない場合) NULL を返します. 失 | 
|---|
| 110 | ;;    敗の原因は, mecab_strerror で取得できます.  | 
|---|
| 111 | ;; [Gauche] NULLの場合に#fを返すようにしてある | 
|---|
| 112 | (define-cproc mecab-nbest-next-tostr (mecab::<mecab-t>) | 
|---|
| 113 | " const char *s = mecab_nbest_next_tostr(mecab); | 
|---|
| 114 |   return s ? SCM_MAKE_STR_COPYING(s) : SCM_FALSE;") | 
|---|
| 115 | ;  (call <const-cstring> "mecab_nbest_next_tostr")) | 
|---|
| 116 |  | 
|---|
| 117 | ;;const mecab_node_t *mecab_next_tonode (mecab_t* m) | 
|---|
| 118 | ;;    mecab_next_tostr とほぼ同じですが,文字列ではなく mecab_node_t 型の形態素情報を返します. | 
|---|
| 119 | ;; [Gauche] NULLの場合に#fを返すようにしてある | 
|---|
| 120 | (define-cproc mecab-nbest-next-tonode (mecab::<mecab-t>) | 
|---|
| 121 | " const mecab_node_t *node = mecab_nbest_next_tonode(mecab); | 
|---|
| 122 |   return node ? wrap_mecab_node_t(node) : SCM_FALSE;") | 
|---|
| 123 | ;  (call <const-mecab-node-t> "mecab_nbest_next_tonode")) | 
|---|
| 124 |  | 
|---|
| 125 | ;;char *mecab_nbest_next_tostr2 (mecab_t *m , char *ostr, size_t olen) | 
|---|
| 126 | ;;    mecab_nbest_tostr() とほぼ同じですが, ostr, olen にて出力用のバッファを 指定できます. 失敗すると (これ以上の解が存在しない場合) NULL を返します. また, 出力 | 
|---|
| 127 | ;;    バッファが溢れた場合も NULL を返します. 失敗の原因は, mecab_strerror で取得できます. | 
|---|
| 128 | ;;(define-cproc mecab-nbest-next-tostr2 (mecab::<mecab-t> ostr::<const-cstring> olen::<uint>) | 
|---|
| 129 | ;;  (call <const-cstring> "mecab_nbest_next_tostr2")) | 
|---|
| 130 |  | 
|---|
| 131 | ;;void mecab_destroy(mecab_t *m) | 
|---|
| 132 | ;;    mecab_t 型のポインタを解放します. | 
|---|
| 133 | ;(define-cproc mecab-destroy (m::<mecab-t>) | 
|---|
| 134 | ;  (call <void> "mecab_destroy")) | 
|---|
| 135 | (define-cproc mecab-destroy (m::<mecab>) | 
|---|
| 136 | "  if (m->m) { mecab_destroy(m->m); m->m = NULL; } | 
|---|
| 137 |    SCM_RETURN(SCM_UNDEFINED); ") | 
|---|
| 138 |  | 
|---|
| 139 | (define-cproc mecab-destroyed? (m::<mecab-t>) | 
|---|
| 140 | "  SCM_RETURN(SCM_MAKE_BOOL(m == NULL)); ") | 
|---|
| 141 |  | 
|---|
| 142 | ;;;;;;; | 
|---|
| 143 | ;;const mecab_node_t *mecab_sparse_tonode (mecab_t *m, const char *str) | 
|---|
| 144 | ;;    解析を行います. 引数には, mecab_new で得られた mecab_t 型のポインタと, | 
|---|
| 145 | ;;    解析したい文を char 型のポインタ文字列として与えます. | 
|---|
| 146 | ;;    成功すれば, 文頭の形態素(mecab_node_t型)へのポインタが返り, 失敗すれば, NULLが返ってきます. | 
|---|
| 147 | ;;    mecab_node_t は双方向リストになっているため next, prev を順にたどる事で全形態素を列挙することができます. | 
|---|
| 148 | ;;    戻り値のポインタが指すメモリ領域は, 呼び出し側で管理する必要はありませんが,mecab_sparse_tonode を呼ぶ度に上書きされます. | 
|---|
| 149 | ;;    また, mecab_destroy を呼ぶと解放されます. | 
|---|
| 150 | (define-cproc mecab-sparse-tonode (mecab::<mecab-t> str::<const-cstring>) | 
|---|
| 151 |   (call <const-mecab-node-t> "mecab_sparse_tonode")) | 
|---|
| 152 |  | 
|---|
| 153 | ;;const mecab_node_t *mecab_sparse_tonode2 (mecab_t *m, const char *str, size_t len) | 
|---|
| 154 | ;;    mecab_sparse_tonode とほぼ同じですが, len にて, 解析する文の長さを指定できます.  | 
|---|
| 155 | (define-cproc mecab-sparse-tonode2 (mecab::<mecab-t> str::<const-cstring> siz::<uint>) | 
|---|
| 156 |   (call <const-mecab-node-t> "mecab_sparse_tonode2")) | 
|---|
| 157 |  | 
|---|
| 158 |  | 
|---|
| 159 | ;;;;;; | 
|---|
| 160 | ;;const mecab_dictionary_info_t *mecab_dictionary_info(mecab_t *m) | 
|---|
| 161 | ;;    辞書情報を取得します. 引数には, mecab_new で得られた mecab_t 型のポインタを与えます. | 
|---|
| 162 | ;;    mecab_dictoinary_info_t は単方向リストになっています. | 
|---|
| 163 | ;;    複数の辞書を使っている場合は, next を辿っていくことで全ての辞書情報にアクセスできます. | 
|---|
| 164 | ;;    mecab_dictionary_info() が返す領域は mecab が管理していますので解放する必要はありません. | 
|---|
| 165 | (define-cproc mecab-dictionary-info (mecab::<mecab-t>) | 
|---|
| 166 |   (call <const-mecab-dictionary-info-t> "mecab_dictionary_info")) | 
|---|
| 167 |  | 
|---|
| 168 | ;;int mecab_get_partial(mecab_t *m) | 
|---|
| 169 | ;;    部分解析の現在のモードを取得します。(0: off, 1:on) | 
|---|
| 170 | (define-cproc mecab-get-partial (mecab::<mecab-t>) | 
|---|
| 171 |   (call <int> "mecab_get_partial")) | 
|---|
| 172 | ;;void mecab_set_partial(mecab_t *m) | 
|---|
| 173 | ;;    部分解析の現在のモードを設定します。(0: off, 1:on) | 
|---|
| 174 | (define-cproc mecab-set-partial (mecab::<mecab-t> partial::<int>) | 
|---|
| 175 |   (call <void> "mecab_set_partial")) | 
|---|
| 176 |  | 
|---|
| 177 | ;;float mecab_get_theta(mecab_t *m) | 
|---|
| 178 | ;;    ソフト分かち書きの温度パラメータを取得します。 | 
|---|
| 179 | (define-cproc mecab-get-theta (mecab::<mecab-t>) | 
|---|
| 180 |   (call <float> "mecab_get_theta")) | 
|---|
| 181 | ;;void mecab_set_theta(mecab_t *m, float theta) | 
|---|
| 182 | ;;    ソフト分かち書きの温度パラメータを設定します。 | 
|---|
| 183 | (define-cproc mecab-set-theta (mecab::<mecab-t> theta::<float>) | 
|---|
| 184 |   (call <void> "mecab_set_theta")) | 
|---|
| 185 |  | 
|---|
| 186 | ;;int mecab_get_lattice_level(mecab_t *m) | 
|---|
| 187 | ;;    ラティスレベル(どの程度のラティス情報を解析時に構築するか)を取得します。 | 
|---|
| 188 | ;;        * 0: 最適解のみが出力可能なレベル (デフォルト, 高速) | 
|---|
| 189 | ;;        * 1: N-best 解が出力可能なレベル (中速) | 
|---|
| 190 | ;;        * 2: ソフトわかち書きが可能なレベル (低速)  | 
|---|
| 191 | (define-cproc mecab-get-lattice-level (mecab::<mecab-t>) | 
|---|
| 192 |   (call <int> "mecab_get_lattice_level")) | 
|---|
| 193 | ;;void mecab_set_lattice_level(mecab_t *m, int lattice_level) | 
|---|
| 194 | ;;    ラティスレベルを設定します。 | 
|---|
| 195 | (define-cproc mecab-set-lattice-level (mecab::<mecab-t> level::<int>) | 
|---|
| 196 |   (call <void> "mecab_set_lattice_level")) | 
|---|
| 197 |  | 
|---|
| 198 | ;;int mecab_get_all_morphs(mecab_t *m) | 
|---|
| 199 | ;;    出力モードを取得します。(0: ベスト解のみ, 1:全出力)  | 
|---|
| 200 | (define-cproc mecab-get-all-morphs (mecab::<mecab-t>) | 
|---|
| 201 |   (call <int> "mecab_get_all_morphs")) | 
|---|
| 202 | ;;void mecab_set_all_morphs(mecab_t *m, int all_mophrs) | 
|---|
| 203 | ;;    出力モードを設定します。(0: ベスト解のみ, 1:全出力) | 
|---|
| 204 | (define-cproc mecab-set-all-morphs (mecab::<mecab-t> all_morphs::<int>) | 
|---|
| 205 |   (call <void> "mecab_set_all_morphs")) | 
|---|
| 206 |  | 
|---|
| 207 | ;;;;;;;;;;; | 
|---|
| 208 | (define-cproc mecab-format-node (mecab::<mecab-t> node::<const-mecab-node-t>) | 
|---|
| 209 |   (call <const-cstring> "mecab_format_node")) | 
|---|
| 210 |  | 
|---|
| 211 | (define-cproc mecab-dict-index (&rest args) | 
|---|
| 212 |   (expr <int> "mecab_call_int_func(&mecab_dict_index,args)")) | 
|---|
| 213 | (define-cproc mecab-dict-gen (&rest args) | 
|---|
| 214 |   (expr <int> "mecab_call_int_func(&mecab_dict_gen,args)")) | 
|---|
| 215 | (define-cproc mecab-cost-train (&rest args) | 
|---|
| 216 |   (expr <int> "mecab_call_int_func(&mecab_cost_train,args)")) | 
|---|
| 217 | (define-cproc mecab-system-eval (&rest args) | 
|---|
| 218 |   (expr <int> "mecab_call_int_func(&mecab_system_eval,args)")) | 
|---|
| 219 | (define-cproc mecab-test-gen (&rest args) | 
|---|
| 220 |   (expr <int> "mecab_call_int_func(&mecab_test_gen,args)")) | 
|---|
| 221 |  | 
|---|
| 222 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 
|---|
| 223 | ;; | 
|---|
| 224 | ;; mecab_node_t | 
|---|
| 225 | ;; | 
|---|
| 226 | ;; 一つ前の形態素へのポインタ | 
|---|
| 227 | (define-cproc mecab-node-prev (node::<const-mecab-node-t>) | 
|---|
| 228 | "  const mecab_node_t *prev_node = node->prev; | 
|---|
| 229 |   return prev_node ? wrap_mecab_node_t(prev_node) : SCM_FALSE;") | 
|---|
| 230 | ;  return node ? node : SCM_FALSE;") | 
|---|
| 231 | ;  (expr <const-mecab-node-t> "node->prev")) | 
|---|
| 232 | ;; 一つ先の形態素へのポインタ | 
|---|
| 233 | (define-cproc mecab-node-next (node::<const-mecab-node-t>) | 
|---|
| 234 | "  const mecab_node_t *next_node = node->next; | 
|---|
| 235 |   return next_node ? wrap_mecab_node_t(next_node) : SCM_FALSE;") | 
|---|
| 236 | ;  return node ? node : SCM_FALSE;") | 
|---|
| 237 | ;  (expr <const-mecab-node-t> "node->next")) | 
|---|
| 238 | ;; 同じ位置で終わる形態素へのポインタ | 
|---|
| 239 | (define-cproc mecab-node-enext (node::<const-mecab-node-t>) | 
|---|
| 240 | "  const mecab_node_t *enext_node = node->enext; | 
|---|
| 241 |   return enext_node ? wrap_mecab_node_t(enext_node) : SCM_FALSE;") | 
|---|
| 242 | ;  (expr <const-mecab-node-t> "node->enext")) | 
|---|
| 243 | ;; 同じ開始位置で始まる形態素へのポインタ | 
|---|
| 244 | (define-cproc mecab-node-bnext (node::<const-mecab-node-t>) | 
|---|
| 245 | "  const mecab_node_t *bnext_node = node->bnext; | 
|---|
| 246 |   return bnext_node ? wrap_mecab_node_t(bnext_node) : SCM_FALSE;") | 
|---|
| 247 | ;  (expr <const-mecab-node-t> "node->bnext")) | 
|---|
| 248 | ;; 形態素の文字列情報 | 
|---|
| 249 | ;; NULL terminateされていません. 文字列として取り出すには | 
|---|
| 250 | ;; strncpy(buf, node->feature, node->length) とする必要があります | 
|---|
| 251 | (define-cproc mecab-node-surface (node::<const-mecab-node-t>) | 
|---|
| 252 | ;  (expr <const-cstring> "(const char *)node->surface")) | 
|---|
| 253 |   "  char buf[node->length + 1]; | 
|---|
| 254 |      memcpy(buf, node->surface, node->length); | 
|---|
| 255 |      buf[node->length] = 0; | 
|---|
| 256 |      return SCM_MAKE_STR_COPYING(buf);"); | 
|---|
| 257 | ;     return Scm_MakeString( (const char *)node->surface, | 
|---|
| 258 | ;                 3, 3/*node->length*/, | 
|---|
| 259 | ;          SCM_STRING_COPYING);") | 
|---|
| 260 | ;; CSV で表記された素性情報 | 
|---|
| 261 | (define-cproc mecab-node-feature (node::<const-mecab-node-t>) | 
|---|
| 262 |   (expr <const-cstring> "(const char *)node->feature")) | 
|---|
| 263 | ;; unsigned int length; 形態素の長さ | 
|---|
| 264 | (define-cproc mecab-node-length (node::<const-mecab-node-t>) | 
|---|
| 265 |   (expr <uint> "node->length")) | 
|---|
| 266 | ;; unsigned int rlength; 形態素の長さ(先頭のスペースを含む) | 
|---|
| 267 | (define-cproc mecab-node-rlength (node::<const-mecab-node-t>) | 
|---|
| 268 |   (expr <uint> "node->rlength")) | 
|---|
| 269 | ;; unsigned int id; 形態素に付与される ユニークID | 
|---|
| 270 | (define-cproc mecab-node-id (node::<const-mecab-node-t>) | 
|---|
| 271 |   (expr <uint> "node->id")) | 
|---|
| 272 | ;; unsigned short rcAttr;      // 右文脈 id | 
|---|
| 273 | (define-cproc mecab-node-rc-attr (node::<const-mecab-node-t>) | 
|---|
| 274 |   (expr <uint> "node->rcAttr")) | 
|---|
| 275 | ;; unsigned short lcAttr;      // 左文脈 id | 
|---|
| 276 | (define-cproc mecab-node-lc-attr (node::<const-mecab-node-t>) | 
|---|
| 277 |   (expr <uint> "node->lcAttr")) | 
|---|
| 278 | ;; unsigned short posid;       // 形態素 ID | 
|---|
| 279 | (define-cproc mecab-node-posid (node::<const-mecab-node-t>) | 
|---|
| 280 |   (expr <uint> "node->posid")) | 
|---|
| 281 | ;; unsigned char  char_type;   // 文字種情報 | 
|---|
| 282 | (define-cproc mecab-node-char-type (node::<const-mecab-node-t>) | 
|---|
| 283 |   (expr <uint> "node->char_type")) | 
|---|
| 284 | ;; unsigned char  stat;        // 形態素の種類: 以下のマクロの値 | 
|---|
| 285 | ;;                             // #define MECAB_NOR_NODE  0 | 
|---|
| 286 | ;;                             // #define MECAB_UNK_NODE  1 | 
|---|
| 287 | ;;                             // #define MECAB_BOS_NODE  2 | 
|---|
| 288 | ;;                             // #define MECAB_EOS_NODE  3 | 
|---|
| 289 | (define-cproc mecab-node-stat (node::<const-mecab-node-t>) | 
|---|
| 290 |   "  const char *syms[4] = { \"mecab-nor-node\",\"mecab-unk-node\",\"mecab-bos-node\",\"mecab-eos-node\" }; | 
|---|
| 291 |      return Scm_Intern( (ScmString *)SCM_MAKE_STR_COPYING(syms[node->stat]) );") | 
|---|
| 292 | ;; unsigned char  isbest;      // ベスト解の場合 1, それ以外 0 | 
|---|
| 293 | (define-cproc mecab-node-best? (node::<const-mecab-node-t>) | 
|---|
| 294 |   (expr <boolean> "node->isbest")) | 
|---|
| 295 | ;; float alpha;       // forward backward の foward log 確率 | 
|---|
| 296 | (define-cproc mecab-node-alpha (node::<const-mecab-node-t>) | 
|---|
| 297 |   (expr <float> "node->alpha")) | 
|---|
| 298 | ;; float beta;        // forward backward の backward log 確率 | 
|---|
| 299 | (define-cproc mecab-node-beta (node::<const-mecab-node-t>) | 
|---|
| 300 |   (expr <float> "node->beta")) | 
|---|
| 301 | ;; float prob;        // 周辺確率 | 
|---|
| 302 | ;;                              // alpha, beta, prob は -l 2 オプションを指定した時に定義されます | 
|---|
| 303 | (define-cproc mecab-node-prob (node::<const-mecab-node-t>) | 
|---|
| 304 |   (expr <float> "node->prob")) | 
|---|
| 305 | ;; short wcost;       // 単語生起コスト | 
|---|
| 306 | (define-cproc mecab-node-wcost (node::<const-mecab-node-t>) | 
|---|
| 307 |   (expr <int> "node->wcost")) | 
|---|
| 308 | ;; long cost;        // 累積コスト | 
|---|
| 309 | (define-cproc mecab-node-cost (node::<const-mecab-node-t>) | 
|---|
| 310 |   (expr <int> "node->cost")) | 
|---|
| 311 |  | 
|---|
| 312 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 
|---|
| 313 | ;; | 
|---|
| 314 | ;; mecab_dictionary_info_t | 
|---|
| 315 | ;; | 
|---|
| 316 |                                                                                 ; #define MECAB_USR_DIC   1 | 
|---|
| 317 |                                                                                 ; #define MECAB_SYS_DIC   0 | 
|---|
| 318 |                                                                                 ; #define MECAB_UNK_DIC   2 | 
|---|
| 319 | ;; const char *filename;  // 辞書のファイル名 | 
|---|
| 320 | (define-cproc mecab-dictionary-info-filename (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 321 |   (expr <const-cstring> "dinfo->filename")) | 
|---|
| 322 | ;; const char *charset;   // 辞書の文字コード | 
|---|
| 323 | (define-cproc mecab-dictionary-info-charset (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 324 |   (expr <const-cstring> "dinfo->charset")) | 
|---|
| 325 | ;; unsigned int size;      // 単語数 | 
|---|
| 326 | (define-cproc mecab-dictionary-info-size (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 327 |   (expr <uint> "dinfo->size")) | 
|---|
| 328 | ;; int type;      // 辞書のタイプ | 
|---|
| 329 | ;;                                             // MECAB_(USR|SYS|UNK)_DIC のいずれか | 
|---|
| 330 | (define-cproc mecab-dictionary-info-type (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 331 |   "  const char *syms[3] = { \"mecab-sys-dic\",\"mecab-usr-dic\",\"mecab-unk-dic\" }; | 
|---|
| 332 |      return Scm_Intern( (ScmString *)SCM_MAKE_STR_COPYING(syms[dinfo->type]) );") | 
|---|
| 333 | ;; unsigned int lsize;     // 左文脈 ID のサイズ | 
|---|
| 334 | (define-cproc mecab-dictionary-info-lsize (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 335 |   (expr <uint> "dinfo->lsize")) | 
|---|
| 336 | ;; unsigned int rsize;     // 右文脈 ID のサイズ | 
|---|
| 337 | (define-cproc mecab-dictionary-info-rsize (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 338 |   (expr <uint> "dinfo->rsize")) | 
|---|
| 339 | ;; unsigned short version;   // バージョン | 
|---|
| 340 | (define-cproc mecab-dictionary-info-version (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 341 |   (expr <uint> "dinfo->version")) | 
|---|
| 342 | ;; struct mecab_dictionary_info_t *next;      // 次の辞書へのポインタ | 
|---|
| 343 | (define-cproc mecab-dictionary-info-next (dinfo::<const-mecab-dictionary-info-t>) | 
|---|
| 344 |   (expr <const-mecab-dictionary-info-t> "dinfo->next")) | 
|---|
| 345 |  | 
|---|
| 346 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 
|---|
| 347 |  | 
|---|
| 348 | ;; Local variables: | 
|---|
| 349 | ;; mode: scheme | 
|---|
| 350 | ;; end: | 
|---|