#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;
delete tagger;
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
CRF++0.58 windows 二进制版
共65个文件
html:22个
png:10个
data:8个
需积分: 14 37 下载量 158 浏览量
2017-05-19
13:35:27
上传
评论
收藏 495KB ZIP 举报
温馨提示
https://taku910.github.io/crfpp/#download 转发自官网指定的google driver
资源推荐
资源详情
资源评论
收起资源包目录
CRF++-0.58.zip (65个子文件)
CRF++-0.58
LGPL 26KB
crf_learn.exe 50KB
AUTHORS 28B
crf_test.exe 50KB
COPYING 164B
sdk
crfpp.h 13KB
example.cpp 2KB
libcrfpp.lib 18KB
doc
default.css 3KB
index.html 26KB
doxygen
files.html 2KB
tab_a.png 140B
classes.html 3KB
index.html 2KB
classCRFPP_1_1Tagger.html 54KB
open.png 118B
namespacemembers_func.html 2KB
tab_h.png 192B
nav_h.png 97B
tab_b.gif 35B
crfpp_8h-source.html 45KB
doxygen.png 4KB
namespaces.html 2KB
classCRFPP_1_1Model.html 11KB
namespacemembers.html 3KB
annotated.html 2KB
tab_s.png 189B
globals_func.html 9KB
globals_type.html 2KB
bc_s.png 677B
doxygen.css 15KB
tab_r.gif 3KB
namespaceCRFPP.html 13KB
globals_defs.html 2KB
tab_l.gif 706B
closed.png 126B
tabs.css 1KB
globals.html 9KB
crfpp_8h_source.html 60KB
classCRFPP_1_1Tagger-members.html 15KB
nav_f.png 159B
tab_b.png 178B
crfpp_8h.html 91KB
functions.html 10KB
classCRFPP_1_1Model-members.html 4KB
functions_func.html 10KB
example
seg
exec.sh 200B
train.data 8KB
template 212B
test.data 8KB
JapaneseNE
exec.sh 204B
train.data 109KB
template 614B
test.data 284KB
chunking
exec.sh 280B
train.data 25KB
template 359B
test.data 252KB
basenp
exec.sh 193B
train.data 20KB
template 372B
test.data 202KB
BSD 1KB
README 20B
libcrfpp.dll 330KB
共 65 条
- 1
资源评论
tianfang
- 粉丝: 1121
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功