用于英语单词复数形式的 Java API
是否有任何 Java API 可以提供英语单词的复数形式(例如 cacti
表示 cactus
)?
Are there any Java API(s) which will provide plural form of English words (e.g. cacti
for cactus
)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
很难找到这样的API。相反,您需要找到一些可以满足您的目的的网络服务。检查此。我不确定这是否可以帮助你..
(我试图将“仙人掌”这个词放在响应中的某个地方并得到“仙人掌”)。
Its hard to find this kind of API. rather you need to find out some websservice which can serve your purpose. Check this. I am not sure if this can help you..
(I tried to put word cacti and got cactus somewhere in the response).
如果您可以利用 javascript,我为此创建了一个轻量级 (7.19 KB) javascript。或者您可以将我的脚本移植到 Java。非常容易使用:
https://github.com/rhroyston/pluralizer-js
顺便说一句:看起来仙人掌到仙人掌是一个超级特殊的转换(无论如何大多数人都会说“1个仙人掌”)。如果您愿意,可以轻松添加。源代码易于阅读/更新。
If you can harness javascript, I created a lightweight (7.19 KB) javascript for this. Or you could port my script over to Java. Very easy to use:
https://github.com/rhroyston/pluralizer-js
BTW: It looks like cacti to cactus is a super special conversion (most ppl are going to say '1 cactus' anyway). Easy to add that if you want to. The source code is easy to read / update.
Wolfram|Alpha 返回给定单词的变形形式列表。
以此为例:
http://www.wolframalpha.com/ input/?i=word+cactus+inflected+forms
这是他们的 API:
http://products.wolframalpha.com/api/
Wolfram|Alpha return a list of inflection forms for a given word.
See this as an example:
http://www.wolframalpha.com/input/?i=word+cactus+inflected+forms
And here is their API:
http://products.wolframalpha.com/api/
查看Evo Inflector,它基于 Damian Conway 论文“< a href="http://users.monash.edu/~damian/papers/HTML/Plurals.html" rel="noreferrer">英语复数化的算法方法”。
该库根据维基词典的数据进行了测试,报告 1000 个最常用的英语单词的成功率为 100%,维基词典中列出的所有单词的成功率为 70%。
如果您想要更高的准确性,您可以获取维基词典转储并解析它以创建单数到复数映射的数据库。请考虑到,由于维基词典的开放性,其中的某些数据可能不正确。
用法示例:
Check Evo Inflector which implements English pluralization algorithm based on Damian Conway paper "An Algorithmic Approach to English Pluralization".
The library is tested against data from Wiktionary and reports 100% success rate for 1000 most used English words and 70% success rate for all the words listed in Wiktionary.
If you want even more accuracy you can take Wiktionary dump and parse it to create the database of singular to plural mappings. Take into account that due to the open nature of Wiktionary some data there might by incorrect.
Example Usage:
jibx-tools 提供了方便的复数/反复数器。
常规测试:
jibx-tools provides a convenient pluralizer/depluralizer.
Groovy test:
我知道 Ruby on Rails 中有一个简单的pluralize()函数,也许你可以通过JRuby得到它。这个问题确实不容易,我看到了几页关于如何复数的规则,但它甚至不完整。有些规则不是算法的 - 它们取决于词干起源等,而这不容易获得。所以你必须决定你想要变得多么完美。
I know there is simple pluralize() function in Ruby on Rails, maybe you could get that through JRuby. The problem really isn't easy, I saw pages of rules on how to pluralize and it wasn't even complete. Some rules are not algorithmic - they depend on stem origin etc. which isn't easily obtained. So you have to decide how perfect you want to be.
考虑到 java,请查看 modeshapes Inflector-Class 作为包 org.modeshape 的成员。 common.text。或者谷歌搜索“inflector”和“randall hauch”。
considering java, have a look at modeshapes Inflector-Class as member of the package org.modeshape.common.text. Or google for "inflector" and "randall hauch".