- Timestamp:
- 03/19/09 08:01:04 (16 years ago)
- Location:
- lang/gauche/cabocha-gauche-0.60pre4
- Files:
-
- 1 added
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/gauche/cabocha-gauche-0.60pre4/Makefile.in
r88 r89 49 49 cabocha.$(SOEXT): $(cabocha_SRCS) 50 50 $(GAUCHE_PACKAGE) compile \ 51 --local=$(LOCAL_PATHS) --ldflags= -lcabocha--verbose cabocha $(cabocha_SRCS)51 --local=$(LOCAL_PATHS) --ldflags="-lmecab -lcabocha" --verbose cabocha $(cabocha_SRCS) 52 52 53 53 check : all -
lang/gauche/cabocha-gauche-0.60pre4/cabocha.c
r88 r89 9 9 #include <gauche/extend.h> 10 10 11 #include <mecab.h> 12 #include "mecab.h" 11 13 #include <cabocha.h> 12 14 #include "cabocha.h" … … 25 27 } 26 28 29 // cabocha_tree_t 30 cabocha_tree_t* unwrap_cabocha_tree_t(ScmObj obj) 31 { 32 return SCM_CABOCHA_TREE(obj)->ctree; 33 } 34 ScmObj wrap_cabocha_tree_t(cabocha_tree_t *ctree) 35 { 36 ScmCaboChaTree *obj = SCM_NEW(ScmCaboChaTree); 37 SCM_SET_CLASS(obj, SCM_CLASS_CABOCHA_TREE); 38 obj->ctree = ctree; 39 return SCM_OBJ(obj); 40 } 41 42 // cabocha_chunk_t 43 cabocha_chunk_t* unwrap_cabocha_chunk_t(ScmObj obj) 44 { 45 return SCM_CABOCHA_CHUNK(obj)->cchunk; 46 } 47 ScmObj wrap_cabocha_chunk_t(cabocha_chunk_t *cchunk) 48 { 49 ScmCaboChaChunk *obj = SCM_NEW(ScmCaboChaChunk); 50 SCM_SET_CLASS(obj, SCM_CLASS_CABOCHA_CHUNK); 51 obj->cchunk = cchunk; 52 return SCM_OBJ(obj); 53 } 54 55 // cabocha_token_t 56 cabocha_token_t* unwrap_cabocha_token_t(ScmObj obj) 57 { 58 return SCM_CABOCHA_TOKEN(obj)->ctok; 59 } 60 ScmObj wrap_cabocha_token_t(cabocha_token_t *ctok) 61 { 62 ScmCaboChaToken *obj = SCM_NEW(ScmCaboChaToken); 63 SCM_SET_CLASS(obj, SCM_CLASS_CABOCHA_TOKEN); 64 obj->ctok = ctok; 65 return SCM_OBJ(obj); 66 } 67 68 /* mecab_node_t */ 69 const mecab_node_t* unwrap_mecab_node_t(ScmObj obj) 70 { 71 return SCM_MECAB_NODE(obj)->mn; 72 } 73 ScmObj wrap_mecab_node_t(const mecab_node_t *mn) 74 { 75 ScmMeCabNode *obj = SCM_NEW(ScmMeCabNode); 76 SCM_SET_CLASS(obj, SCM_CLASS_MECAB_NODE); 77 obj->mn = mn; 78 return SCM_OBJ(obj); 79 } 27 80 28 81 /* APIs with (int argc, char **argv) */ … … 67 120 } 68 121 122 ScmObj Scm_MakeStringList(const char **strs, int size) 123 { 124 if (size==0) return SCM_NIL; 125 ScmObj p = Scm_Cons(SCM_MAKE_STR_COPYING(strs[size-1]),SCM_NIL); 126 for (int i=size-2; i>=0; i--) { 127 p = Scm_Cons(SCM_MAKE_STR_COPYING(strs[i]), p); 128 } 129 return p; 130 } 131 69 132 /* 70 133 * Module initialization function. -
lang/gauche/cabocha-gauche-0.60pre4/cabocha.h
r88 r89 15 15 SCM_DECL_BEGIN 16 16 17 /* CaboCha_t wrapper */17 /* cabocha_t wrapper */ 18 18 typedef struct ScmCaboChaRec { 19 19 SCM_HEADER; … … 27 27 extern ScmObj wrap_cabocha_t(cabocha_t *m); 28 28 29 /* cabocha_tree_t wrapper */ 30 typedef struct ScmCaboChaTreeRec { 31 SCM_HEADER; 32 cabocha_tree_t *ctree; /* NULL if closed */ 33 } ScmCaboChaTree; 34 SCM_CLASS_DECL(Scm_CaboChaTreeClass); 35 #define SCM_CLASS_CABOCHA_TREE (&Scm_CaboChaTreeClass) 36 #define SCM_CABOCHA_TREE(obj) ((ScmCaboChaTree*)(obj)) 37 #define SCM_CABOCHA_TREEP(obj) (SCM_XTYPEP(obj, SCM_CLASS_CABOCHA_TREE)) 38 extern cabocha_tree_t* unwrap_cabocha_tree_t(ScmObj obj); 39 extern ScmObj wrap_cabocha_tree_t(cabocha_tree_t *m); 40 41 /* cabocha_chunk_t wrapper */ 42 typedef struct ScmCaboChaChunkRec { 43 SCM_HEADER; 44 cabocha_chunk_t *cchunk; /* NULL if closed */ 45 } ScmCaboChaChunk; 46 SCM_CLASS_DECL(Scm_CaboChaChunkClass); 47 #define SCM_CLASS_CABOCHA_CHUNK (&Scm_CaboChaChunkClass) 48 #define SCM_CABOCHA_CHUNK(obj) ((ScmCaboChaChunk*)(obj)) 49 #define SCM_CABOCHA_CHUNKP(obj) (SCM_XTYPEP(obj, SCM_CLASS_CABOCHA_CHUNK)) 50 extern cabocha_chunk_t* unwrap_cabocha_chunk_t(ScmObj obj); 51 extern ScmObj wrap_cabocha_chunk_t(cabocha_chunk_t *m); 52 53 /* cabocha_token_t wrapper */ 54 typedef struct ScmCaboChaTokenRec { 55 SCM_HEADER; 56 cabocha_token_t *ctok; /* NULL if closed */ 57 } ScmCaboChaToken; 58 SCM_CLASS_DECL(Scm_CaboChaTokenClass); 59 #define SCM_CLASS_CABOCHA_TOKEN (&Scm_CaboChaTokenClass) 60 #define SCM_CABOCHA_TOKEN(obj) ((ScmCaboChaToken*)(obj)) 61 #define SCM_CABOCHA_TOKENP(obj) (SCM_XTYPEP(obj, SCM_CLASS_CABOCHA_TOKEN)) 62 extern cabocha_token_t* unwrap_cabocha_token_t(ScmObj obj); 63 extern ScmObj wrap_cabocha_token_t(cabocha_token_t *m); 64 65 29 66 /* APIs with (int argc, char **argv) */ 30 67 typedef cabocha_t *(*cabocha_func_with_args)(int argc, char **argv); 31 typedef int (*int_func_with_args)(int argc, char **argv);68 // typedef int (*int_func_with_args)(int argc, char **argv); 32 69 extern cabocha_t *cabocha_call_cabocha_func(cabocha_func_with_args fn, ScmObj args); 33 70 extern int cabocha_call_int_func(int_func_with_args fn, ScmObj args); -
lang/gauche/cabocha-gauche-0.60pre4/cabocha.scm
r88 r89 8 8 (export <cabocha> 9 9 cabocha? 10 cabocha-do 10 11 cabocha-new cabocha-new2 11 cabocha-destroy12 cabocha-destroyed?13 14 12 cabocha-sparse-tostr cabocha-sparse-tostr2 15 13 cabocha-strerror 14 cabocha-destroy cabocha-destroyed? 15 cabocha-sparse-totree cabocha-sparse-totree2 16 17 cabocha-tree-new 18 cabocha-tree-destroy 19 cabocha-tree-empty 20 cabocha-tree-clear 21 cabocha-tree-clear-chunk 22 cabocha-tree-size 23 cabocha-tree-chunk-size 24 cabocha-tree-token-size 25 cabocha-tree-sentence 26 cabocha-tree-sentence-size 27 cabocha-tree-set-sentence 28 cabocha-tree-read 29 cabocha-tree-read-from-mecab-node 30 cabocha-tree-token 31 cabocha-tree-chunk 32 cabocha-tree-add-token 33 cabocha-tree-add-chunk 34 cabocha-tree-strdup 35 cabocha-tree-alloc 36 cabocha-tree-tostr 37 cabocha-tree-set-charset cabocha-tree-charset 38 cabocha-tree-set-posset cabocha-tree-posset 39 cabocha-tree-set-output-layer cabocha-tree-output-layer 40 41 cabocha-learn 42 cabocha-system-eval 43 cabocha-model-index 44 45 cabocha-chunk-link 46 cabocha-chunk-head-pos cabocha-chunk-func-pos 47 cabocha-chunk-token-size cabocha-chunk-token-pos 48 cabocha-chunk-score 49 cabocha-chunk-feature-list cabocha-chunk-feature-list-size 50 51 cabocha-token-surface 52 cabocha-token-normalized-surface 53 cabocha-token-feature 54 cabocha-token-feature-list 55 cabocha-token-feature-list-size 56 cabocha-token-ne 57 cabocha-token-chunk 16 58 )) 17 59 -
lang/gauche/cabocha-gauche-0.60pre4/cabochalib.stub
r88 r89 9 9 #include <gauche/extend.h> 10 10 11 #include <mecab.h> 12 #include \"mecab.h\" 11 13 #include <cabocha.h> 12 14 #include \"cabocha.h\" … … 16 18 17 19 (define-cclass <cabocha> "ScmCaboCha*" "Scm_CaboChaClass" () ()) 18 19 20 (define-type <cabocha-t> "cabocha_t*" "cabocha_t" 20 21 "SCM_CABOCHAP" "unwrap_cabocha_t" "wrap_cabocha_t") 21 22 22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 23 (define-cclass <cabocha-tree> "ScmCaboChaTree*" "Scm_CaboChaTreeClass" () ()) 24 (define-type <cabocha-tree-t> "cabocha_tree_t*" "cabocha_tree_t" 25 "SCM_CABOCHA_TREEP" "unwrap_cabocha_tree_t" "wrap_cabocha_tree_t") 26 27 (define-cclass <cabocha-chunk> "ScmCaboChaChunk*" "Scm_CaboChaChunkClass" () ()) 28 (define-type <cabocha-chunk-t> "cabocha_chunk_t*" "cabocha_chunk_t" 29 "SCM_CABOCHA_CHUNKP" "unwrap_cabocha_chunk_t" "wrap_cabocha_chunk_t") 30 31 (define-cclass <cabocha-token> "ScmCaboChaToken*" "Scm_CaboChaTokenClass" () ()) 32 (define-type <cabocha-token-t> "cabocha_token_t*" "cabocha_token_t" 33 "SCM_CABOCHA_TOKENP" "unwrap_cabocha_token_t" "wrap_cabocha_token_t") 34 35 ;;; 36 ;(define-cclass <mecab> "ScmMeCab*" "Scm_MeCabClass" () ()) 37 (define-cclass <mecab-node> "ScmMeCabNode*" "Scm_MeCabNodeClass" () ()) 38 ;(define-cclass <mecab-dictionary-info> "ScmMeCabDictionaryInfo*" "Scm_MeCabDictionaryInfoClass" () ()) 39 (define-type <const-mecab-node-t> "const mecab_node_t*" "const mecab_node_t" 40 "SCM_MECAB_NODEP" "unwrap_mecab_node_t" "wrap_mecab_node_t") 41 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 43 44 (define-cproc cabocha-do (&rest args) 45 (expr <int> "cabocha_call_int_func(&cabocha_do,args)")) 46 47 ;; 48 ;; parser 49 ;; 23 50 24 51 ;;cabocha_t *cabocha_new(int argc, char **argv) … … 73 100 " SCM_RETURN(SCM_MAKE_BOOL(c == NULL)); ") 74 101 102 ;; 103 (define-cproc cabocha-sparse-totree (c::<cabocha-t> str::<const-cstring>) 104 (call <cabocha-tree-t> "cabocha_sparse_totree")) 105 106 (define-cproc cabocha-sparse-totree2 (c::<cabocha-t> str::<const-cstring> len::<uint>) 107 (call <cabocha-tree-t> "cabocha_sparse_totree2")) 108 109 ;; 110 ;; tree 111 ;; 112 (define-cproc cabocha-tree-new () 113 (call <cabocha-tree-t> "cabocha_tree_new")) 114 (define-cproc cabocha-tree-destroy (tree::<cabocha-tree-t>) 115 (call <void> "cabocha_tree_destroy")) 116 (define-cproc cabocha-tree-empty (tree::<cabocha-tree-t>) 117 (call <int> "cabocha_tree_empty")) 118 (define-cproc cabocha-tree-clear (tree::<cabocha-tree-t>) 119 (call <void> "cabocha_tree_clear")) 120 (define-cproc cabocha-tree-clear-chunk (tree::<cabocha-tree-t>) 121 (call <void> "cabocha_tree_clear_chunk")) 122 (define-cproc cabocha-tree-size (tree::<cabocha-tree-t>) 123 (call <uint> "cabocha_tree_size")) 124 (define-cproc cabocha-tree-chunk-size (tree::<cabocha-tree-t>) 125 (call <uint> "cabocha_tree_chunk_size")) 126 (define-cproc cabocha-tree-token-size (tree::<cabocha-tree-t>) 127 (call <uint> "cabocha_tree_token_size")) 128 (define-cproc cabocha-tree-sentence (tree::<cabocha-tree-t>) 129 (call <const-cstring> "cabocha_tree_sentence")) 130 (define-cproc cabocha-tree-sentence-size (tree::<cabocha-tree-t>) 131 (call <uint> "cabocha_tree_sentence_size")) 132 (define-cproc cabocha-tree-set-sentence (tree::<cabocha-tree-t> sentence::<const-cstring> length::<uint>) 133 (call <void> "cabocha_tree_set_sentence")) 134 (define-cproc cabocha-tree-read (tree::<cabocha-tree-t> input::<const-cstring> length::<uint> input-layer::<int>) 135 ;; cabocha_input_layer_t : enum { INPUT_RAW_SENTENCE, _POS, _CHUNK, _SELECTION, _DEP } 136 (call <int> "cabocha_tree_read")) 137 (define-cproc cabocha-tree-read-from-mecab-node (tree::<cabocha-tree-t> node::<const-mecab-node-t>) 138 (call <int> "cabocha_tree_read_from_mecab_node")) 139 140 (define-cproc cabocha-tree-token (tree::<cabocha-tree-t> i::<uint>) 141 (call <cabocha-token-t> "cabocha_tree_token")) ;; const 142 (define-cproc cabocha-tree-chunk (tree::<cabocha-tree-t> i::<uint>) 143 (call <cabocha-chunk-t> "cabocha_tree_chunk")) ;; const 144 145 (define-cproc cabocha-tree-add-token (tree::<cabocha-tree-t>) 146 (call <cabocha-token-t> "cabocha_tree_add_token")) 147 (define-cproc cabocha-tree-add-chunk (tree::<cabocha-tree-t>) 148 (call <cabocha-chunk-t> "cabocha_tree_add_chunk")) 149 150 (define-cproc cabocha-tree-strdup (tree::<cabocha-tree-t> str::<const-cstring>) 151 (call <const-cstring> "cabocha_tree_strdup")) 152 (define-cproc cabocha-tree-alloc (tree::<cabocha-tree-t> size::<uint>) 153 (call <const-cstring> "cabocha_tree_alloc")) 154 155 (define-cproc cabocha-tree-tostr (tree::<cabocha-tree-t> format::<int>) ;; cabocha_format_t : ENUM { FORMAT-TREE -LATTICE -TREE_LATTICE -XML -NONE } 156 (call <const-cstring> "cabocha_tree_tostr")) 157 ;(define-cproc cabocha-tree-tostr2 (tree::<cabocha-tree-t> format::<cabocha-format-t str::<const-cstring> length::<uint>) 158 ; const char *cabocha_tree_tostr2(cabocha_tree_t* tree, cabocha_format_t format, 159 ; char *str, size_t length); 160 (define-cproc cabocha-tree-set-charset (tree::<cabocha-tree-t> charset::<int>) ;; cabocha_charset_t : enum { EUC_JP, CP932, UTF8, ASCII } 161 (call <void> "cabocha_tree_set_charset")) 162 (define-cproc cabocha-tree-charset (tree::<cabocha-tree-t>) 163 (call <int> "cabocha_tree_charset")) ;; cabocha_charset_t 164 (define-cproc cabocha-tree-set-posset (tree::<cabocha-tree-t> posset::<int>) ;; cabocha_posset_t : enum { IPA, JUMAN } 165 (call <void> "cabocha_tree_set_posset")) 166 (define-cproc cabocha-tree-posset (tree::<cabocha-tree-t>) 167 (call <int> "cabocha_tree_posset")) ;; cabocha_posset_t 168 (define-cproc cabocha-tree-set-output-layer (tree::<cabocha-tree-t> output-layer::<int>) 169 ;; cabocha_output_layer_t : enum { OUTPUT*_RAW_SENTENCE, _POS, _CHUNK, _SELECTION, _DEP } 170 (call <void> "cabocha_tree_set_output_layer")) 171 (define-cproc cabocha-tree-output-layer (tree::<cabocha-tree-t>) 172 (call <int> "cabocha_tree_output_layer")) ;; cabocha_output_layer_t 173 174 (define-cproc cabocha-learn (&rest args) 175 (expr <int> "cabocha_call_int_func(&cabocha_learn,args)")) 176 (define-cproc cabocha-system-eval (&rest args) 177 (expr <int> "cabocha_call_int_func(&cabocha_system_eval,args)")) 178 (define-cproc cabocha-model-index (&rest args) 179 (expr <int> "cabocha_call_int_func(&cabocha_model_index,args)")) 180 181 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 182 (define-cproc cabocha-chunk-link (chunk::<cabocha-chunk-t>) 183 (expr <int> "chunk->link")) 184 (define-cproc cabocha-chunk-head-pos (chunk::<cabocha-chunk-t>) 185 (expr <uint> "chunk->head_pos")) 186 (define-cproc cabocha-chunk-func-pos (chunk::<cabocha-chunk-t>) 187 (expr <uint> "chunk->func_pos")) 188 (define-cproc cabocha-chunk-token-size (chunk::<cabocha-chunk-t>) 189 (expr <uint> "chunk->token_size")) 190 (define-cproc cabocha-chunk-token-pos (chunk::<cabocha-chunk-t>) 191 (expr <uint> "chunk->token_pos")) 192 (define-cproc cabocha-chunk-score (chunk::<cabocha-chunk-t>) 193 (expr <float> "chunk->score")) 194 (define-cproc cabocha-chunk-feature-list (chunk::<cabocha-chunk-t>) 195 " return Scm_MakeStringList(chunk->feature_list,chunk->feature_list_size);") 196 (define-cproc cabocha-chunk-feature-list-size (chunk::<cabocha-chunk-t>) 197 (expr <uint> "chunk->feature_list_size")) 198 199 (define-cproc cabocha-token-surface (token::<cabocha-token-t>) 200 (expr <const-cstring> "token->surface")) 201 (define-cproc cabocha-token-normalized-surface (token::<cabocha-token-t>) 202 (expr <const-cstring> "token->normalized_surface")) 203 (define-cproc cabocha-token-feature (token::<cabocha-token-t>) 204 (expr <const-cstring> "token->feature")) 205 (define-cproc cabocha-token-feature-list (token::<cabocha-token-t>) 206 " return Scm_MakeStringList(token->feature_list,token->feature_list_size);") 207 (define-cproc cabocha-token-feature-list-size (token::<cabocha-token-t>) 208 (expr <uint> "token->feature_list_size")) 209 (define-cproc cabocha-token-ne (token::<cabocha-token-t>) 210 (expr <const-cstring> "token->ne")) 211 (define-cproc cabocha-token-chunk (token::<cabocha-token-t>) 212 (expr <cabocha-chunk-t> "token->chunk")) 213 214 75 215 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 76 216