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20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
/*
  MeCab -- Yet Another Part-of-Speech and Morphological Analyzer

  Copyright(C) 2001-2011 Taku Kudo <taku@chasen.org>
  Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
*/
#ifndef MECAB_MECAB_H_
#define MECAB_MECAB_H_

/* C/C++ common data structures  */

/**
 * DictionaryInfo structure
 */
struct mecab_dictionary_info_t {
  /**
   * filename of dictionary
   * On Windows, filename is stored in UTF-8 encoding
   */
  const char                     *filename;

  /**
   * character set of the dictionary. e.g., "SHIFT-JIS", "UTF-8"
   */
  const char                     *charset;

  /**
   * How many words are registered in this dictionary.
   */
  unsigned int                    size;

  /**
   * dictionary type
   * this value should be MECAB_USR_DIC, MECAB_SYS_DIC, or MECAB_UNK_DIC.
   */
  int                             type;

  /**
   * left attributes size
   */
  unsigned int                    lsize;

  /**
   * right attributes size
   */
  unsigned int                    rsize;

  /**
   * version of this dictionary
   */
  unsigned short                  version;

  /**
   * pointer to the next dictionary info.
   */
  struct mecab_dictionary_info_t *next;
};

/**
 * Path structure
 */
struct mecab_path_t {
  /**
   * pointer to the right node
   */
  struct mecab_node_t* rnode;

  /**
   * pointer to the next right path
   */
  struct mecab_path_t* rnext;

  /**
   * pointer to the left node
   */
  struct mecab_node_t* lnode;

  /**
   * pointer to the next left path
   */

  struct mecab_path_t* lnext;

  /**
   * local cost
   */
  int                  cost;

  /**
   * marginal probability
   */
  float                prob;
};

/**
 * Node structure
 */
struct mecab_node_t {
  /**
   * pointer to the previous node.
   */
  struct mecab_node_t  *prev;

  /**
   * pointer to the next node.
   */
  struct mecab_node_t  *next;

  /**
   * pointer to the node which ends at the same position.
   */
  struct mecab_node_t  *enext;

  /**
   * pointer to the node which starts at the same position.
   */
  struct mecab_node_t  *bnext;

  /**
   * pointer to the right path.
   * this value is NULL if MECAB_ONE_BEST mode.
   */
  struct mecab_path_t  *rpath;

  /**
   * pointer to the right path.
   * this value is NULL if MECAB_ONE_BEST mode.
   */
  struct mecab_path_t  *lpath;

  /**
   * surface string.
   * this value is not 0 terminated.
   * You can get the length with length/rlength members.
   */
  const char           *surface;

  /**
   * feature string
   */
  const char           *feature;

  /**
   * unique node id
   */
  unsigned int          id;

  /**
   * length of the surface form.
   */
  unsigned short        length;

  /**
   * length of the surface form including white space before the morph.
   */
  unsigned short        rlength;

  /**
   * right attribute id
   */
  unsigned short        rcAttr;

  /**
   * left attribute id
   */
  unsigned short        lcAttr;

  /**
   * unique part of speech id. This value is defined in "pos.def" file.
   */
  unsigned short        posid;

  /**
   * character type
   */
  unsigned char         char_type;

  /**
   * status of this model.
   * This value is MECAB_NOR_NODE, MECAB_UNK_NODE, MECAB_BOS_NODE, MECAB_EOS_NODE, or MECAB_EON_NODE.
   */
  unsigned char         stat;

  /**
   * set 1 if this node is best node.
   */
  unsigned char         isbest;

  /**
   * forward accumulative log summation.
   * This value is only available when MECAB_MARGINAL_PROB is passed.
   */
  float                 alpha;

  /**
   * backward accumulative log summation.
   * This value is only available when MECAB_MARGINAL_PROB is passed.
   */
  float                 beta;

  /**
   * marginal probability.
   * This value is only available when MECAB_MARGINAL_PROB is passed.
   */
  float                 prob;

  /**
   * word cost.
   */
  short                 wcost;

  /**
   * best accumulative cost from bos node to this node.
   */
  long                  cost;
};

/**
 * Parameters for MeCab::Node::stat
 */
enum {
  /**
   * Normal node defined in the dictionary.
   */
  MECAB_NOR_NODE = 0,
  /**
   * Unknown node not defined in the dictionary.
   */
  MECAB_UNK_NODE = 1,
  /**
   * Virtual node representing a beginning of the sentence.
   */
  MECAB_BOS_NODE = 2,
  /**
   * Virtual node representing a end of the sentence.
   */
  MECAB_EOS_NODE = 3,

  /**
   * Virtual node representing a end of the N-best enumeration.
   */
  MECAB_EON_NODE = 4
};

/**
 * Parameters for MeCab::DictionaryInfo::type
 */
enum {
  /**
   * This is a system dictionary.
   */
  MECAB_SYS_DIC = 0,

  /**
   * This is a user dictionary.
   */
  MECAB_USR_DIC = 1,

  /**
   * This is a unknown word dictionary.
   */
  MECAB_UNK_DIC = 2
};

/**
 * Parameters for MeCab::Lattice::request_type
 */
