Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译test_case.cpp时头文件出错 #20

Open
hellopiece opened this issue May 7, 2017 · 7 comments
Open

编译test_case.cpp时头文件出错 #20

hellopiece opened this issue May 7, 2017 · 7 comments

Comments

@hellopiece
Copy link

hellopiece commented May 7, 2017

图片上传不了,直接贴log了。
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(37): error C2039: “dat”: 不是“thulac::NGramFeature”的成员
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(14): note: 参见“thulac::NGramFeature”的声明
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(62): warning C4018: “<”: 有符号/无符号不匹配
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(66): warning C4018: “<”: 有符号/无符号不匹配
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(67): warning C4018: “<”: 有符号/无符号不匹配
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(128): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(132): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(134): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(136): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(138): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(140): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(142): error C3861: “add_values”: 找不到标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(177): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(177): error C2228: “.base”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(178): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(178): error C2228: “.check”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(179): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(179): error C2228: “.base”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(246): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(246): error C2228: “.check”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(249): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(249): error C2228: “.base”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(250): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(250): error C2228: “.base”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(251): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(251): error C2228: “.check”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(254): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_ngram_feature.h(254): error C2228: “.base”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h : warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(31): error C2061: 语法错误: 标识符“Node”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(37): error C2143: 语法错误: 缺少“)”(在“;”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): error C2146: 语法错误: 缺少“;”(在标识符“best”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): error C3927: "->": 非函数声明符后不允许尾随返回类型
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): error C3484: 语法错误: 返回类型前应为“->”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): error C3613: “->”后缺少返回类型(假定为“int”)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): error C2146: 语法错误: 缺少“;”(在标识符“node_id”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(42): error C2143: 语法错误: 缺少“;”(在“*”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(42): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(42): error C2086: “int Alpha_Beta”: 重定义
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(41): note: 参见“Alpha_Beta”的声明
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C2059: 语法错误:“for”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C2143: 语法错误: 缺少“)”(在“;”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C2143: 语法错误: 缺少“;”(在“<”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C2143: 语法错误: 缺少“;”(在“++”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C2086: “int i”: 重定义
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): note: 参见“i”的声明
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): error C2059: 语法错误:“)”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2059: 语法错误:“for”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2143: 语法错误: 缺少“)”(在“;”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2143: 语法错误: 缺少“;”(在“<”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2086: “int i”: 重定义
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(45): note: 参见“i”的声明
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2143: 语法错误: 缺少“;”(在“++”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2059: 语法错误:“)”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2143: 语法错误: 缺少“;”(在“{”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(46): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(95): error C2059: 语法错误:“}”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(95): error C2143: 语法错误: 缺少“;”(在“}”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(98): error C2059: 语法错误:“while”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(98): error C2143: 语法错误: 缺少“;”(在“{”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(98): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(117): error C2059: 语法错误:“return”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(118): error C2059: 语法错误:“}”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(118): error C2143: 语法错误: 缺少“;”(在“}”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(121): error C2059: 语法错误:“}”
d:\programing\ml\thulac\thulac-master\include\cb_decoder.h(121): error C2143: 语法错误: 缺少“;”(在“}”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(13): error C2143: 语法错误: 缺少“;”(在“{”的前面)
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(13): error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(94): error C2653: “TaggingDecoder”: 不是类或命名空间名称
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(94): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(95): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(95): error C2227: “->separator”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(96): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(96): error C2227: “->max_length”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(97): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(97): error C2227: “->sequence”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(97): error C2227: “->max_length”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(97): error C3078: 必须在新的表达式中指定数组大小
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(98): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(98): error C2227: “->allowed_label_lists”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(98): error C2227: “->max_length”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(98): error C3078: 必须在新的表达式中指定数组大小
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(99): error C2065: “pocs_to_tags”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(101): error C2065: “ngram_feature”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(105): error C2065: “dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(106): error C2065: “is_old_type_dat”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(108): error C2065: “nodes”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(108): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(108): error C2227: “->max_length”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(108): error C3078: 必须在新的表达式中指定数组大小
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(110): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(110): error C2227: “->label_trans”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(111): error C2065: “label_trans_pre”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(112): error C2065: “label_trans_post”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(115): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(115): error C2227: “->tag_size”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(118): error C2355: “this”: 只能在非静态成员函数或非静态数据成员初始值设定项的内部引用
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(118): error C2227: “->model”的左边必须指向类/结构/联合/泛型类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(120): error C2065: “alphas”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(121): error C2065: “betas”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(123): warning C4508: “TaggingDecoder”: 函数应返回一个值;假定“void”返回类型
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(124): error C2653: “TaggingDecoder”: 不是类或命名空间名称
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(124): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(124): error C2084: 函数“int TaggingDecoder(void)”已有主体
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(94): note: 参见“TaggingDecoder”的前一个定义
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(125): error C2065: “sequence”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(125): error C2541: “delete”: 不能删除不是指针的对象
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(126): error C2065: “allowed_label_lists”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(126): error C2541: “delete”: 不能删除不是指针的对象
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(130): error C2065: “max_length”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(131): error C2065: “nodes”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(131): error C2228: “.predecessors”的左边必须有类/结构/联合
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(132): error C2065: “nodes”: 未声明的标识符
d:\programing\ml\thulac\thulac-master\include\cb_tagging_decoder.h(132): error C2228: “.successors”的左边必须有类/结构/联合

@hellopiece
Copy link
Author

实际查看了cb_ngram_feature.h,发现log里显示错误的行数和实际在头文件里的行数不同。例如第一个dat错误,Log里提示37行,实际dat是在36行。

@MaJunhua
Copy link
Collaborator

MaJunhua commented May 8, 2017

感谢您对THULAC的支持。可以提供一下编译环境么,我们在开发环境下确实没有这些错误。另外thulac里并没有thulac_case这个文件或变量,您是指什么?

@hellopiece hellopiece changed the title 使用thulac_case时头文件出错 编译test_case.cpp时头文件出错 May 8, 2017
@hellopiece
Copy link
Author

不好意思,应该是test_case,已修改标题。
编译环境:windows10 Visual Studio 2017 community,debug x86
运行thulac.exe时,输出结果乱码,当输入“我爱北京天安门”时,thulac停止工作。

@MaJunhua
Copy link
Collaborator

MaJunhua commented May 9, 2017

我们的代码开发和测试都是基于Unix/Linux的系统,没有针对windows开发,可能确实在windows上面会有一些问题,您可以试试换到linux上。windows的兼容问题我们会在之后争取解决:)

@hellopiece
Copy link
Author

不过windows上python版本可以用。感谢你们的工作!

@lewiis
Copy link

lewiis commented May 27, 2017

我已在VS 2017上编译通过,开始也出现这些问题,后来经过推敲,发现是编码问题。下载的源文件都是UTF-8编码,但是如果其中有中文字符(包括注释中的),VS好像识别不了,于是就出现各种问题。解决的方法:
1)删除所有中文内容,包括注释。
或者
2)将源文件重新存为UTF-8有签名(UTF-8 with BOM),或者UTF-16。
另外,test_case.cpp中的测试用例无法通过,原因也是编码。因为其中含有中文,如
test.testEqual("我爱北京天安门", "我 爱 北京 天安门");
必须存为非UTF-8格式才能编译,但是这个算法目前好像不支持非UTF-8。
不过可以从文件中读取文本来进行分词,已经测试通过。
编码确实是个坑,希望thulac支持更多的编码。谢谢你们的工作!

@MaJunhua
Copy link
Collaborator

非常感谢反馈!windows的编码问题我们会提上日程解决~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants