如何匹配时态或形式的单词? [英] How can I match words regardless of tense or form?

查看:129
本文介绍了如何匹配时态或形式的单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在处理一个贯穿文档的脚本,提取所有关键字,然后尝试将这些关键字与其他文档中找到的关键字进行匹配.有一些细节使这一点变得复杂,但是它们与我的问题不是很相关.基本上,我希望能够匹配单词,而不考虑它们出现的时态.

I am currently working on a script that runs through a document, pulls out all keywords, and then attempts to match these keywords with those found in other documents. There are some specifics that complicate this, but they are not very pertinent to me question. Basically I would like to be able to match words regardless of the tense in which they appear.

例如:如果给定字符串"swim","swam"和"swimming",我希望有一个程序可以识别这些都是相同的单词,尽管它是否会将单词存储为swim,swim或游泳对我来说并不重要.

For example: If given the strings "swim", "swam", and "swimming", I would like a program that can recognize that these are all the same word, though whether it would store the word as swim, swam or swimming doesn't matter all that much to me.

我知道可以通过包含所有这些单词形式的字典来解决此问题,但是我不知道以这种方式映射的任何字典对此都非常有用.我更喜欢与Python兼容的解决方案或库,因为这是我目前用于此脚本编写的内容,但是我可以使用几乎任何语言的解决方案(保存haskell或eiffel或类似的晦涩难懂的语言)都可以与之合作)

I'm aware that this problem could be mostly solved with a dictionary containing all of these word forms, but I am unaware of any dictionary that is mapped in such a way to be useful for this. I would prefer a solution or library that is compatible with Python, since that is what I am currently using for this scripting, but I would be fine with a solution in just about any language (save haskell or eiffel or something similarly obscure/difficult to work with)

推荐答案

查看 pywordnet .

>>> N['dog']
dog(n.)
>>> N['dog'].getSenses()
('dog' in {noun: dog, domestic dog, Canis familiaris},
 'dog' in {noun: frump, dog}, 'dog' in {noun: dog},
 'dog' in {noun: cad, bounder, blackguard, dog, hound, heel},
 'dog' in {noun: pawl, detent, click, dog},
 'dog' in {noun: andiron, firedog, dog, dogiron})

这篇关于如何匹配时态或形式的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