-
Notifications
You must be signed in to change notification settings - Fork 2
/
mecab_lib.cc
47 lines (34 loc) · 871 Bytes
/
mecab_lib.cc
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
#include "mecab_lib.h"
namespace MeCab
{
Parser* initialize_parser()
{
MeCab::Parser *parser = MeCab::createTagger("");
if (parser == NULL)
{
throw std::runtime_error("init failed:"
+ std::string(MeCab::getTaggerError()));
}
return parser;
} // end of initialize_parser()
void deinitialize_parser(Parser*& parser)
{
delete parser;
parser = NULL;
} // end of deinitialize_parser()
bool is_indexable_node(const MeCab::Node* node)
{
switch (node->posid)
{
case MeCab::POSID::COMPOUND:
case MeCab::POSID::NN_NOUN:
case MeCab::POSID::SL_FOREIGN:
case MeCab::POSID::SN_NUMERIC:
return true;
break;
default:
return false;
break;
}
} // end of is_indexable_node()
} // end of namespace MeCab