#include <iostream>
#include "crfpp.h"
// c++ -O3 example.cpp -lcrfpp
int main(int argc, char **argv) {
// -v 3: access deep information like alpha,beta,prob
// -nN: enable nbest output. N should be >= 2
CRFPP::Tagger *tagger =
CRFPP::createTagger("-m model -v 3 -n2");
if (!tagger) {
std::cerr << CRFPP::getTaggerError() << std::endl;
return -1;
}
// clear internal context
tagger->clear();
// add context
tagger->add("Confidence NN");
tagger->add("in IN");
tagger->add("the DT");
tagger->add("pound NN");
tagger->add("is VBZ");
tagger->add("widely RB");
tagger->add("expected VBN");
tagger->add("to TO");
tagger->add("take VB");
tagger->add("another DT");
tagger->add("sharp JJ");
tagger->add("dive NN");
tagger->add("if IN");
tagger->add("trade NN");
tagger->add("figures NNS");
tagger->add("for IN");
tagger->add("September NNP");
std::cout << "column size: " << tagger->xsize() << std::endl;
std::cout << "token size: " << tagger->size() << std::endl;
std::cout << "tag size: " << tagger->ysize() << std::endl;
std::cout << "tagset information:" << std::endl;
for (size_t i = 0; i < tagger->ysize(); ++i) {
std::cout << "tag " << i << " " << tagger->yname(i) << std::endl;
}
// parse and change internal stated as 'parsed'
if (! tagger->parse()) return -1;
std::cout << "conditional prob=" << tagger->prob()
<< " log(Z)=" << tagger->Z() << std::endl;
for (size_t i = 0; i < tagger->size(); ++i) {
for (size_t j = 0; j < tagger->xsize(); ++j) {
std::cout << tagger->x(i, j) << '\t';
}
std::cout << tagger->y2(i) << '\t';
std::cout << std::endl;
std::cout << "Details";
for (size_t j = 0; j < tagger->ysize(); ++j) {
std::cout << '\t' << tagger->yname(j) << "/prob=" << tagger->prob(i,j)
<< "/alpha=" << tagger->alpha(i, j)
<< "/beta=" << tagger->beta(i, j);
}
std::cout << std::endl;
}
// when -n20 is specified, you can access nbest outputs
std::cout << "nbest outputs:" << std::endl;
for (size_t n = 0; n < 10; ++n) {
if (! tagger->next()) break;
std::cout << "nbest n=" << n << "\tconditional prob=" << tagger->prob() << std::endl;
// you can access any information using tagger->y()...
}
std::cout << "Done" << std::endl;
}
没有合适的资源?快使用搜索试试~ 我知道了~
CRF++0.54工具包
共55个文件
html:17个
data:8个
template:4个
5星 · 超过95%的资源 需积分: 3 34 下载量 140 浏览量
2011-05-25
11:39:00
上传
评论
收藏 467KB ZIP 举报
温馨提示
开源的CRF++工具包,crf++在易用性,稳定性和准确性等综合方面均有着不错的表现,十分适合中文分词技术研究者使用。
资源推荐
资源详情
资源评论
收起资源包目录
CRF++-0.54.zip (55个子文件)
CRF++-0.54
BSD 1KB
COPYING 164B
sdk
crfpp.h 10KB
libcrfpp.lib 11KB
example.cpp 2KB
libcrfpp.opt 43KB
crf_learn.opt 43KB
LGPL 26KB
AUTHORS 28B
crf_test.opt 43KB
crf_test.exe 40KB
README 19B
example
seg
exec.sh 200B
template 212B
test.data 8KB
train.data 8KB
basenp
exec.sh 193B
template 372B
test.data 202KB
train.data 20KB
chunking
exec.sh 280B
template 359B
test.data 252KB
train.data 25KB
JapaneseNE
exec.sh 204B
template 614B
test.data 284KB
train.data 109KB
libcrfpp.dll 332KB
crf_learn.exe 40KB
doc
index.html 25KB
default.css 3KB
doxygen
tabs.css 2KB
crfpp_8h-source.html 45KB
tab_r.gif 3KB
doxygen.css 9KB
globals_type.html 2KB
namespaceCRFPP.html 5KB
namespaces.html 1KB
files.html 1KB
tab_b.gif 35B
doxygen.png 1KB
functions_func.html 8KB
annotated.html 1KB
namespacemembers.html 2KB
Thumbs.db 8KB
classCRFPP_1_1Tagger.html 47KB
functions.html 8KB
tab_l.gif 706B
globals.html 6KB
globals_func.html 6KB
crfpp_8h.html 60KB
index.html 1KB
namespacemembers_func.html 2KB
classCRFPP_1_1Tagger-members.html 13KB
共 55 条
- 1
资源评论
- xiixiixixi2014-05-12可以用 非常的好 谢谢
keithsu0928
- 粉丝: 3
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功