GithubHelp home page GithubHelp logo

omarkmu / krdict.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fox-islam/krdict.js

0.0 0.0 0.0 157 KB

A node.js module to interact with krdict, the Korean Learners' Dictionary

TypeScript 87.66% JavaScript 12.34%

krdict.js's Introduction

krdict.js

A node.js module to interact with krdict, the Korean Learners' Dictionary, through its API. To use this module you'll need an API key from krdict.

To install the module from npm run:

npm install krdict.js

An example of a basic query with only the required parameters:

const krdict = require('krdict.js');

krDict.setKey(API_KEY);

krdict.dictionarySearch({
    query: '나무',
}).then((response) => {
    console.log(JSON.stringify(response.data));
});

Which would ouput something like this:

{
  "channel": {
    ...
    "item": [
      {
        "word": [ "나무" ],
        "vocabularyGrade": [ "초급" ],
        "partOfSpeech": [ "명사" ],
        ...
        "meaning": [
          {
            "meaningOrder": [ "1" ],
            "definition": [ "단단한 줄기에 가지와 잎이 달린, 여러 해 동안 자라는 식물." ]
          },
          ...
        ]
      },
      ...
    ]
  }
}

Additional parameters can be passed in

const krdict = require('krdict.js');

krdict.setKey(API_KEY);

krdict.dictionarySearch({
    query: '나무',
    sortMethod: 'alphabetical',
    shouldTranslate: true,
    translationLanguage: 'english'
}).then((response) => {
    console.log(JSON.stringify(response.requestParameters));
    console.log(JSON.stringify(response.data));
});

which are mapped to the parameter names and values expected by the krdict API:

{
  "key": "xyz",
  "q": "나무",
  "sort": "dict",
  "translated": "y",
  "trans_lang": 1
}
{
  "channel": {
    ...
    "item": [
        {
            "word": [ "나무" ],
            "vocabularyGrade": [ "초급" ],
            "partOfSpeech": [ "명사" ],
            ...
            "meaning": [
                {
                    "meaningOrder": [ "1" ],
                    "definition": [ "단단한 줄기에 가지와 잎이 달린, 여러 해 동안 자라는 식물." ],
                    "translation": [{
                        "language": [ "영어" ],
                        "word": [ "tree" ],
                        "definition": [ "A plant with a hard stem, branches and leaves." ]
                    }]
                },
                ...
            ]
        },
        ...
    ]
  }
}

You can view a complete list of accepted parameters and their values on the wiki page

krdict.js's People

Contributors

fox-islam avatar omarkmu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.