链接类型错误:
Error 3 error LNK2019: unresolved external symbol "class std::set<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl MakeStopSet(void)" (?MakeStopSet@@YA?AV?$set@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@XZ) referenced in function "public: int __thiscall Preprocess::ConstructMap(class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::vector<struct std::pair<int,int>,class std::allocator<struct std::pair<int,int> > >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::vector<struct std::pair<int,int>,class std::allocator<struct std::pair<int,int> > > > > > &,int,int)" (?ConstructMap@Preprocess@@QAEHAAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@U?$pair@HH@std@@V?$allocator@U?$pair@HH@std@@@2@@2@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$vector@U?$pair@HH@std@@V?$allocator@U?$pair@HH@std@@@2@@2@@std@@@2@@std@@HH@Z) Preprocess.obj WekaPreprocess
代码头文件
#ifndef _Preprocess_H
#define _Preprocess_H
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<iomanip>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<limits>
#include <xstring>
#include"ictclas30.h"
#include"boost\tr1\regex.hpp"
#include"boost/algorithm/string.hpp"
#include"windows.h"
/************************************************************************/
/* WkaPreprocess类完成如下功能
将文本集合分词-》去停用词-》建立词袋子模型=》特征词选择=》对文章建立VSM模型=
》写成weka数据格式(arff)-》输出聚类信息 */
/************************************************************************/
//一些谓词函数
using namespace std;
class Preprocess
{
public:
void trim(string &str,const string val);//去除字符串首尾空白
//构建倒排表: key=word,val= a list of pairs which consists of articleid,and count, count=tf
int ConstructMap(map<string,vector<pair<int,int>>>&mymap,int beginindex,int endindex);
//保存词袋子到硬盘
void save(map<string,vector<pair<int,int> > >&mymap);
//从内存中加载词袋子模型
void load(map<string,vector<pair<int,int> > >&mymap);
//打印词袋子模型
void print(map<string,vector<pair<int,int> > >&mymap);
//窄字符串转化成宽字符串
wstring myMultibyteToWideChar(string sResult);
//宽字符串转化成窄字符串
string myWideCharToMultibyte(wstring wsResult);
//调用ICTclass分词
string ICTsplit(const char *sInput);
//构造停用词表
set<string>MakeStopSet();
//去除停用词,噪声词
vector<string>goodWordsinPieceArticle(string rawtext,set<string> stopwords);
//整数转化成字符串
string do_fraction(int val);
//浮点数转化成字符串
string do_fraction(double val, int decplaces=5);
//特征词选择算法
void DFcharicteristicWordSelection(map<string,vector<pair<int,int>>> &mymap,int DFthreshold);
//获取最后的特征词
vector<string> GetFinalKeyWords();
//获取特征词的maxTF,DF
vector<pair<int,int> >GetfinalKeysMaxTFDF(map<string,vector<pair<int,int>>> &mymap);
//文档向量模型规范化
vector<pair<int,double> > NormalizationVSM(vector<pair<int,double> > tempVSM);
//建立文档向量模型并且写到arff文件里
void VSMFormation(map<string,vector<pair<int,int>>> &mymap,int articleIdBegin,int maxArticleId,int corpus_N);
/***单个文档向量模型字符串化***/
string FormatVSMtoString(vector<pair<int,double> > tempVSM);
//写Arff文件头部
void WriteHeadArff();
};
#endif
源文件
#include"stdafx.h"
#include "Preprocess.h"
#pragma comment(lib, "ICTCLAS30.lib")
using namespace std;
/************************************************************************/
/* 去掉字符串首尾空白 */
/************************************************************************/
bool isLonger(const pair<string,int> &pair1, const pair<string,int> &pair2)
{
return pair1.second>pair2.second;
}
bool cntAssist(const pair<string,int> &pair1)
{
return pair1.second<=100;
}
bool PredTF(const pair<int,int>& pair1,int articleId)
{
return pair1.first==articleId;
}
class PredTFclass
{
private: const int m;
public:
PredTFclass(int id):m(id){};
bool operator()(const pair<int,int>& pair1){return PredTF(pair1,m);};
};
bool myCmp(const pair<string,double>&pair1,const pair<string,double>&pair2 )
{
return pair1.second>=pair2.second;
}
void Preprocess:: trim(string &str,const string val)
{
str.erase(0,str.find_first_not_of(val));
str.erase(str.find_last_not_of(val)+val.size());
}
以及其他在.h中声明的函数
意思是说在 Preprocess::ConstructMap 函数中引用了 MakeStopSet(void) 函数,而编译器不知道MakeStopSet(void) 是个啥东西.