Home > Uncategorized > English Dictionary API served with MongoDB

English Dictionary API served with MongoDB

As an exercise with the no-SQL database platform MongoDB, I created a free account on mongolabs, created a database called webtropy, and within this, created a collection with the name “dictionary”. I then downloaded a English dictionary in text format from http://www.isc.ro/en/commands/lists.html (TWL06), Importing this into Mongo was mongoimport, specifying fields as “word”.

They offer a REST API via their HTTP interface, such as:

https://api.mongolab.com/api/1/databases/webtropy/collections/dictionary?apiKey=5FdV2ICC_dTrXGyumdVcIaBB2xYztY_n&q={‘word’:’HELLO‘}

Where “HELLO” is the word being checked. If the word is missing, i.e. “HELLOY” then the result is an empty JSON array “[]“

For the full English dictionary in JSON format, you can download this from Box.com at https://www.box.com/s/dvvuv4d6kqet4xbu7nvw

About these ads
Categories: Uncategorized
  1. May 31, 2013 at 12:15 pm | #1

    A use of this dictionary, is a javascript spell-checker:

    <html>
    <head>
    <script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
    <script src="mydictionary.json"></script>
    <style> #result {color:red}</style>
    <script language="javascript">
    $(document).ready(function() {
    $("#btnCheck").bind("click",btnCheck_click);
    });
    function btnCheck_click() {
    var word = $("#tbWord").val().toUpperCase();
    var arrPos = $.inArray(word,dictionary);
    if (arrPos != -1)
    {
    $("#result").text("It's a word!");
    }
    else
    {
    $("#result").text("It's not a word!");
    }
    }
    </script>
    </head>
    <body>
    Is it a word?<br>
    <input id="tbWord" type="text">
    <input type="button" id="btnCheck" value="Check"/><br>
    <span id="result"></span>
    </body>
    </html>

  2. August 6, 2013 at 9:14 am | #2

    I’m now expanding this to include multiple languages using Bing Translate API. Limited to 2 Million chars per month, so it might take some time…

  3. August 15, 2013 at 3:50 pm | #3

    The import was done using mongoimport like this: mongoimport -h ds039078.mongolab.com -d celltower -c celltower
    –type csv –file “C:\Users\Fiach\Desktop\With markers and location.csv” –head
    erline -u fiach -p xxxxxxx –port 39078

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: