MeCab
mecab.h
Go to the documentation of this file.
1 /*
2  MeCab -- Yet Another Part-of-Speech and Morphological Analyzer
3 
4  Copyright(C) 2001-2011 Taku Kudo <taku@chasen.org>
5  Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
6 */
7 #ifndef MECAB_MECAB_H_
8 #define MECAB_MECAB_H_
9 
10 /* C/C++ common data structures */
11 
20  const char *filename;
21 
25  const char *charset;
26 
30  unsigned int size;
31 
36  int type;
37 
41  unsigned int lsize;
42 
46  unsigned int rsize;
47 
51  unsigned short version;
52 
57 };
58 
62 struct mecab_path_t {
67 
72 
77 
83 
87  int cost;
88 
92  float prob;
93 };
94 
98 struct mecab_node_t {
103 
108 
113 
118 
124 
130 
136  const char *surface;
137 
141  const char *feature;
142 
146  unsigned int id;
147 
151  unsigned short length;
152 
156  unsigned short rlength;
157 
161  unsigned short rcAttr;
162 
166  unsigned short lcAttr;
167 
171  unsigned short posid;
172 
176  unsigned char char_type;
177 
182  unsigned char stat;
183 
187  unsigned char isbest;
188 
193  float alpha;
194 
199  float beta;
200 
205  float prob;
206 
210  short wcost;
211 
215  long cost;
216 };
217 
221 enum {
238 
242  MECAB_EON_NODE = 4
243 };
244 
248 enum {
253 
258 
262  MECAB_UNK_DIC = 2
263 };
264 
268 enum {
299 
305 };
306 
310 enum {
315 
320 
325 };
326 
327 /* C interface */
328 #ifdef __cplusplus
329 #include <cstdio>
330 #else
331 #include <stdio.h>
332 #endif
333 
334 #ifdef __cplusplus
335 extern "C" {
336 #endif
337 
338 #ifdef _WIN32
339 #ifndef NOMINMAX
340 #define NOMINMAX 1
341 #endif
342 #include <windows.h>
343 # ifdef DLL_EXPORT
344 # define MECAB_DLL_EXTERN __declspec(dllexport)
345 # define MECAB_DLL_CLASS_EXTERN __declspec(dllexport)
346 # else
347 # define MECAB_DLL_EXTERN __declspec(dllimport)
348 # endif
349 #endif
350 
351 #ifndef MECAB_DLL_EXTERN
352 # define MECAB_DLL_EXTERN extern
353 #endif
354 
355 #ifndef MECAB_DLL_CLASS_EXTERN
356 # define MECAB_DLL_CLASS_EXTERN
357 #endif
358 
359  typedef struct mecab_t mecab_t;
360  typedef struct mecab_model_t mecab_model_t;
361  typedef struct mecab_lattice_t mecab_lattice_t;
363  typedef struct mecab_node_t mecab_node_t;
364  typedef struct mecab_path_t mecab_path_t;
365 
366 #ifndef SWIG
367  /* C interface */
368 
369  /* old mecab interface */
373  MECAB_DLL_EXTERN mecab_t* mecab_new(int argc, char **argv);
374 
378  MECAB_DLL_EXTERN mecab_t* mecab_new2(const char *arg);
379 
383  MECAB_DLL_EXTERN const char* mecab_version();
384 
388  MECAB_DLL_EXTERN const char* mecab_strerror(mecab_t *mecab);
389 
393  MECAB_DLL_EXTERN void mecab_destroy(mecab_t *mecab);
394 
398  MECAB_DLL_EXTERN int mecab_get_partial(mecab_t *mecab);
399 
403  MECAB_DLL_EXTERN void mecab_set_partial(mecab_t *mecab, int partial);
404 
408  MECAB_DLL_EXTERN float mecab_get_theta(mecab_t *mecab);
409 
413  MECAB_DLL_EXTERN void mecab_set_theta(mecab_t *mecab, float theta);
414 
418  MECAB_DLL_EXTERN int mecab_get_lattice_level(mecab_t *mecab);
419 
423  MECAB_DLL_EXTERN void mecab_set_lattice_level(mecab_t *mecab, int level);
424 
428  MECAB_DLL_EXTERN int mecab_get_all_morphs(mecab_t *mecab);
429 
433  MECAB_DLL_EXTERN void mecab_set_all_morphs(mecab_t *mecab, int all_morphs);
434 
438  MECAB_DLL_EXTERN int mecab_parse_lattice(mecab_t *mecab, mecab_lattice_t *lattice);
439 
443  MECAB_DLL_EXTERN const char* mecab_sparse_tostr(mecab_t *mecab, const char *str);
444 
448  MECAB_DLL_EXTERN const char* mecab_sparse_tostr2(mecab_t *mecab, const char *str, size_t len);
449 
453  MECAB_DLL_EXTERN char* mecab_sparse_tostr3(mecab_t *mecab, const char *str, size_t len,
454  char *ostr, size_t olen);
455 
459  MECAB_DLL_EXTERN const mecab_node_t* mecab_sparse_tonode(mecab_t *mecab, const char*);
460 
464  MECAB_DLL_EXTERN const mecab_node_t* mecab_sparse_tonode2(mecab_t *mecab, const char*, size_t);
465 
469  MECAB_DLL_EXTERN const char* mecab_nbest_sparse_tostr(mecab_t *mecab, size_t N, const char *str);
470 
474  MECAB_DLL_EXTERN const char* mecab_nbest_sparse_tostr2(mecab_t *mecab, size_t N,
475  const char *str, size_t len);
476 
480  MECAB_DLL_EXTERN char* mecab_nbest_sparse_tostr3(mecab_t *mecab, size_t N,
481  const char *str, size_t len,
482  char *ostr, size_t olen);
483 
487  MECAB_DLL_EXTERN int mecab_nbest_init(mecab_t *mecab, const char *str);
488 
492  MECAB_DLL_EXTERN int mecab_nbest_init2(mecab_t *mecab, const char *str, size_t len);
493 
497  MECAB_DLL_EXTERN const char* mecab_nbest_next_tostr(mecab_t *mecab);
498 
502  MECAB_DLL_EXTERN char* mecab_nbest_next_tostr2(mecab_t *mecab, char *ostr, size_t olen);
503 
507  MECAB_DLL_EXTERN const mecab_node_t* mecab_nbest_next_tonode(mecab_t *mecab);
508 
512  MECAB_DLL_EXTERN const char* mecab_format_node(mecab_t *mecab, const mecab_node_t *node);
513 
517  MECAB_DLL_EXTERN const mecab_dictionary_info_t* mecab_dictionary_info(mecab_t *mecab);
518 
519  /* lattice interface */
523  MECAB_DLL_EXTERN mecab_lattice_t *mecab_lattice_new();
524 
528  MECAB_DLL_EXTERN void mecab_lattice_destroy(mecab_lattice_t *lattice);
529 
533  MECAB_DLL_EXTERN void mecab_lattice_clear(mecab_lattice_t *lattice);
534 
539  MECAB_DLL_EXTERN int mecab_lattice_is_available(mecab_lattice_t *lattice);
540 
545 
550 
560 
564  MECAB_DLL_EXTERN mecab_node_t *mecab_lattice_get_begin_nodes(mecab_lattice_t *lattice, size_t pos);
565 
569  MECAB_DLL_EXTERN mecab_node_t *mecab_lattice_get_end_nodes(mecab_lattice_t *lattice, size_t pos);
570 
574  MECAB_DLL_EXTERN const char *mecab_lattice_get_sentence(mecab_lattice_t *lattice);
575 
579  MECAB_DLL_EXTERN void mecab_lattice_set_sentence(mecab_lattice_t *lattice, const char *sentence);
580 
585  MECAB_DLL_EXTERN void mecab_lattice_set_sentence2(mecab_lattice_t *lattice, const char *sentence, size_t len);
586 
590  MECAB_DLL_EXTERN size_t mecab_lattice_get_size(mecab_lattice_t *lattice);
591 
595  MECAB_DLL_EXTERN double mecab_lattice_get_z(mecab_lattice_t *lattice);
596 
600  MECAB_DLL_EXTERN void mecab_lattice_set_z(mecab_lattice_t *lattice, double Z);
601 
605  MECAB_DLL_EXTERN double mecab_lattice_get_theta(mecab_lattice_t *lattice);
606 
611  MECAB_DLL_EXTERN void mecab_lattice_set_theta(mecab_lattice_t *lattice, double theta);
612 
616  MECAB_DLL_EXTERN int mecab_lattice_next(mecab_lattice_t *lattice);
617 
621  MECAB_DLL_EXTERN int mecab_lattice_get_request_type(mecab_lattice_t *lattice);
622 
626  MECAB_DLL_EXTERN int mecab_lattice_has_request_type(mecab_lattice_t *lattice, int request_type);
627 
631  MECAB_DLL_EXTERN void mecab_lattice_set_request_type(mecab_lattice_t *lattice, int request_type);
632 
637  MECAB_DLL_EXTERN void mecab_lattice_add_request_type(mecab_lattice_t *lattice, int request_type);
638 
642  MECAB_DLL_EXTERN void mecab_lattice_remove_request_type(mecab_lattice_t *lattice, int request_type);
643 
648 
652  MECAB_DLL_EXTERN const char *mecab_lattice_tostr(mecab_lattice_t *lattice);
653 
657  MECAB_DLL_EXTERN const char *mecab_lattice_tostr2(mecab_lattice_t *lattice, char *buf, size_t size);
658 
662  MECAB_DLL_EXTERN const char *mecab_lattice_nbest_tostr(mecab_lattice_t *lattice, size_t N);
663 
668  MECAB_DLL_EXTERN const char *mecab_lattice_nbest_tostr2(mecab_lattice_t *lattice, size_t N, char *buf, size_t size);
669 
673  MECAB_DLL_EXTERN int mecab_lattice_has_constraint(mecab_lattice_t *lattice);
674 
678  MECAB_DLL_EXTERN int mecab_lattice_get_boundary_constraint(mecab_lattice_t *lattice, size_t pos);
679 
680 
684  MECAB_DLL_EXTERN const char *mecab_lattice_get_feature_constraint(mecab_lattice_t *lattice, size_t pos);
685 
689  MECAB_DLL_EXTERN void mecab_lattice_set_boundary_constraint(mecab_lattice_t *lattice, size_t pos, int boundary_type);
690 
694  MECAB_DLL_EXTERN void mecab_lattice_set_feature_constraint(mecab_lattice_t *lattice, size_t begin_pos, size_t end_pos, const char *feature);
695 
699  MECAB_DLL_EXTERN void mecab_lattice_set_result(mecab_lattice_t *lattice, const char *result);
700 
704  MECAB_DLL_EXTERN const char *mecab_lattice_strerror(mecab_lattice_t *lattice);
705 
706 
707  /* model interface */
711  MECAB_DLL_EXTERN mecab_model_t *mecab_model_new(int argc, char **argv);
712 
716  MECAB_DLL_EXTERN mecab_model_t *mecab_model_new2(const char *arg);
717 
722  MECAB_DLL_EXTERN void mecab_model_destroy(mecab_model_t *model);
723 
727  MECAB_DLL_EXTERN mecab_t *mecab_model_new_tagger(mecab_model_t *model);
728 
733 
737  MECAB_DLL_EXTERN int mecab_model_swap(mecab_model_t *model, mecab_model_t *new_model);
738 
743 
747  MECAB_DLL_EXTERN int mecab_model_transition_cost(mecab_model_t *model,
748  unsigned short rcAttr,
749  unsigned short lcAttr);
750 
755  const char *begin,
756  const char *end,
757  mecab_lattice_t *lattice);
758 
759  /* static functions */
760  MECAB_DLL_EXTERN int mecab_do(int argc, char **argv);
761  MECAB_DLL_EXTERN int mecab_dict_index(int argc, char **argv);
762  MECAB_DLL_EXTERN int mecab_dict_gen(int argc, char **argv);
763  MECAB_DLL_EXTERN int mecab_cost_train(int argc, char **argv);
764  MECAB_DLL_EXTERN int mecab_system_eval(int argc, char **argv);
765  MECAB_DLL_EXTERN int mecab_test_gen(int argc, char **argv);
766 #endif
767 
768 #ifdef __cplusplus
769 }
770 #endif
771 
772 /* C++ interface */
773 #ifdef __cplusplus
774 
775 namespace MeCab {
777 typedef struct mecab_path_t Path;
778 typedef struct mecab_node_t Node;
779 
780 template <typename N, typename P> class Allocator;
781 class Tagger;
782 
787 public:
791  virtual void clear() = 0;
792 
797  virtual bool is_available() const = 0;
798 
804  virtual Node *bos_node() const = 0;
805 
810  virtual Node *eos_node() const = 0;
811 
812 #ifndef SWIG
816  virtual Node **begin_nodes() const = 0;
817 
821  virtual Node **end_nodes() const = 0;
822 #endif
823 
830  virtual Node *end_nodes(size_t pos) const = 0;
831 
838  virtual Node *begin_nodes(size_t pos) const = 0;
839 
845  virtual const char *sentence() const = 0;
846 
851  virtual void set_sentence(const char *sentence) = 0;
852 
853 #ifndef SWIG
859  virtual void set_sentence(const char *sentence, size_t len) = 0;
860 #endif
861 
866  virtual size_t size() const = 0;
867 
872  virtual void set_Z(double Z) = 0;
873 
878  virtual double Z() const = 0;
879 
884  virtual void set_theta(float theta) = 0;
885 
890  virtual float theta() const = 0;
891 
898  virtual bool next() = 0;
899 
904  virtual int request_type() const = 0;
905 
910  virtual bool has_request_type(int request_type) const = 0;
911 
916  virtual void set_request_type(int request_type) = 0;
917 
922  virtual void add_request_type(int request_type) = 0;
923 
928  virtual void remove_request_type(int request_type) = 0;
929 
930 #ifndef SWIG
934  virtual Allocator<Node, Path> *allocator() const = 0;
935 #endif
936 
941  virtual Node *newNode() = 0;
942 
949  virtual const char *toString() = 0;
950 
958  virtual const char *toString(const Node *node) = 0;
959 
967  virtual const char *enumNBestAsString(size_t N) = 0;
968 
969 #ifndef SWIG
977  virtual const char *toString(char *buf, size_t size) = 0;
978 
987  virtual const char *toString(const Node *node,
988  char *buf, size_t size) = 0;
989 
998  virtual const char *enumNBestAsString(size_t N, char *buf, size_t size) = 0;
999 #endif
1000 
1004  virtual bool has_constraint() const = 0;
1005 
1011  virtual int boundary_constraint(size_t pos) const = 0;
1012 
1018  virtual const char *feature_constraint(size_t pos) const = 0;
1019 
1025  virtual void set_boundary_constraint(size_t pos,
1026  int boundary_constraint_type) = 0;
1027 
1035  size_t begin_pos, size_t end_pos,
1036  const char *feature) = 0;
1037 
1042  virtual void set_result(const char *result) = 0;
1043 
1048  virtual const char *what() const = 0;
1049 
1054  virtual void set_what(const char *str) = 0;
1055 
1056 #ifndef SWIG
1061  static Lattice *create();
1062 #endif
1063 
1064  virtual ~Lattice() {}
1065 };
1066 
1071 public:
1076  virtual const DictionaryInfo *dictionary_info() const = 0;
1077 
1082  virtual int transition_cost(unsigned short rcAttr,
1083  unsigned short lcAttr) const = 0;
1084 
1090  virtual Node *lookup(const char *begin, const char *end,
1091  Lattice *lattice) const = 0;
1092 
1099  virtual Tagger *createTagger() const = 0;
1100 
1105  virtual Lattice *createLattice() const = 0;
1106 
1118  virtual bool swap(Model *model) = 0;
1119 
1124  static const char *version();
1125 
1126  virtual ~Model() {}
1127 
1128 #ifndef SWIG
1137  static Model* create(int argc, char **argv);
1138 
1147  static Model* create(const char *arg);
1148 #endif
1149 };
1150 
1155 public:
1168  static bool parse(const Model &model, Lattice *lattice);
1169 
1179  virtual bool parse(Lattice *lattice) const = 0;
1180 
1189  virtual const char* parse(const char *str) = 0;
1190 
1200  virtual const Node* parseToNode(const char *str) = 0;
1201 
1212  virtual const char* parseNBest(size_t N, const char *str) = 0;
1213 
1223  virtual bool parseNBestInit(const char *str) = 0;
1224 
1232  virtual const Node* nextNode() = 0;
1233 
1241  virtual const char* next() = 0;
1242 
1253  virtual const char* formatNode(const Node *node) = 0;
1254 
1255 #ifndef SWIG
1266  virtual const char* parse(const char *str, size_t len, char *ostr, size_t olen) = 0;
1267 
1274  virtual const char* parse(const char *str, size_t len) = 0;
1275 
1282  virtual const Node* parseToNode(const char *str, size_t len) = 0;
1283 
1291  virtual const char* parseNBest(size_t N, const char *str, size_t len) = 0;
1292 
1300  virtual bool parseNBestInit(const char *str, size_t len) = 0;
1301 
1309  virtual const char* next(char *ostr , size_t olen) = 0;
1310 
1321  virtual const char* parseNBest(size_t N, const char *str,
1322  size_t len, char *ostr, size_t olen) = 0;
1323 
1332  virtual const char* formatNode(const Node *node, char *ostr, size_t olen) = 0;
1333 #endif
1334 
1340  virtual void set_request_type(int request_type) = 0;
1341 
1347  virtual int request_type() const = 0;
1348 
1354  virtual bool partial() const = 0;
1355 
1361  virtual void set_partial(bool partial) = 0;
1362 
1368  virtual int lattice_level() const = 0;
1369 
1375  virtual void set_lattice_level(int level) = 0;
1376 
1382  virtual bool all_morphs() const = 0;
1383 
1389  virtual void set_all_morphs(bool all_morphs) = 0;
1390 
1395  virtual void set_theta(float theta) = 0;
1396 
1401  virtual float theta() const = 0;
1402 
1407  virtual const DictionaryInfo* dictionary_info() const = 0;
1408 
1413  virtual const char* what() const = 0;
1414 
1415  virtual ~Tagger() {}
1416 
1417 #ifndef SWIG
1426  static Tagger *create(int argc, char **argv);
1427 
1436  static Tagger *create(const char *arg);
1437 #endif
1438 
1443  static const char *version();
1444 };
1445 
1446 #ifndef SWIG
1450 MECAB_DLL_EXTERN Lattice *createLattice();
1451 
1455 MECAB_DLL_EXTERN Model *createModel(int argc, char **argv);
1456 
1460 MECAB_DLL_EXTERN Model *createModel(const char *arg);
1461 
1465 MECAB_DLL_EXTERN Tagger *createTagger(int argc, char **argv);
1466 
1470 MECAB_DLL_EXTERN Tagger *createTagger(const char *arg);
1471 
1478 MECAB_DLL_EXTERN void deleteLattice(Lattice *lattice);
1479 
1480 
1487 MECAB_DLL_EXTERN void deleteModel(Model *model);
1488 
1495 MECAB_DLL_EXTERN void deleteTagger(Tagger *tagger);
1496 
1501 MECAB_DLL_EXTERN const char* getLastError();
1502 
1508 MECAB_DLL_EXTERN const char* getTaggerError();
1509 #endif
1510 }
1511 #endif
1512 #endif /* MECAB_MECAB_H_ */
Definition: mecab.h:780
Lattice class.
Definition: mecab.h:786
static Lattice * create()
Create new Lattice object.
virtual Node * end_nodes(size_t pos) const =0
Return node linked list ending at |pos|.
virtual Node ** end_nodes() const =0
This method is used internally.
virtual Node * newNode()=0
Return new node.
virtual Node * bos_node() const =0
Return bos (begin of sentence) node.
virtual const char * enumNBestAsString(size_t N)=0
Return string representation of the N-best results.
virtual void set_what(const char *str)=0
Set error string.
virtual void set_Z(double Z)=0
Set normalization factor of CRF.
virtual void set_feature_constraint(size_t begin_pos, size_t end_pos, const char *feature)=0
Set parsing constraint for partial parsing mode.
virtual void set_sentence(const char *sentence, size_t len)=0
Set sentence.
virtual int request_type() const =0
Return the current request type.
virtual const char * feature_constraint(size_t pos) const =0
Returns the token constraint at the position.
virtual float theta() const =0
Return temparature parameter theta.
virtual ~Lattice()
Definition: mecab.h:1064
virtual const char * toString(const Node *node)=0
Return string representation of the node.
virtual void set_result(const char *result)=0
Set golden parsing results for unittesting.
virtual const char * toString(char *buf, size_t size)=0
Return string representation of the lattice.
virtual void add_request_type(int request_type)=0
Add request type.
virtual double Z() const =0
return normalization factor of CRF.
virtual void set_theta(float theta)=0
Set temparature parameter theta.
virtual bool has_constraint() const =0
Returns true if any parsing constraint is set.
virtual int boundary_constraint(size_t pos) const =0
Returns the boundary constraint at the position.
virtual bool next()=0
Obtain next-best result.
virtual Node * eos_node() const =0
Return eos (end of sentence) node.
virtual bool is_available() const =0
Return true if result object is available.
virtual Allocator< Node, Path > * allocator() const =0
This method is used internally.
virtual const char * toString()=0
Return string representation of the lattice.
virtual void clear()=0
Clear all internal lattice data.
virtual const char * toString(const Node *node, char *buf, size_t size)=0
Return string representation of the node.
virtual const char * enumNBestAsString(size_t N, char *buf, size_t size)=0
Return string representation of the N-best result.
virtual const char * what() const =0
Return error string.
virtual const char * sentence() const =0
Return sentence.
virtual Node ** begin_nodes() const =0
This method is used internally.
virtual void set_request_type(int request_type)=0
Set request type.
virtual void set_boundary_constraint(size_t pos, int boundary_constraint_type)=0
Set parsing constraint for partial parsing mode.
virtual Node * begin_nodes(size_t pos) const =0
Return node linked list starting at |pos|.
virtual bool has_request_type(int request_type) const =0
Return true if the object has a specified request type.
virtual void set_sentence(const char *sentence)=0
Set sentence.
virtual size_t size() const =0
Return sentence size.
virtual void remove_request_type(int request_type)=0
Remove request type.
Model class.
Definition: mecab.h:1070
virtual bool swap(Model *model)=0
Swap the instance with |model|.
virtual const DictionaryInfo * dictionary_info() const =0
Return DictionaryInfo linked list.
static Model * create(int argc, char **argv)
Factory method to create a new Model with a specified main's argc/argv-style parameters.
virtual Tagger * createTagger() const =0
Create a new Tagger object.
virtual Lattice * createLattice() const =0
Create a new Lattice object.
virtual ~Model()
Definition: mecab.h:1126
static Model * create(const char *arg)
Factory method to create a new Model with a string parameter representation, i.e.,...
virtual Node * lookup(const char *begin, const char *end, Lattice *lattice) const =0
perform common prefix search from the range [begin, end).
virtual int transition_cost(unsigned short rcAttr, unsigned short lcAttr) const =0
Return transition cost from rcAttr to lcAttr.
static const char * version()
Return a version string.
Tagger class.
Definition: mecab.h:1154
static bool parse(const Model &model, Lattice *lattice)
Handy static method.
virtual const char * parseNBest(size_t N, const char *str, size_t len, char *ostr, size_t olen)=0
The same as parseNBest(), but input length and output buffer can be passed.
virtual bool partial() const =0
Return true if partial parsing mode is on.
virtual void set_lattice_level(int level)=0
Set lattice level.
virtual const char * formatNode(const Node *node)=0
Return formatted node object.
virtual const char * parseNBest(size_t N, const char *str, size_t len)=0
The same as parseNBest(), but input length can be passed.
virtual void set_partial(bool partial)=0
set partial parsing mode.
static const char * version()
Return a version string.
virtual const char * next(char *ostr, size_t olen)=0
The same as next(), but output buffer can be passed.
virtual const char * parse(const char *str)=0
Parse given sentence and return parsed result as string.
virtual const char * parse(const char *str, size_t len, char *ostr, size_t olen)=0
The same as parse() method, but input length and output buffer are passed.
virtual ~Tagger()
Definition: mecab.h:1415
static Tagger * create(const char *arg)
Factory method to create a new Tagger with a string parameter representation, i.e....
virtual const Node * parseToNode(const char *str, size_t len)=0
The same as parseToNode(), but input lenth can be passed.
virtual bool parse(Lattice *lattice) const =0
Parse lattice object.
virtual int lattice_level() const =0
Return lattice level.
virtual const char * formatNode(const Node *node, char *ostr, size_t olen)=0
The same as formatNode(), but output buffer can be passed.
virtual void set_request_type(int request_type)=0
Set request type.
virtual bool parseNBestInit(const char *str)=0
Initialize N-best enumeration with a sentence.
virtual float theta() const =0
Return temparature parameter theta.
virtual void set_all_morphs(bool all_morphs)=0
set all-morphs output mode.
static Tagger * create(int argc, char **argv)
Factory method to create a new Tagger with a specified main's argc/argv-style parameters.
virtual const char * parse(const char *str, size_t len)=0
The same as parse() method, but input length can be passed.
virtual const char * what() const =0
Return error string.
virtual int request_type() const =0
Return the current request type.
virtual const char * next()=0
Return next-best parsed result.
virtual void set_theta(float theta)=0
Set temparature parameter theta.
virtual bool parseNBestInit(const char *str, size_t len)=0
The same as parseNBestInit(), but input length can be passed.
virtual const Node * parseToNode(const char *str)=0
Parse given sentence and return Node object.
virtual bool all_morphs() const =0
Return true if all morphs output mode is on.
virtual const DictionaryInfo * dictionary_info() const =0
Return DictionaryInfo linked list.
virtual const Node * nextNode()=0
Return next-best parsed result.
virtual const char * parseNBest(size_t N, const char *str)=0
Parse given sentence and obtain N-best results as a string format.
MECAB_DLL_EXTERN char * mecab_nbest_next_tostr2(mecab_t *mecab, char *ostr, size_t olen)
C wrapper of MeCab::Tagger::next(char *ostr, size_t olen)
@ MECAB_UNK_NODE
Unknown node not defined in the dictionary.
Definition: mecab.h:229
@ MECAB_EOS_NODE
Virtual node representing a end of the sentence.
Definition: mecab.h:237
@ MECAB_EON_NODE
Virtual node representing a end of the N-best enumeration.
Definition: mecab.h:242
@ MECAB_NOR_NODE
Normal node defined in the dictionary.
Definition: mecab.h:225
@ MECAB_BOS_NODE
Virtual node representing a beginning of the sentence.
Definition: mecab.h:233
MECAB_DLL_EXTERN const char * mecab_nbest_sparse_tostr(mecab_t *mecab, size_t N, const char *str)
C wrapper of MeCab::Tagger::parseNBest(size_t N, const char *str)
MECAB_DLL_EXTERN int mecab_model_transition_cost(mecab_model_t *model, unsigned short rcAttr, unsigned short lcAttr)
C wrapper of MeCab::Model::transition_cost()
MECAB_DLL_EXTERN int mecab_lattice_has_constraint(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::has_constraint()
MECAB_DLL_EXTERN mecab_node_t * mecab_lattice_new_node(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::newNode();.
MECAB_DLL_EXTERN void mecab_lattice_set_boundary_constraint(mecab_lattice_t *lattice, size_t pos, int boundary_type)
C wrapper of MeCab::Lattice::boundary_constraint(pos, type)
MECAB_DLL_EXTERN const char * mecab_lattice_nbest_tostr2(mecab_lattice_t *lattice, size_t N, char *buf, size_t size)
C wrapper of MeCab::Lattice::enumNBestAsString(N, buf, size)
MECAB_DLL_EXTERN double mecab_lattice_get_theta(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::theta()
MECAB_DLL_EXTERN char * mecab_nbest_sparse_tostr3(mecab_t *mecab, size_t N, const char *str, size_t len, char *ostr, size_t olen)
C wrapper of MeCab::Tagger::parseNBest(size_t N, const char *str, char *ostr, size_t olen)
MECAB_DLL_EXTERN int mecab_get_all_morphs(mecab_t *mecab)
C wrapper of MeCab::Tagger::all_morphs()
MECAB_DLL_EXTERN const char * mecab_version()
C wrapper of MeCab::Tagger::version()
MECAB_DLL_EXTERN void mecab_lattice_set_theta(mecab_lattice_t *lattice, double theta)
C wrapper of MeCab::Lattice::set_theta()
MECAB_DLL_EXTERN const char * mecab_sparse_tostr(mecab_t *mecab, const char *str)
C wrapper of MeCab::Tagger::parse(const char *str)
MECAB_DLL_EXTERN int mecab_parse_lattice(mecab_t *mecab, mecab_lattice_t *lattice)
C wrapper of MeCab::Tagger::parse(MeCab::Lattice *lattice)
MECAB_DLL_EXTERN void mecab_lattice_add_request_type(mecab_lattice_t *lattice, int request_type)
C wrapper of MeCab::Lattice::add_request_type()
MECAB_DLL_EXTERN float mecab_get_theta(mecab_t *mecab)
C wrapper of MeCab::Tagger::theta()
MECAB_DLL_EXTERN const char * mecab_lattice_tostr(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::toString()
MECAB_DLL_EXTERN mecab_node_t * mecab_model_lookup(mecab_model_t *model, const char *begin, const char *end, mecab_lattice_t *lattice)
C wrapper of MeCab::Model::lookup()
MECAB_DLL_EXTERN void mecab_lattice_set_sentence2(mecab_lattice_t *lattice, const char *sentence, size_t len)
C wrapper of MeCab::Lattice::set_sentence(sentence, len)
MECAB_DLL_EXTERN int mecab_lattice_get_request_type(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::request_type()
MECAB_DLL_EXTERN mecab_node_t * mecab_lattice_get_begin_nodes(mecab_lattice_t *lattice, size_t pos)
C wrapper of MeCab::Lattice::begin_nodes(pos)
MECAB_DLL_EXTERN mecab_node_t * mecab_lattice_get_bos_node(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::bos_node()
MECAB_DLL_EXTERN const mecab_dictionary_info_t * mecab_model_dictionary_info(mecab_model_t *model)
C wapper of MeCab::Model::dictionary_info()
MECAB_DLL_EXTERN int mecab_dict_index(int argc, char **argv)
MECAB_DLL_EXTERN mecab_lattice_t * mecab_model_new_lattice(mecab_model_t *model)
C wapper of MeCab::Model::createLattice()
MECAB_DLL_EXTERN void mecab_set_theta(mecab_t *mecab, float theta)
C wrapper of MeCab::Tagger::set_theta()
MECAB_DLL_EXTERN mecab_t * mecab_model_new_tagger(mecab_model_t *model)
C wapper of MeCab::Model::createTagger()
MECAB_DLL_EXTERN mecab_model_t * mecab_model_new(int argc, char **argv)
C wapper of MeCab::Model::create(argc, argv)
MECAB_DLL_EXTERN int mecab_model_swap(mecab_model_t *model, mecab_model_t *new_model)
C wrapper of MeCab::Model::swap()
MECAB_DLL_EXTERN const char * mecab_lattice_nbest_tostr(mecab_lattice_t *lattice, size_t N)
C wrapper of MeCab::Lattice::enumNBestAsString(N)
MECAB_DLL_EXTERN int mecab_nbest_init2(mecab_t *mecab, const char *str, size_t len)
C wrapper of MeCab::Tagger::parseNBestInit(const char *str, size_t len)
struct mecab_lattice_t mecab_lattice_t
Definition: mecab.h:361
MECAB_DLL_EXTERN const mecab_dictionary_info_t * mecab_dictionary_info(mecab_t *mecab)
C wrapper of MeCab::Tagger::dictionary_info()
MECAB_DLL_EXTERN const mecab_node_t * mecab_sparse_tonode(mecab_t *mecab, const char *)
C wrapper of MeCab::Tagger::parseToNode(const char *str)
MECAB_DLL_EXTERN int mecab_do(int argc, char **argv)
MECAB_DLL_EXTERN const mecab_node_t * mecab_sparse_tonode2(mecab_t *mecab, const char *, size_t)
C wrapper of MeCab::Tagger::parseToNode(const char *str, size_t len)
MECAB_DLL_EXTERN const char * mecab_lattice_get_sentence(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::sentence()
MECAB_DLL_EXTERN const char * mecab_format_node(mecab_t *mecab, const mecab_node_t *node)
C wrapper of MeCab::Tagger::formatNode(const Node *node)
MECAB_DLL_EXTERN const mecab_node_t * mecab_nbest_next_tonode(mecab_t *mecab)
C wrapper of MeCab::Tagger::nextNode()
MECAB_DLL_EXTERN int mecab_lattice_has_request_type(mecab_lattice_t *lattice, int request_type)
C wrapper of MeCab::Lattice::has_request_type()
MECAB_DLL_EXTERN void mecab_lattice_destroy(mecab_lattice_t *lattice)
C wrapper of MeCab::deleteLattice(lattice)
MECAB_DLL_EXTERN mecab_node_t ** mecab_lattice_get_all_end_nodes(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::end_nodes()
MECAB_DLL_EXTERN int mecab_dict_gen(int argc, char **argv)
MECAB_DLL_EXTERN void mecab_lattice_clear(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::clear()
MECAB_DLL_EXTERN mecab_lattice_t * mecab_lattice_new()
C wrapper of MeCab::createLattice()
MECAB_DLL_EXTERN int mecab_get_lattice_level(mecab_t *mecab)
C wrapper of MeCab::Tagger::lattice_level()
MECAB_DLL_EXTERN size_t mecab_lattice_get_size(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::size()
MECAB_DLL_EXTERN void mecab_set_all_morphs(mecab_t *mecab, int all_morphs)
C wrapper of MeCab::Tagger::set_all_moprhs()
MECAB_DLL_EXTERN mecab_t * mecab_new(int argc, char **argv)
C wrapper of MeCab::Tagger::create(argc, argv)
struct mecab_model_t mecab_model_t
Definition: mecab.h:360
@ MECAB_ALLOCATE_SENTENCE
When this flag is set, tagger internally copies the body of passed sentence into internal buffer.
Definition: mecab.h:304
@ MECAB_ALL_MORPHS
When this flag is set, the result linked-list (Node::next/prev) traverses all nodes in the lattice.
Definition: mecab.h:298
@ MECAB_NBEST
Set this flag if you want to obtain N best results.
Definition: mecab.h:276
@ MECAB_ALTERNATIVE
Set this flag if you want to obtain alternative results.
Definition: mecab.h:293
@ MECAB_MARGINAL_PROB
Set this flag if you want to obtain marginal probabilities.
Definition: mecab.h:288
@ MECAB_ONE_BEST
One best result is obtained (default mode)
Definition: mecab.h:272
@ MECAB_PARTIAL
Set this flag if you want to enable a partial parsing mode.
Definition: mecab.h:282
MECAB_DLL_EXTERN void mecab_set_partial(mecab_t *mecab, int partial)
C wrapper of MeCab::Tagger::partial()
MECAB_DLL_EXTERN const char * mecab_nbest_next_tostr(mecab_t *mecab)
C wrapper of MeCab::Tagger::next()
MECAB_DLL_EXTERN const char * mecab_lattice_get_feature_constraint(mecab_lattice_t *lattice, size_t pos)
C wrapper of MeCab::Lattice::feature_constraint(pos)
MECAB_DLL_EXTERN void mecab_destroy(mecab_t *mecab)
C wrapper of MeCab::deleteTagger(tagger)
MECAB_DLL_EXTERN int mecab_nbest_init(mecab_t *mecab, const char *str)
C wrapper of MeCab::Tagger::parseNBestInit(const char *str)
MECAB_DLL_EXTERN mecab_model_t * mecab_model_new2(const char *arg)
C wapper of MeCab::Model::create(arg)
MECAB_DLL_EXTERN int mecab_test_gen(int argc, char **argv)
MECAB_DLL_EXTERN void mecab_lattice_set_result(mecab_lattice_t *lattice, const char *result)
C wrapper of MeCab::Lattice::set_result(result);.
MECAB_DLL_EXTERN const char * mecab_strerror(mecab_t *mecab)
C wrapper of MeCab::getLastError()
@ MECAB_INSIDE_TOKEN
The position is not a token boundary.
Definition: mecab.h:324
@ MECAB_TOKEN_BOUNDARY
The position is a strong token boundary.
Definition: mecab.h:319
@ MECAB_ANY_BOUNDARY
The token boundary is not specified.
Definition: mecab.h:314
MECAB_DLL_EXTERN void mecab_lattice_set_request_type(mecab_lattice_t *lattice, int request_type)
C wrapper of MeCab::Lattice::set_request_type()
MECAB_DLL_EXTERN void mecab_set_lattice_level(mecab_t *mecab, int level)
C wrapper of MeCab::Tagger::set_lattice_level()
MECAB_DLL_EXTERN mecab_node_t * mecab_lattice_get_eos_node(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::eos_node()
MECAB_DLL_EXTERN char * mecab_sparse_tostr3(mecab_t *mecab, const char *str, size_t len, char *ostr, size_t olen)
C wrapper of MeCab::Tagger::parse(const char *str, char *ostr, size_t olen)
MECAB_DLL_EXTERN const char * mecab_lattice_tostr2(mecab_lattice_t *lattice, char *buf, size_t size)
C wrapper of MeCab::Lattice::toString(buf, size)
MECAB_DLL_EXTERN const char * mecab_nbest_sparse_tostr2(mecab_t *mecab, size_t N, const char *str, size_t len)
C wrapper of MeCab::Tagger::parseNBest(size_t N, const char *str, size_t len)
#define MECAB_DLL_CLASS_EXTERN
Definition: mecab.h:356
struct mecab_t mecab_t
Definition: mecab.h:359
MECAB_DLL_EXTERN int mecab_system_eval(int argc, char **argv)
MECAB_DLL_EXTERN const char * mecab_sparse_tostr2(mecab_t *mecab, const char *str, size_t len)
C wrapper of MeCab::Tagger::parse(const char *str, size_t len)
MECAB_DLL_EXTERN void mecab_lattice_set_z(mecab_lattice_t *lattice, double Z)
C wrapper of MeCab::Lattice::set_Z()
MECAB_DLL_EXTERN void mecab_lattice_set_feature_constraint(mecab_lattice_t *lattice, size_t begin_pos, size_t end_pos, const char *feature)
C wrapper of MeCab::Lattice::set_feature_constraint(begin_pos, end_pos, feature)
MECAB_DLL_EXTERN int mecab_lattice_next(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::next()
@ MECAB_SYS_DIC
This is a system dictionary.
Definition: mecab.h:252
@ MECAB_UNK_DIC
This is a unknown word dictionary.
Definition: mecab.h:262
@ MECAB_USR_DIC
This is a user dictionary.
Definition: mecab.h:257
MECAB_DLL_EXTERN void mecab_lattice_set_sentence(mecab_lattice_t *lattice, const char *sentence)
C wrapper of MeCab::Lattice::set_sentence(sentence)
MECAB_DLL_EXTERN const char * mecab_lattice_strerror(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::what()
MECAB_DLL_EXTERN void mecab_model_destroy(mecab_model_t *model)
C wapper of MeCab::deleteModel(model)
MECAB_DLL_EXTERN mecab_node_t ** mecab_lattice_get_all_begin_nodes(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::begin_nodes()
MECAB_DLL_EXTERN double mecab_lattice_get_z(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::Z()
MECAB_DLL_EXTERN int mecab_get_partial(mecab_t *mecab)
C wrapper of MeCab::Tagger:set_partial()
MECAB_DLL_EXTERN int mecab_lattice_is_available(mecab_lattice_t *lattice)
C wrapper of MeCab::Lattice::is_available()
MECAB_DLL_EXTERN int mecab_cost_train(int argc, char **argv)
MECAB_DLL_EXTERN int mecab_lattice_get_boundary_constraint(mecab_lattice_t *lattice, size_t pos)
C wrapper of MeCab::Lattice::boundary_constraint(pos)
MECAB_DLL_EXTERN mecab_node_t * mecab_lattice_get_end_nodes(mecab_lattice_t *lattice, size_t pos)
C wrapper of MeCab::Lattice::end_nodes(pos)
MECAB_DLL_EXTERN mecab_t * mecab_new2(const char *arg)
C wrapper of MeCab::Tagger::create(arg)
MECAB_DLL_EXTERN void mecab_lattice_remove_request_type(mecab_lattice_t *lattice, int request_type)
C wrapper of MeCab::Lattice::remove_request_type()
Definition: mecab.h:775
MECAB_DLL_EXTERN void deleteLattice(Lattice *lattice)
delete Lattice object.
MECAB_DLL_EXTERN Lattice * createLattice()
Alias of Lattice::create()
MECAB_DLL_EXTERN void deleteTagger(Tagger *tagger)
delete Tagger object.
MECAB_DLL_EXTERN Model * createModel(int argc, char **argv)
Alias of Mode::create(argc, argv)
MECAB_DLL_EXTERN Tagger * createTagger(int argc, char **argv)
Alias of Tagger::create(argc, argv)
MECAB_DLL_EXTERN void deleteModel(Model *model)
delete Model object.
MECAB_DLL_EXTERN const char * getTaggerError()
An alias of getLastError.
MECAB_DLL_EXTERN const char * getLastError()
Return last error string.
DictionaryInfo structure.
Definition: mecab.h:15
int type
dictionary type this value should be MECAB_USR_DIC, MECAB_SYS_DIC, or MECAB_UNK_DIC.
Definition: mecab.h:36
struct mecab_dictionary_info_t * next
pointer to the next dictionary info.
Definition: mecab.h:56
unsigned int rsize
right attributes size
Definition: mecab.h:46
const char * charset
character set of the dictionary.
Definition: mecab.h:25
unsigned int lsize
left attributes size
Definition: mecab.h:41
unsigned short version
version of this dictionary
Definition: mecab.h:51
unsigned int size
How many words are registered in this dictionary.
Definition: mecab.h:30
const char * filename
filename of dictionary On Windows, filename is stored in UTF-8 encoding
Definition: mecab.h:20
Node structure.
Definition: mecab.h:98
unsigned short length
length of the surface form.
Definition: mecab.h:151
long cost
best accumulative cost from bos node to this node.
Definition: mecab.h:215
struct mecab_node_t * enext
pointer to the node which ends at the same position.
Definition: mecab.h:112
unsigned short rcAttr
right attribute id
Definition: mecab.h:161
float alpha
forward accumulative log summation.
Definition: mecab.h:193
unsigned char char_type
character type
Definition: mecab.h:176
struct mecab_node_t * bnext
pointer to the node which starts at the same position.
Definition: mecab.h:117
unsigned char isbest
set 1 if this node is best node.
Definition: mecab.h:187
unsigned short rlength
length of the surface form including white space before the morph.
Definition: mecab.h:156
float beta
backward accumulative log summation.
Definition: mecab.h:199
const char * surface
surface string.
Definition: mecab.h:136
unsigned char stat
status of this model.
Definition: mecab.h:182
struct mecab_node_t * prev
pointer to the previous node.
Definition: mecab.h:102
struct mecab_path_t * rpath
pointer to the right path.
Definition: mecab.h:123
unsigned short lcAttr
left attribute id
Definition: mecab.h:166
float prob
marginal probability.
Definition: mecab.h:205
struct mecab_path_t * lpath
pointer to the right path.
Definition: mecab.h:129
struct mecab_node_t * next
pointer to the next node.
Definition: mecab.h:107
short wcost
word cost.
Definition: mecab.h:210
const char * feature
feature string
Definition: mecab.h:141
unsigned int id
unique node id
Definition: mecab.h:146
unsigned short posid
unique part of speech id.
Definition: mecab.h:171
Path structure.
Definition: mecab.h:62
struct mecab_path_t * lnext
pointer to the next left path
Definition: mecab.h:82
struct mecab_path_t * rnext
pointer to the next right path
Definition: mecab.h:71
struct mecab_node_t * lnode
pointer to the left node
Definition: mecab.h:76
int cost
local cost
Definition: mecab.h:87
float prob
marginal probability
Definition: mecab.h:92
struct mecab_node_t * rnode
pointer to the right node
Definition: mecab.h:66