ndic

Python module for NAVER English-Korean and Korean-English dictionaries


Keywords
dictionary, translate, English, Korean, Naver
License
MIT
Install
pip install ndic==1.6

Documentation

Ndic

Build Status Coverage Status Pypi Version Downloads Per Month License MIT

Python package for NAVER English-Korean and Korean-English dictionaries

Introduction

Search of both English-Korean and Korean-English dictionaries is provided.

Requirements

Ndic works by crawling the web http://endic.naver.com/. To crawl, it uses Requests and BeautifulSoup.

Therefore, you should use it in Internet Environments.

Ndic supports Python 2.7 & 3.4–3.7 because Requests officially supports these versions.

Installation

Install via pip:

$ pip install ndic

Usage

The usage is very simple.

Begin by importing the Ndic module:

>>> import ndic

Entering an English word as the search function argument will return the corresponding Korean word(s).

>>> ndic.search('apple')
'사과'

Conversely, entering a Korean word as the search function argument will return the corresponding English word(s).

>>> ndic.search('μ•ˆλ…•ν•˜μ„Έμš”')
'Hi!'

If the word you search has multiple meanings, you can choose the meaning of the desired order.

Unless you set any xth value, you will get the first meaning of the word.

>>> ndic.search('말', 1) # 1st meaning
'(μ–Έμ–΄) word, language, speech, (literary) tongue'
>>> ndic.search('말', 2) # 2nd meaning
'(동물) horse'

Phrases may also be searched.

>>> ndic.search('in order to')
'(λͺ©μ ) μœ„ν•˜μ—¬'

Entering a nonexistent word as the search function argument will return the empty string.

>>> ndic.search("aslkjfwe")
''
>>> ndic.search("μ•„λŒœλ¦¬μ•Ό")
''

If your network connection is lost, you will get below error message.

>>> ndic.search('...')
NdicConnectionError: Network connection is lost. Please check the connection to the Internet.

Command Line Interface

Furthermore, Ndic supports CLI(Command Line System).

So you can use it in command line and get the return value of the search fuction in terminals. It works by Click.

$ ndic love
(특히 κ°€μ‘±γƒ»μΉœκ΅¬μ— λŒ€ν•œ) μ‚¬λž‘
$ ndic get --xth 2 # or -x 2
μ–»λ‹€, μž…μˆ˜ν•˜λ‹€; 가지닀(obtain)