Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
因此,我无法从 Wordnet::SenseRelate 调用函数,因为文本中的某些“单词”不是有效查询。我试过用 try 和 catch 包围,这样程序就不会退出并跳过它,但没有运气。我想通过使用 Wordnet::QueryData 检查一个词是否有效,但是当我使用无效词时它会退出,例如:
$wn->querySense("#44");
我得到:
(querySense) Bad query string: #44
可以在语句中找到使用的正则表达式:
my ($word, $pos, $sense) = $string =~ /^([^\#]+)(?:\#([^\#]+)(?:\#(\d+))?)?$/;
如果不确定令牌是否会被接受,请对照此正则表达式对其进行测试。
评论特定问题时,不能有任何前导或尾随 # 字符(遇到的问题)。如果存在 # 个字符,则查询字符串中可以有 1 个或 2 个,但不能超过 2 个。# 字符如果作为分隔符出现,以确定什么是单词、什么是 pos 和什么是有义的。