enum {
  /**
   * One best result is obtained (default mode)
   */
  MECAB_ONE_BEST          = 1,
  /**
   * Set this flag if you want to obtain N best results.
   */
  MECAB_NBEST             = 2,
  /**
   * Set this flag if you want to enable a partial parsing mode.
   * When this flag is set, the input |sentence| needs to be written
   * in partial parsing format.
   */
  MECAB_PARTIAL           = 4,
  /**
   * Set this flag if you want to obtain marginal probabilities.
   * Marginal probability is set in MeCab::Node::prob.
   * The parsing speed will get 3-5 times slower than the default mode.
   */
  MECAB_MARGINAL_PROB     = 8,
  /**
   * Set this flag if you want to obtain alternative results.
   * Not implemented.
   */
  MECAB_ALTERNATIVE       = 16,
  /**
   * When this flag is set, the result linked-list (Node::next/prev)
   * traverses all nodes in the lattice.
   */
  MECAB_ALL_MORPHS        = 32,

  /**
   * When this flag is set, tagger internally copies the body of passed
   * sentence into internal buffer.
   */
  MECAB_ALLOCATE_SENTENCE = 64
};

/**
 * Parameters for MeCab::Lattice::boundary_constraint_type
 */
enum {
  /**
   * The token boundary is not specified.
   */
  MECAB_ANY_BOUNDARY = 0,

  /**
   * The position is a strong token boundary.
   */
  MECAB_TOKEN_BOUNDARY = 1,

  /**
   * The position is not a token boundary.
   */
  MECAB_INSIDE_TOKEN = 2
};

/* C interface  */
#ifdef __cplusplus
#include <cstdio>
#else
#include <stdio.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _WIN32
#include <windows.h>
#  ifdef DLL_EXPORT
#    define MECAB_DLL_EXTERN  __declspec(dllexport)
#    define MECAB_DLL_CLASS_EXTERN  __declspec(dllexport)
#  else
#    define MECAB_DLL_EXTERN  __declspec(dllimport)
#  endif
#endif

#ifndef MECAB_DLL_EXTERN
#  define MECAB_DLL_EXTERN extern
#endif

#ifndef MECAB_DLL_CLASS_EXTERN
#  define MECAB_DLL_CLASS_EXTERN
#endif

  typedef struct mecab_t                 mecab_t;
  typedef struct mecab_model_t           mecab_model_t;
  typedef struct mecab_lattice_t         mecab_lattice_t;
  typedef struct mecab_dictionary_info_t mecab_dictionary_info_t;
  typedef struct mecab_node_t            mecab_node_t;
  typedef struct mecab_path_t            mecab_path_t;

#ifndef SWIG
  /* C interface */

  /* old mecab interface */
  /**
   * C wrapper of MeCab::Tagger::create(argc, argv)
   */
  MECAB_DLL_EXTERN mecab_t*      mecab_new(int argc, char **argv);

  /**
   * C wrapper of MeCab::Tagger::create(arg)
   */
  MECAB_DLL_EXTERN mecab_t*      mecab_new2(const char *arg);

  /**
   * C wrapper of MeCab::Tagger::version()
   */
  MECAB_DLL_EXTERN const char*   mecab_version();

  /**
   * C wrapper of MeCab::getLastError()
   */
  MECAB_DLL_EXTERN const char*   mecab_strerror(mecab_t *mecab);

  /**
   * C wrapper of MeCab::deleteTagger(tagger)
   */
  MECAB_DLL_EXTERN void          mecab_destroy(mecab_t *mecab);

  /**
   * C wrapper of MeCab::Tagger:set_partial()
   */
  MECAB_DLL_EXTERN int           mecab_get_partial(mecab_t *mecab);

  /**
   * C wrapper of MeCab::Tagger::partial()
   */
  MECAB_DLL_EXTERN void          mecab_set_partial(mecab_t *mecab, int partial);

  /**
   * C wrapper of MeCab::Tagger::theta()
   */
  MECAB_DLL_EXTERN float         mecab_get_theta(mecab_t *mecab);

  /**
   * C wrapper of  MeCab::Tagger::set_theta()
   */
  MECAB_DLL_EXTERN void          mecab_set_theta(mecab_t *mecab, float theta);

  /**
   * C wrapper of MeCab::Tagger::lattice_level()
   */
  MECAB_DLL_EXTERN int           mecab_get_lattice_level(mecab_t *mecab);

  /**
   * C wrapper of MeCab::Tagger::set_lattice_level()
   */
  MECAB_DLL_EXTERN void          mecab_set_lattice_level(mecab_t *mecab, int level);

  /**
   * C wrapper of MeCab::Tagger::all_morphs()
   */
  MECAB_DLL_EXTERN int           mecab_get_all_morphs(mecab_t *mecab);

  /**
   * C wrapper of MeCab::Tagger::set_all_moprhs()
   */
  MECAB_DLL_EXTERN void          mecab_set_all_morphs(mecab_t *mecab, int all_morphs);

  /**
   * C wrapper of MeCab::Tagger::parse(MeCab::Lattice *lattice)
   */
  MECAB_DLL_EXTERN int           mecab_parse_lattice(mecab_t *mecab, mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Tagger::parse(const char *str)
   */
  MECAB_DLL_EXTERN const char*   mecab_sparse_tostr(mecab_t *mecab, const char *str);

  /**
   * C wrapper of MeCab::Tagger::parse(const char *str, size_t len)
   */
  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, char *ostr, size_t olen)
   */
  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::parseToNode(const char *str)
   */
  MECAB_DLL_EXTERN const mecab_node_t* mecab_sparse_tonode(mecab_t *mecab, const char*);

  /**
   * C wrapper of MeCab::Tagger::parseToNode(const char *str, size_t len)
   */
  MECAB_DLL_EXTERN const mecab_node_t* mecab_sparse_tonode2(mecab_t *mecab, const char*, size_t);

  /**
   * C wrapper of MeCab::Tagger::parseNBest(size_t N, const char *str)
   */
  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, size_t len)
   */
  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, char *ostr, size_t olen)
   */
  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::parseNBestInit(const char *str)
   */
  MECAB_DLL_EXTERN int           mecab_nbest_init(mecab_t *mecab, const char *str);

  /**
   * C wrapper of MeCab::Tagger::parseNBestInit(const char *str, size_t len)
   */
  MECAB_DLL_EXTERN int           mecab_nbest_init2(mecab_t *mecab, const char *str, size_t len);

  /**
   * C wrapper of MeCab::Tagger::next()
   */
  MECAB_DLL_EXTERN const char*   mecab_nbest_next_tostr(mecab_t *mecab);

  /**
   * C wrapper of MeCab::Tagger::next(char *ostr, size_t olen)
   */
  MECAB_DLL_EXTERN char*         mecab_nbest_next_tostr2(mecab_t *mecab, char *ostr, size_t olen);

  /**
   * C wrapper of MeCab::Tagger::nextNode()
   */
  MECAB_DLL_EXTERN const mecab_node_t* mecab_nbest_next_tonode(mecab_t *mecab);

  /**
   * C wrapper of MeCab::Tagger::formatNode(const Node *node)
   */
  MECAB_DLL_EXTERN const char*   mecab_format_node(mecab_t *mecab, const mecab_node_t *node);

  /**
   * C wrapper of MeCab::Tagger::dictionary_info()
   */
  MECAB_DLL_EXTERN const mecab_dictionary_info_t* mecab_dictionary_info(mecab_t *mecab);

  /* lattice interface */
  /**
   * C wrapper of MeCab::createLattice()
   */
  MECAB_DLL_EXTERN mecab_lattice_t *mecab_lattice_new();

  /**
   * C wrapper of MeCab::deleteLattice(lattice)
   */
  MECAB_DLL_EXTERN void             mecab_lattice_destroy(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::clear()
   */
  MECAB_DLL_EXTERN void             mecab_lattice_clear(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::is_available()
   */

  MECAB_DLL_EXTERN int              mecab_lattice_is_available(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::bos_node()
   */
  MECAB_DLL_EXTERN mecab_node_t    *mecab_lattice_get_bos_node(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::eos_node()
   */
  MECAB_DLL_EXTERN mecab_node_t    *mecab_lattice_get_eos_node(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::begin_nodes()
   */

  MECAB_DLL_EXTERN mecab_node_t   **mecab_lattice_get_all_begin_nodes(mecab_lattice_t *lattice);
  /**
   * C wrapper of MeCab::Lattice::end_nodes()
   */
  MECAB_DLL_EXTERN mecab_node_t   **mecab_lattice_get_all_end_nodes(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::begin_nodes(pos)
   */
  MECAB_DLL_EXTERN mecab_node_t    *mecab_lattice_get_begin_nodes(mecab_lattice_t *lattice, size_t pos);

  /**
   * C wrapper of MeCab::Lattice::end_nodes(pos)
   */
  MECAB_DLL_EXTERN mecab_node_t    *mecab_lattice_get_end_nodes(mecab_lattice_t *lattice, size_t pos);

  /**
   * C wrapper of MeCab::Lattice::sentence()
   */
  MECAB_DLL_EXTERN const char      *mecab_lattice_get_sentence(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::set_sentence(sentence)
   */
  MECAB_DLL_EXTERN void             mecab_lattice_set_sentence(mecab_lattice_t *lattice, const char *sentence);

  /**
   * C wrapper of MeCab::Lattice::set_sentence(sentence, len)
   */

  MECAB_DLL_EXTERN void             mecab_lattice_set_sentence2(mecab_lattice_t *lattice, const char *sentence, size_t len);

  /**
   * C wrapper of MeCab::Lattice::size()
   */
  MECAB_DLL_EXTERN size_t           mecab_lattice_get_size(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::Z()
   */
  MECAB_DLL_EXTERN double           mecab_lattice_get_z(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::set_Z()
   */
  MECAB_DLL_EXTERN void             mecab_lattice_set_z(mecab_lattice_t *lattice, double Z);

  /**
   * C wrapper of MeCab::Lattice::theta()
   */
  MECAB_DLL_EXTERN double           mecab_lattice_get_theta(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::set_theta()
   */

  MECAB_DLL_EXTERN void             mecab_lattice_set_theta(mecab_lattice_t *lattice, double theta);

  /**
   * C wrapper of MeCab::Lattice::next()
   */
  MECAB_DLL_EXTERN int              mecab_lattice_next(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::request_type()
   */
  MECAB_DLL_EXTERN int              mecab_lattice_get_request_type(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::has_request_type()
   */
  MECAB_DLL_EXTERN int              mecab_lattice_has_request_type(mecab_lattice_t *lattice, int request_type);

  /**
   * C wrapper of MeCab::Lattice::set_request_type()
   */
  MECAB_DLL_EXTERN void             mecab_lattice_set_request_type(mecab_lattice_t *lattice, int request_type);

  /**
   * C wrapper of MeCab::Lattice::add_request_type()
   */

  MECAB_DLL_EXTERN void             mecab_lattice_add_request_type(mecab_lattice_t *lattice, int request_type);

  /**
   * C wrapper of MeCab::Lattice::remove_request_type()
   */
  MECAB_DLL_EXTERN void             mecab_lattice_remove_request_type(mecab_lattice_t *lattice, int request_type);

  /**
   * C wrapper of MeCab::Lattice::newNode();
   */
  MECAB_DLL_EXTERN mecab_node_t    *mecab_lattice_new_node(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::toString()
   */
  MECAB_DLL_EXTERN const char      *mecab_lattice_tostr(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::toString(buf, size)
   */
  MECAB_DLL_EXTERN const char      *mecab_lattice_tostr2(mecab_lattice_t *lattice, char *buf, size_t size);

  /**
   * C wrapper of MeCab::Lattice::enumNBestAsString(N)
   */
  MECAB_DLL_EXTERN const char      *mecab_lattice_nbest_tostr(mecab_lattice_t *lattice, size_t N);

  /**
   * C wrapper of MeCab::Lattice::enumNBestAsString(N, buf, size)
   */

  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::has_constraint()
   */
  MECAB_DLL_EXTERN int             mecab_lattice_has_constraint(mecab_lattice_t *lattice);

  /**
   * C wrapper of MeCab::Lattice::boundary_constraint(pos)
   */
  MECAB_DLL_EXTERN int             mecab_lattice_get_boundary_constraint(mecab_lattice_t *lattice, size_t pos);


  /**
   * C wrapper of MeCab::Lattice::feature_constraint(pos)
   */
  MECAB_DLL_EXTERN const char     *mecab_lattice_get_feature_constraint(mecab_lattice_t *lattice, size_t pos);

  /**
   * C wrapper of MeCab::Lattice::boundary_constraint(pos, type)
   */
  MECAB_DLL_EXTERN void            mecab_lattice_set_boundary_constraint(mecab_lattice_t *lattice, size_t pos, int boundary_type);

  /**
   * C wrapper of MeCab::Lattice::set_feature_constraint(begin_pos, end_pos, feature)
   */
  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_result(result);
   */
  MECAB_DLL_EXTERN void            mecab_lattice_set_result(mecab_lattice_t *lattice, const char *result);

  /**
   * C wrapper of MeCab::Lattice::what()
   */
  MECAB_DLL_EXTERN const char      *mecab_lattice_strerror(mecab_lattice_t *lattice);


  /* model interface */
  /**
   * C wapper of MeCab::Model::create(argc, argv)
   */
  MECAB_DLL_EXTERN mecab_model_t   *mecab_model_new(int argc, char **argv);

  /**
   * C wapper of MeCab::Model::create(arg)
   */
  MECAB_DLL_EXTERN mecab_model_t   *mecab_model_new2(const char *arg);

  /**
   * C wapper of MeCab::deleteModel(model)
   */

  MECAB_DLL_EXTERN void             mecab_model_destroy(mecab_model_t *model);

  /**
   * C wapper of MeCab::Model::createTagger()
   */
  MECAB_DLL_EXTERN mecab_t         *mecab_model_new_tagger(mecab_model_t *model);

  /**
   * C wapper of MeCab::Model::createLattice()
   */
  MECAB_DLL_EXTERN mecab_lattice_t *mecab_model_new_lattice(mecab_model_t *model);

  /**
   * C wrapper of MeCab::Model::swap()
   */
  MECAB_DLL_EXTERN int mecab_model_swap(mecab_model_t *model, mecab_model_t *new_model);

  /**
   * C wapper of MeCab::Model::dictionary_info()
   */
  MECAB_DLL_EXTERN const mecab_dictionary_info_t* mecab_model_dictionary_info(mecab_model_t *model);

  /**
   * C wrapper of MeCab::Model::transition_cost()
   */
  MECAB_DLL_EXTERN int mecab_model_transition_cost(mecab_model_t *model,
                                                   unsigned short rcAttr,
                                                   unsigned short lcAttr);

  /**
   * C wrapper of MeCab::Model::lookup()
   */
  MECAB_DLL_EXTERN mecab_node_t *mecab_model_lookup(mecab_model_t *model,
                                                    const char *begin,
                                                    const char *end,
                                                    mecab_lattice_t *lattice);

  /* static functions */
  MECAB_DLL_EXTERN int           mecab_do(int argc, char **argv);
  MECAB_DLL_EXTERN int           mecab_dict_index(int argc, char **argv);
  MECAB_DLL_EXTERN int           mecab_dict_gen(int argc, char **argv);
  MECAB_DLL_EXTERN int           mecab_cost_train(int argc, char **argv);
  MECAB_DLL_EXTERN int           mecab_system_eval(int argc, char **argv);
  MECAB_DLL_EXTERN int           mecab_test_gen(int argc, char **argv);
#endif

#ifdef __cplusplus
}
#endif

/* C++ interface */
#ifdef __cplusplus

namespace MeCab {
typedef struct mecab_dictionary_info_t DictionaryInfo;
typedef struct mecab_path_t            Path;
typedef struct mecab_node_t            Node;

template <typename N, typename P> class Allocator;
class Tagger;

/**
 * Lattice class
 */
class MECAB_DLL_CLASS_EXTERN Lattice {
public:
  /**
   * Clear all internal lattice data.
   */
  virtual void clear()              = 0;

  /**
   * Return true if result object is available.
   * @return boolean
   */
  virtual bool is_available() const = 0;

  /**
   * Return bos (begin of sentence) node.
   * You can obtain all nodes via "for (const Node *node = lattice->bos_node(); node; node = node->next) {}"
   * @return bos node object
   */
  virtual Node *bos_node() const              = 0;

  /**
   * Return eos (end of sentence) node.
   * @return eos node object
   */
  virtual Node *eos_node() const              = 0;

#ifndef SWIG
  /**
   * This method is used internally.
   */
  virtual Node **begin_nodes() const          = 0;

  /**
   * This method is used internally.
   */
  virtual Node **end_nodes() const            = 0;
#endif

  /**
   * Return node linked list ending at |pos|.
   * You can obtain all nodes via "for (const Node *node = lattice->end_nodes(pos); node; node = node->enext) {}"
   * @param pos position of nodes. 0 <= pos < size()
   * @return node linked list
   */
  virtual Node *end_nodes(size_t pos) const   = 0;

  /**
   * Return node linked list starting at |pos|.
   * You can obtain all nodes via "for (const Node *node = lattice->begin_nodes(pos); node; node = node->bnext) {}"
   * @param pos position of nodes. 0 <= pos < size()
   * @return node linked list
   */
  virtual Node *begin_nodes(size_t pos) const = 0;

  /**
   * Return sentence.
   * If MECAB_NBEST or MECAB_PARTIAL mode is off, the returned poiner is the same as the one set by set_sentence().
   * @return sentence
   */
  virtual const char *sentence() const = 0;

  /**
   * Set sentence. This method does not take the ownership of the object.
   * @param sentence sentence
   */
  virtual void set_sentence(const char *sentence)             = 0;

#ifndef SWIG
  /**
   * Set sentence. This method does not take the ownership of the object.
   * @param sentence sentence
   * @param len length of the sentence
   */
  virtual void set_sentence(const char *sentence, size_t len) = 0;
#endif

  /**
   * Return sentence size.
   * @return sentence size
   */
  virtual size_t size() const                                 = 0;

  /**
   * Set normalization factor of CRF.
   * @param Z new normalization factor.
   */
  virtual void   set_Z(double Z) = 0;

  /**
   * return normalization factor of CRF.
   * @return normalization factor.
   */
  virtual double Z() const = 0;

  /**
   * Set temparature parameter theta.
   * @param theta temparature parameter.
   */
  virtual void  set_theta(float theta) = 0;

  /**
   * Return temparature parameter theta.
   * @return temparature parameter.
   */
  virtual float theta() const          = 0;

  /**
   * Obtain next-best result. The internal linked list structure is updated.
   * You should set MECAB_NBEST reques_type in advance.
   * Return false if no more results are available or request_type is invalid.
   * @return boolean
   */
  virtual bool next() = 0;

  /**
   * Return the current request type.
   * @return request type
   */
  virtual int request_type() const                = 0;

  /**
   * Return true if the object has a specified request type.
   * @return boolean
   */
  virtual bool has_request_type(int request_type) const = 0;

  /**
   * Set request type.
   * @param request_type new request type assigned
   */
  virtual void set_request_type(int request_type) = 0;

  /**
   * Add request type.
   * @param request_type new request type added
   */
  virtual void add_request_type(int request_type) = 0;

  /**
   * Remove request type.
   * @param request_type new request type removed
   */
  virtual void remove_request_type(int request_type) = 0;

#ifndef SWIG
  /**
   * This method is used internally.
   */
  virtual Allocator<Node, Path> *allocator() const = 0;
#endif

  /**
   * Return new node. Lattice objects has the ownership of the node.
   * @return new node object
   */
  virtual Node *newNode() = 0;

  /**
   * Return string representation of the lattice.
   * Returned object is managed by this instance. When clear/set_sentence() method
   * is called, the returned buffer is initialized.
   * @return string representation of the lattice
   */
  virtual const char *toString()                = 0;

  /**
   * Return string representation of the node.
   * Returned object is managed by this instance. When clear/set_sentence() method
   * is called, the returned buffer is initialized.
   * @return string representation of the node
   * @param node node object
   */
  virtual const char *toString(const Node *node) = 0;

  /**
   * Return string representation of the N-best results.
   * Returned object is managed by this instance. When clear/set_sentence() method
   * is called, the returned buffer is initialized.
   * @return string representation of the node
   * @param N how many results you want to obtain
   */
  virtual const char *enumNBestAsString(size_t N) = 0;

#ifndef SWIG
  /**
   * Return string representation of the lattice.
   * Result is saved in the specified buffer.
   * @param buf output buffer
   * @param size output buffer size
   * @return string representation of the lattice
   */
  virtual const char *toString(char *buf, size_t size) = 0;

  /**
   * Return string representation of the node.
   * Result is saved in the specified buffer.
   * @param node node object
   * @param buf output buffer
   * @param size output buffer size
   * @return string representation of the lattice
   */
  virtual const char *toString(const Node *node,
                               char *buf, size_t size) = 0;

  /**
   * Return string representation of the N-best result.
   * Result is saved in the specified.
   * @param N how many results you want to obtain
   * @param buf output buffer
   * @param size output buffer size
   * @return string representation of the lattice
   */
  virtual const char *enumNBestAsString(size_t N, char *buf, size_t size) = 0;
#endif

  /**
   * Returns true if any parsing constraint is set
   */
  virtual bool has_constraint() const = 0;

  /**
   * Returns the boundary constraint at the position.
   * @param pos the position of constraint
   * @return boundary constraint type
   */
  virtual int boundary_constraint(size_t pos) const = 0;

  /**
   * Returns the token constraint at the position.
   * @param pos the beginning position of constraint.
   * @return constrained node starting at the position.
   */
  virtual const char *feature_constraint(size_t pos) const = 0;

  /**
   * Set parsing constraint for partial parsing mode.
   * @param pos the position of the boundary
   * @param boundary_constraint_type the type of boundary
   */
  virtual void set_boundary_constraint(size_t pos,
                                       int boundary_constraint_type) = 0;

  /**
   * Set parsing constraint for partial parsing mode.
   * @param begin_pos the starting position of the constrained token.
   * @param end_pos the the ending position of the constrained token.
   * @param feature the feature of the constrained token.
   */
  virtual void set_feature_constraint(
      size_t begin_pos, size_t end_pos,
      const char *feature) = 0;

  /**
   * Set golden parsing results for unittesting.
   * @param result the parsing result written in the standard mecab output.
   */
  virtual void set_result(const char *result) = 0;

  /**
   * Return error string.
   * @return error string
   */
  virtual const char *what() const            = 0;

  /**
   * Set error string. given string is copied to the internal buffer.
   * @param str new error string
   */
  virtual void set_what(const char *str)        = 0;

#ifndef SWIG
  /**
   * Create new Lattice object
   * @return new Lattice object
   */
  static Lattice *create();
#endif

  virtual ~Lattice() {}
};

/**
 * Model class
 */
class MECAB_DLL_CLASS_EXTERN Model {
public:
  /**
   * Return DictionaryInfo linked list.
   * @return DictionaryInfo linked list
   */
  virtual const DictionaryInfo *dictionary_info() const = 0;

  /**
   * Return transtion cost from rcAttr to lcAttr.
   * @return transtion cost
   */
  virtual int transition_cost(unsigned short rcAttr,
                              unsigned short lcAttr) const = 0;

  /**
   * perform common prefix search from the range [begin, end).
   * |lattice| takes the ownership of return value.
   * @return node linked list.
   */
  virtual Node *lookup(const char *begin, const char *end,
                       Lattice *lattice) const = 0;

  /**
   * Create a new Tagger object.
   * All returned tagger object shares this model object as a parsing model.
   * Never delete this model object before deleting tagger object.
   * @return new Tagger object
   */
  virtual Tagger  *createTagger() const = 0;

  /**
   * Create a new Lattice object.
   * @return new Lattice object
   */
  virtual Lattice *createLattice() const = 0;

  /**
   * Swap the instance with |model|.
   * The ownership of |model| always moves to this instance,
   * meaning that passed |model| will no longer be accessible after calling this method.
   * return true if new model is swapped successfully.
   * This method is thread safe. All taggers created by
   * Model::createTagger() method will also be updated asynchronously.
   * No need to stop the parsing thread excplicitly before swapping model object.
   * @return boolean
   * @param model new model which is going to be swapped with the current model.
   */
  virtual bool swap(Model *model) = 0;

  /**
   * Return a version string
   * @return version string
   */
  static const char *version();

  virtual ~Model() {}

#ifndef SWIG
  /**
   * Factory method to create a new Model with a specified main's argc/argv-style parameters.
   * Return NULL if new model cannot be initialized. Use MeCab::getLastError() to obtain the
   * cause of the errors.
   * @return new Model object
   * @param argc number of parameters
   * @param argv parameter list
   */
  static Model* create(int argc, char **argv);

  /**
   * Factory method to create a new Model with a string parameter representation, i.e.,
   * "-d /user/local/mecab/dic/ipadic -Ochasen".
   * Return NULL if new model cannot be initialized. Use MeCab::getLastError() to obtain the
   * cause of the errors.
   * @return new Model object
   * @param arg single string representation of the argment.
   */
  static Model* create(const char *arg);
#endif
};

/**
 * Tagger class
 */
class MECAB_DLL_CLASS_EXTERN Tagger {
public:
  /**
   * Handy static method.
   * Return true if lattice is parsed successfully.
   * This function is equivalent to
   * {
   *   Tagger *tagger = model.createModel();
   *   cosnt bool result = tagger->parse(lattice);
   *   delete tagger;
   *   return result;
   * }
   * @return boolean
   */
  static bool  parse(const Model &model, Lattice *lattice);

  /**
   * Parse lattice object.
   * Return true if lattice is parsed successfully.
   * A sentence must be set to the lattice with Lattice:set_sentence object before calling this method.
   * Parsed node object can be obtained with Lattice:bos_node.
   * This method is thread safe.
   * @return lattice lattice object
   * @return boolean
   */
  virtual bool parse(Lattice *lattice) const                = 0;

  /**
   * Parse given sentence and return parsed result as string.
   * You should not delete the returned string. The returned buffer
   * is overwritten when parse method is called again.
   * This method is NOT thread safe.
   * @param str sentence
   * @return parsed result
   */
  virtual const char* parse(const char *str)                = 0;

  /**
   * Parse given sentence and return Node object.
   * You should not delete the returned node object. The returned buffer
   * is overwritten when parse method is called again.
   * You can traverse all nodes via Node::next member.
   * This method is NOT thread safe.
   * @param str sentence
   * @return bos node object
   */
  virtual const Node* parseToNode(const char *str)          = 0;

  /**
   * Parse given sentence and obtain N-best results as a string format.
   * Currently, N must be 1 <= N <= 512 due to the limitation of the buffer size.
   * You should not delete the returned string. The returned buffer
   * is overwritten when parse method is called again.
   * This method is DEPRECATED. Use Lattice class.
   * @param N how many results you want to obtain
   * @param str sentence
   * @return parsed result
   */
  virtual const char* parseNBest(size_t N, const char *str) = 0;

  /**
   * Initialize N-best enumeration with a sentence.
   * Return true if initialization finishes successfully.
   * N-best result is obtained by calling next() or nextNode() in sequence.
   * This method is NOT thread safe.
   * This method is DEPRECATED. Use Lattice class.
   * @param str sentence
   * @return boolean
   */
  virtual bool  parseNBestInit(const char *str)             = 0;

  /**
   * Return next-best parsed result. You must call parseNBestInit() in advance.
   * Return NULL if no more reuslt is available.
   * This method is NOT thread safe.
   * This method is DEPRECATED. Use Lattice class.
   * @return node object
   */
  virtual const Node* nextNode()                            = 0;

  /**
   * Return next-best parsed result. You must call parseNBestInit() in advance.
   * Return NULL if no more reuslt is available.
   * This method is NOT thread safe.
   * This method is DEPRECATED. Use Lattice class.
   * @return parsed result
   */
  virtual const char* next()                                = 0;

  /**
   * Return formatted node object. The format is specified with
   * --unk-format, --bos-format, --eos-format, and --eon-format respectively.
   * You should not delete the returned string. The returned buffer
   * is overwritten when parse method is called again.
   * This method is NOT thread safe.
   * This method is DEPRECATED. Use Lattice class.
   * @param node node object.
   * @return parsed result
   */
  virtual const char* formatNode(const Node *node)          = 0;

#ifndef SWIG
  /**
   * The same as parse() method, but input length and output buffer are passed.
   * Return parsed result as string. The result pointer is the same as |ostr|.
   * Return NULL, if parsed result string cannot be stored within |olen| bytes.
   * @param str sentence
   * @param len sentence length
   * @param ostr output buffer
   * @param olen output buffer length
   * @return parsed result
   */
  virtual const char* parse(const char *str, size_t len, char *ostr, size_t olen) = 0;

  /**
   * The same as parse() method, but input length can be passed.
   * @param str sentence
   * @param len sentence length
   * @return parsed result
   */
  virtual const char* parse(const char *str, size_t len)                          = 0;

  /**
   * The same as parseToNode(), but input lenth can be passed.
   * @param str sentence
   * @param len sentence length
   * @return node object
   */
  virtual const Node* parseToNode(const char *str, size_t len)                    = 0;

  /**
   * The same as parseNBest(), but input length can be passed.
   * @param N how many results you want to obtain
   * @param str sentence
   * @param len sentence length
   * @return parsed result
   */
  virtual const char* parseNBest(size_t N, const char *str, size_t len)           = 0;

  /**
   * The same as parseNBestInit(), but input length can be passed.
   * @param str sentence
   * @param len sentence length
   * @return boolean
   * @return parsed result
   */
  virtual bool  parseNBestInit(const char *str, size_t len)                  = 0;

  /**
   * The same as next(), but output buffer can be passed.
   * Return NULL if more than |olen| buffer is required to store output string.
   * @param ostr output buffer
   * @param olen output buffer length
   * @return parsed result
   */
  virtual const char* next(char *ostr , size_t olen)                        = 0;

  /**
   * The same as parseNBest(), but input length and output buffer can be passed.
   * Return NULL if more than |olen| buffer is required to store output string.
   * @param N how many results you want to obtain
   * @param str input sentence
   * @param len input sentence length
   * @param ostr output buffer
   * @param olen output buffer length
   * @return parsed result
   */
  virtual const char* parseNBest(size_t N, const char *str,
                                 size_t len, char *ostr, size_t olen)       = 0;

  /**
   * The same as formatNode(), but output buffer can be passed.
   * Return NULL if more than |olen| buffer is required to store output string.
   * @param node node object
   * @param ostr output buffer
   * @param olen output buffer length
   * @return parsed result
   */
  virtual const char* formatNode(const Node *node, char *ostr, size_t olen) = 0;
#endif

  /**
   * Set request type.
   * This method is DEPRECATED. Use Lattice::set_request_type(MECAB_PARTIAL).
   * @param request_type new request type assigned
   */
  virtual void set_request_type(int request_type) = 0;

  /**
   * Return the current request type.
   * This method is DEPRECATED. Use Lattice class.
   * @return request type
   */
  virtual int  request_type() const = 0;

  /**
   * Return true if partial parsing mode is on.
   * This method is DEPRECATED. Use Lattice::has_request_type(MECAB_PARTIAL).
   * @return boolean
   */
  virtual bool  partial() const                             = 0;

  /**
   * set partial parsing mode.
   * This method is DEPRECATED. Use Lattice::add_request_type(MECAB_PARTIAL) or Lattice::remove_request_type(MECAB_PARTIAL)
   * @param partial partial mode
   */
  virtual void  set_partial(bool partial)                   = 0;

  /**
   * Return lattice level.
   * This method is DEPRECATED. Use Lattice::*_request_type()
   * @return int lattice level
   */
  virtual int   lattice_level() const                       = 0;

  /**
   * Set lattice level.
   * This method is DEPRECATED. Use Lattice::*_request_type()
   * @param level lattice level
   */
  virtual void  set_lattice_level(int level)                = 0;

  /**
   * Return true if all morphs output mode is on.
   * This method is DEPRECATED. Use Lattice::has_request_type(MECAB_ALL_MORPHS).
   * @return boolean
   */
  virtual bool  all_morphs() const                          = 0;

  /**
   * set all-morphs output mode.
   * This method is DEPRECATED. Use Lattice::add_request_type(MECAB_ALL_MORPHS) or Lattice::remove_request_type(MECAB_ALL_MORPHS)
   * @param all_morphs
   */
  virtual void  set_all_morphs(bool all_morphs)             = 0;

  /**
   * Set temparature parameter theta.
   * @param theta temparature parameter.
   */
  virtual void  set_theta(float theta)                      = 0;

  /**
   * Return temparature parameter theta.
   * @return temparature parameter.
   */
  virtual float theta() const                               = 0;

  /**
   * Return DictionaryInfo linked list.
   * @return DictionaryInfo linked list
   */
  virtual const DictionaryInfo* dictionary_info() const = 0;

  /**
   * Return error string.
   * @return error string
   */
  virtual const char* what() const = 0;

  virtual ~Tagger() {}

#ifndef SWIG
  /**
   * Factory method to create a new Tagger with a specified main's argc/argv-style parameters.
   * Return NULL if new model cannot be initialized. Use MeCab::getLastError() to obtain the
   * cause of the errors.
   * @return new Tagger object
   * @param argc number of parameters
   * @param argv parameter list
   */
  static Tagger *create(int argc, char **argv);

  /**
   * Factory method to create a new Tagger with a string parameter representation, i.e.,
   * "-d /user/local/mecab/dic/ipadic -Ochasen".
   * Return NULL if new model cannot be initialized. Use MeCab::getLastError() to obtain the
   * cause of the errors.
   * @return new Model object
   * @param arg single string representation of the argment.
   */
  static Tagger *create(const char *arg);
#endif

  /**
   * Return a version string
   * @return version string
   */
  static const char *version();
};

#ifndef SWIG
/**
 * Alias of Lattice::create()
 */
MECAB_DLL_EXTERN Lattice     *createLattice();

/**
 * Alias of Mode::create(argc, argv)
 */
MECAB_DLL_EXTERN Model       *createModel(int argc, char **argv);

/**
 * Alias of Mode::create(arg)
 */
MECAB_DLL_EXTERN Model       *createModel(const char *arg);

/**
 * Alias of Tagger::create(argc, argv)
 */
MECAB_DLL_EXTERN Tagger      *createTagger(int argc, char **argv);

/**
 * Alias of Tagger::create(arg)
 */
MECAB_DLL_EXTERN Tagger      *createTagger(const char *arg);

/**
 * delete Lattice object.
 * This method calles "delete lattice".
 * In some environment, e.g., MS-Windows, an object allocated inside a DLL must be deleted in the same DLL too.
 * @param lattice lattice object
 */
MECAB_DLL_EXTERN void        deleteLattice(Lattice *lattice);


/**
 * delete Model object.
 * This method calles "delete model".
 * In some environment, e.g., MS-Windows, an object allocated inside a DLL must be deleted in the same DLL too.
 * @param model model object
 */
MECAB_DLL_EXTERN void        deleteModel(Model *model);

/**
 * delete Tagger object.
 * This method calles "delete tagger".
 * In some environment, e.g., MS-Windows, an object allocated inside a DLL must be deleted in the same DLL too.
 * @param tagger tagger object
 */
MECAB_DLL_EXTERN void        deleteTagger(Tagger *tagger);

/**
 * Return last error string.
 * @return error string
 */
MECAB_DLL_EXTERN const char*  getLastError();

/**
 * An alias of getLastError.
 * It is kept for backward compatibility.
 * @return error string
 */
MECAB_DLL_EXTERN const char*  getTaggerError();
#endif
}
#endif
#endif  /* MECAB_MECAB_H_ */