-
Notifications
You must be signed in to change notification settings - Fork 208
/
common.h
140 lines (119 loc) · 3.3 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
// MeCab -- Yet Another Part-of-Speech and Morphological Analyzer
//
//
// Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
// Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
#ifndef MECAB_COMMON_H_
#define MECAB_COMMON_H_
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <sstream>
#ifdef __CYGWIN__
#define _GLIBCXX_EXPORT_TEMPLATE
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if defined(_MSC_VER) || defined(__CYGWIN__)
#define NOMINMAX
#define snprintf _snprintf
#endif
#define COPYRIGHT "MeCab: Yet Another Part-of-Speech and Morphological Analyzer\n\
\nCopyright(C) 2001-2012 Taku Kudo \nCopyright(C) 2004-2008 Nippon Telegraph and Telephone Corporation\n"
#define SYS_DIC_FILE "sys.dic"
#define UNK_DEF_FILE "unk.def"
#define UNK_DIC_FILE "unk.dic"
#define MATRIX_DEF_FILE "matrix.def"
#define MATRIX_FILE "matrix.bin"
#define CHAR_PROPERTY_DEF_FILE "char.def"
#define CHAR_PROPERTY_FILE "char.bin"
#define FEATURE_FILE "feature.def"
#define REWRITE_FILE "rewrite.def"
#define LEFT_ID_FILE "left-id.def"
#define RIGHT_ID_FILE "right-id.def"
#define POS_ID_FILE "pos-id.def"
#define MODEL_DEF_FILE "model.def"
#define MODEL_FILE "model.bin"
#define DICRC "dicrc"
#define BOS_KEY "BOS/EOS"
#define DEFAULT_MAX_GROUPING_SIZE 24
#define CHAR_PROPERTY_DEF_DEFAULT "DEFAULT 1 0 0\nSPACE 0 1 0\n0x0020 SPACE\n"
#define UNK_DEF_DEFAULT "DEFAULT,0,0,0,*\nSPACE,0,0,0,*\n"
#define MATRIX_DEF_DEFAULT "1 1\n0 0 0\n"
#ifdef MECAB_USE_UTF8_ONLY
#define MECAB_DEFAULT_CHARSET "UTF-8"
#endif
#ifndef MECAB_DEFAULT_CHARSET
#if defined(_WIN32) && !defined(__CYGWIN__)
#define MECAB_DEFAULT_CHARSET "SHIFT-JIS"
#else
#define MECAB_DEFAULT_CHARSET "EUC-JP"
#endif
#endif
#define NBEST_MAX 512
#define NODE_FREELIST_SIZE 512
#define PATH_FREELIST_SIZE 2048
#define MIN_INPUT_BUFFER_SIZE 8192
#define MAX_INPUT_BUFFER_SIZE (8192*640)
#define BUF_SIZE 8192
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifdef _WIN32
#ifdef __GNUC__
#define WPATH_FORCE(path) (MeCab::Utf8ToWide(path).c_str())
#define WPATH(path) (path)
#else
#define WPATH(path) WPATH_FORCE(path)
#endif
#else
#define WPATH_FORCE(path) (path)
#define WPATH(path) (path)
#endif
namespace MeCab {
class die {
public:
die() {}
~die() {
std::cerr << std::endl;
exit(-1);
}
int operator&(std::ostream&) { return 0; }
};
struct whatlog {
std::ostringstream stream_;
std::string str_;
const char *str() {
str_ = stream_.str();
return str_.c_str();
}
};
class wlog {
public:
wlog(whatlog *what) : what_(what) {
what_->stream_.clear();
}
bool operator&(std::ostream &) {
return false;
}
private:
whatlog *what_;
};
} // MeCab
#define WHAT what_.stream_
#define CHECK_FALSE(condition) \
if (condition) {} else return \
wlog(&what_) & what_.stream_ << \
__FILE__ << "(" << __LINE__ << ") [" << #condition << "] "
#define CHECK_DIE(condition) \
(condition) ? 0 : die() & std::cerr << __FILE__ << \
"(" << __LINE__ << ") [" << #condition << "] "
#endif // MECAB_COMMON_H_