题
有没有人知道一个好的词典API或ruby库来查找单词的定义?
我认为它应该像:
- 我打电话给get_definition(word)
- 它返回该单词的定义(理想情况下以某种方式轻松格式化显示的定义。 醇>
由于
解决方案
Ruby-WordNet 听起来像是在寻找您所需要的:
Ruby-WordNet是一个Ruby接口 WordNet®词汇数据库。共发现 是一个在线词汇参考系统 其设计灵感来自当前 人的心理语言学理论 词汇记忆。英语名词,动词, 形容词和副词是有组织的 进入同义词集,每个代表 一个潜在的词汇概念。 不同的关系链接同义词 集。
其他提示
Wordnik.com有几个word-info API,包括定义API。更多信息请访问: http://developer.wordnik.com/
[我为Wordnik工作。我们很快会有更多的API,让我们知道你想要的东西!]
昨天我发现了一个网络服务。
转到英国文化协会主页,然后双击任何字词(不是超链接)。
这应打开一个弹出窗口,其中包含剑桥词典定义。 API相对简单(它是一个公共API,我昨天检查过它):
http://dictionary.cambridge.org/learnenglish/results.asp?searchword=SEARCH_PHRASE&dict=L
供参考,这是他们用来双击启动它的代码:
/* BC double-click pop-up dictionary */
var NS = (navigator.appName == "Netscape" || navigator.product == 'Gecko') ? 1 : 0;
if (NS) document.captureEvents(Event.DBLCLICK);
document.ondblclick = dict;
var dictvar;
function dict() {
if (NS) {
t = document.getSelection();
pass_to_dictionary(t);
} else {
t = document.selection.createRange();
if(document.selection.type == 'Text' && t.text != '') {
document.selection.empty();
pass_to_dictionary(t.text);
}
}
}
function pass_to_dictionary(text) {
//alert(text);
if (text > '') {
window.open('http://dictionary.cambridge.org/learnenglish/results.asp?searchword='+text+ '&dict=L', 'dict_win', 'width=650,height=400,resizable=yes,scrollbars=yes');
}
}
还有dictionary.com的API(几年前)的包装器
http://rubyforge.org/snippet/detail.php?type =代码段和ID = 53个
http://rubyforge.org/snippet/detail.php?type =代码段和ID = 52个
和wiktionary
不隶属于 StackOverflow