Question

Does anyone know of a good dictionary API or ruby library to lookup the definitions of words?

I'm thinking it should work something like:

  1. I call get_definition(word)
  2. It returns the definition for that word (ideally in some way to easily format the definition for display.

Thanks

Was it helpful?

Solution

Ruby-WordNet sounds like it does what you're looking for:

Ruby-WordNet is a Ruby interface to the WordNet® Lexical Database. WordNet is an online lexical reference system whose design is inspired by current psycholinguistic theories of human lexical memory. English nouns, verbs, adjectives and adverbs are organized into synonym sets, each representing one underlying lexical concept. Different relations link the synonym sets.

OTHER TIPS

Wordnik.com has several word-info APIs, including a definitions API. More info is here: http://developer.wordnik.com/

[I work for Wordnik. We will have more APIs soon, let us know what you want!]

I discovered a webservice for this yesterday.

Go to the British Council homepage and double click on any word (that isn't already a hyperlink).

This should open a popup window with a Cambridge Dictionary definition in it. The API is relatively simple (and it is a public API, I checked it yesterday):

http://dictionary.cambridge.org/learnenglish/results.asp?searchword=SEARCH_PHRASE&dict=L

For reference, here's the code they use to launch this on double-click:

/* 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');
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top