CoreNLP Tokensregex错误,运算符“+”出错,

bwleehnv  于 2个月前  发布在  其他
关注(0)|答案(1)|浏览(30)

你好,
我在尝试使用tokensregex语法时遇到了这个错误。* 版本 4.4.0

  • 示例有效模式:the very* first? day of the tentacle

  • 示例失败模式:the very* first? day+ of the tentacle

似乎在处理过程中的某个时刻,+ 字符被转义为 \+ (参见错误截图)。
如果我尝试使用模式 the very* first? day{1,} of the tentacle,它按预期工作。
我还尝试使用版本4.4.0的CoreNLP Java库解析相同的模式,它在使用 "+" 运算符时没有错误。

String strPattern = "the very* first? day+ of the tentacle";
		
TokenSequenceParser parser = new TokenSequenceParser();
Env env = new Env(parser);
env.initDefaultBindings();
Pair<PatternExpr, SequenceMatchAction<CoreMap>> p = parser.parseSequenceWithAction(env, strPattern);

// => works without error !

我不知道问题是否仅存在于 http://corenlp.run/ 在线测试器上,还是在我没有尝试过的Java库中。

f45qwnt8

f45qwnt81#

我尽量避免在可以的情况下学习关于Javascript的知识,但是在服务器的.js文件中,这个看起来对我来说是不正确的:url: serverAddress + '/tokensregex?pattern=' + encodeURIComponent( pattern.replace("&", "\&").replace('+', '+')) + I本以为用encodeURIComponent对pattern进行编码的整个目的是转义所有特殊字符,所以不需要对+和&进行第二次转义。无论如何,服务器没有对我能看到的内容进行双重解码,所以模式会被解释为带有\的字符串,而不是正确地运行。 8413fa1...

周四,2022年3月3日,凌晨2点55分,PERANI Julien @**.**>写道:嗨,我在尝试使用tokensregex语法时遇到了这个错误 - 版本4.4.0 - 一个有效模式的例子:the very first? day of the tentacle [image: image] < http://corenlp.run/ > - 一个失败模式的例子:the very first? day+ of the tentacle [image: image] < https://user-images.githubusercontent.com/4158840/156548894-b3202305-c95d-42b6-ba48-8aadcecf557b.png >。似乎在处理过程中某个时刻+字符被转义为+(参见错误截图)。如果我尝试使用模式the very first? day{1,} of the tentacle,它按预期工作。我还尝试使用版本4.4.0的CoreNLP Java库解析相同的模式,它在使用"+"运算符时没有错误。String strPattern = "the very* first? day+ of the tentacle"; TokenSequenceParser parser = new TokenSequenceParser();Env env = new Env(parser); env.initDefaultBindings();Pair<PatternExpr, SequenceMatchAction> p = parser.parseSequenceWithAction(env, strPattern); // => 没有错误!我不知道问题是否只存在于https://user-images.githubusercontent.com/4158840/156549050-5ec6ab19-9f67-4d48-a5c0-9687e5590ab8.png在线测试器上,还是存在于我尚未尝试过的Java库中。——直接回复此电子邮件,查看GitHub上的<#1256>,或取消订阅< http://corenlp.run/ >。使用GitHub移动端在iOS上进行GitHub通知的优先级通知< https://github.com/notifications/unsubscribe-auth/AA2AYWISIXGLA4MDXI4WLI3U6CLCLANCNFSM5P2DTGMA >或Android< https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 >。您收到此消息是因为您订阅了此线程。Message ID: ***@***.***>

相关问题