• 大小: 354KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: CRF  

资源简介

这是一个关于CRF的源代码,能直接来用,欢迎广大朋友下载

资源截图

代码片段和文件信息

#include “base_feature.h“
#include “fun.h“
#include 
#include 
#ifdef _WIN32
#include 
#else
#include 
#endif
#include “const.h“

using namespace std;

vector base_feature::_labels;

feature_pool::feature_pool(){
_feature_num=0;
_cols=0;
_sen_num=0;
_total_words=0;
_total_bytes=0;
_max_sen_bytes=0;
}

feature_pool::~feature_pool(){
int i;
for(i=0;i<_features.size();i++){
delete _features[i];
}
}

bool feature_pool::check_training(char *training_file){
ifstream fin;
int i;
fin.open(training_file);
if(!fin.is_open()){
cout<<“can not open file: “< return false;
}

int lines=0;
_cols=0;
vector > table;
bool has_next;

do{
has_next=build_table(fintablelines);
if(table.size()){
for(i=0;i if(_cols && _cols!=table[i].size()){//incompatible
lines=lines-table.size()+i;
if(!has_next)
lines++;
cout<<“line “< fin.close();
return false;
}
_cols=table[i].size();
if(_cols<3){
lines=lines-table.size()+i;
if(!has_next)
lines++;
cout<<“line “< fin.close();
return false;
}
string t=table[i].back();//label
int par_pos=atoi(table[i][table[i].size()-2].c_str());
if(par_pos!=table.size()){
int indexinsert_pos;
if(!vector_search(base_feature::_labelstindexinsert_pos)){
vector_insert(base_feature::_labelstinsert_pos);
}
}
}
//check projective
if(!is_projective(table)){
lines=lines-table.size();
if(!has_next)
lines++;
cout<<“sentence beginning at line “< fin.close();
return false;
}
int rn=root_num(table);
if(rn>1){
lines=lines-table.size();
if(!has_next)
lines++;
cout<<“sentence beginning at line “< fin.close();
return false;
}else if(rn==0){
lines=lines-table.size();
if(!has_next)
lines++;
cout<<“sentence beginning at line “< fin.close();
return false;
}
}
}while(has_next);
fin.close();
return true;
}


int base_feature::get_label_index(string &t){
int indexinsert_pos;
if(!vector_search(base_feature::_labelstindexinsert_pos))
return -1;//not found
return index;
}

void feature_pool::push_back(base_feature *bf){
bf->_base_feature_id=_feature_num;
_feature_num=_feature_num+bf->_feature_num;
_features.push_back(bf);
_base_feature_ids.push_back(bf->_base_feature_id);
}



void feature_pool::generate_feature(char *training_file){
int lines=0;
ifstream fin;
vector > table;
bool has_next;
int i=0;
cout<<“generate sentences“< fin.open(training_file);
do{
has_next=build_table(fintablelines);
if(table.size()){
sentence_tmp st;
generate_sentence(tablest);
char fn[100];
sprintf(f

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......     10586  2010-06-08 20:56  crfparser_0.10\base_feature.cpp

    .......      1875  2010-06-07 13:09  crfparser_0.10\base_feature.h

    .......       388  2010-06-07 08:45  crfparser_0.10\const.h

    .......     18832  2010-06-10 13:16  crfparser_0.10\crfparser.cpp

    .......      1938  2010-06-07 14:17  crfparser_0.10\crfparser.h

    .......    217088  2010-06-19 22:15  crfparser_0.10\crfparser_learn.exe

    .......    180224  2010-06-19 22:14  crfparser_0.10\crfparser_test.exe

    .......     27467  2010-06-07 10:05  crfparser_0.10\crfparser_thread.cpp

    .......      2417  2009-03-17 09:55  crfparser_0.10\crfparser_thread.h

    .......      5149  2010-06-19 21:34  crfparser_0.10\dat.h

    .......      1349  2009-03-17 09:55  crfparser_0.10\freelist.h

    .......      2179  2010-06-07 00:51  crfparser_0.10\fun.cpp

    .......      3781  2010-01-08 18:05  crfparser_0.10\fun.h

    .......      1586  2010-06-17 10:28  crfparser_0.10\key

    .......     17282  2010-05-07 19:32  crfparser_0.10\lbfgs.cpp

    .......       901  2010-05-07 19:31  crfparser_0.10\lbfgs.h

    .......     26428  2007-03-07 23:54  crfparser_0.10\LGPL

    .......      9953  2010-06-19 22:15  crfparser_0.10\main.cpp

    .......      1308  2010-06-08 18:30  crfparser_0.10\Makefile

    .......     75049  2013-11-06 21:07  crfparser_0.10\model

    .......     16530  2010-06-17 12:22  crfparser_0.10\readme.html

    .......      2202  2013-11-06 21:09  crfparser_0.10\result

    .......      2780  2010-06-17 10:28  crfparser_0.10\template

    .......     32685  2010-06-19 20:37  crfparser_0.10\templet_feature.cpp

    .......      4094  2010-06-19 20:37  crfparser_0.10\templet_feature.h

    .......  26030104  2013-11-06 21:07  crfparser_0.10\tf

    .......      1197  2009-03-17 09:55  crfparser_0.10\thread.h

    .......      1586  2010-06-17 10:27  crfparser_0.10\train

    .......      2910  2010-06-09 18:23  crfparser_0.10\user.cpp

     目录          0  2013-11-27 15:05  crfparser_0.10

............此处省略3个文件信息

评论

共有 条评论