Last active
May 4, 2021 04:40
-
-
Save curipha/5d83fa381e716792242b511deaf2fff8 to your computer and use it in GitHub Desktop.
C++ source to use Mecab library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run following command to build this file. | |
// $ g++ `mecab-config --cflags` `mecab-config --libs` -Os mecab.cpp | |
#include <iostream> | |
#include <mecab.h> | |
int main (int argc, char **argv) { | |
const MeCab::Node* node = MeCab::createTagger("")->parseToNode("隣の客はよく柿食う客だ。"); | |
for (; node; node = node->next) { | |
switch(node->stat) { | |
case MECAB_BOS_NODE: | |
case MECAB_EOS_NODE: | |
continue; | |
default: | |
std::cout | |
<< node->feature | |
// << ' ' << (int)(node->surface - input) | |
// << ' ' << (int)(node->surface - input + node->length) | |
// << ' ' << node->rcAttr | |
// << ' ' << node->lcAttr | |
// << ' ' << node->posid | |
// << ' ' << (int)node->char_type | |
// << ' ' << (int)node->stat | |
// << ' ' << (int)node->isbest | |
// << ' ' << node->alpha | |
// << ' ' << node->beta | |
// << ' ' << node->prob | |
// << ' ' << node->cost | |
<< std::endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment