본문 바로가기
Programming/Python

[Python] PyDictionary 영어사전, 번역기

by 코딩하는 금융인 2022. 7. 24.

안녕하세요.

파이썬에서 번역기능이 필요할 때 유용한 패키지인 PyDictionary에 대해서 알아보겠습니다.

 

 PyDictionary 모듈 소개 및 활용예시

▣ PyDictionary Module

파이썬2,3 환경에서 의미, 번역, 동의어, 반의어 등을 얻는 사전 모듈 (WordNet, Google-translate, synonym)

- 주요 기능으로 meanings와 translations가 있음

 

▣ PyDictionary Module 사용법

○ 패키지 다운로드(installation) 및 import

pip install PyDictionary

from PyDictionary import PyDictionary

 

○ PyDictionary meanings

<Meanings 딕셔너리 구성>

Noun 명사
Verb 동사
Adverb 부사
Adjective 형용사

 

<실제 활용>

from PyDictionary import PyDictionary

dict = PyDictionary()
  
# meaning of "hate"
meaning = dict.meaning("hate")
print(meaning)

## {'Noun': ['the emotion of intense dislike; a feeling of dislike so strong that it demands action'], 'Verb': ['dislike intensely; feel antipathy or aversion towards']}

# 명사 뽑기
meaning['Noun']
## ['the emotion of intense dislike; a feeling of dislike so strong that it demands action']

# 동사 뽑기
meaning['Verb']
## ['dislike intensely; feel antipathy or aversion towards']
반응형

○ PyDictionary translations

<구글 언어별 코드>

- 자세한 사항은 Google translate Languages를 참조하시면 됩니다.

Language Name Language Code Language Name Language Code
Afrikaans af Romanian ro
Irish ga Esperanto eo
Albanian sq Russian ru
Italian it Estonian et
Arabic ar Serbian sr
Japanese ja Filipino tl
Azerbaijani az Slovak sk
Kannada kn Finnish fi
Basque eu Slovenian sl
Korean ko French fr
Bengali bn Spanish es
Latin la Galician gl
Belarusian be Swahili sw
Latvian lv Georgian ka
Bulgarian bg Swedish sv
Lithuanian lt German de
Catalan ca Tamil ta
Macedonian mk Greek el
Chinese Simplified zh-CN Telugu te
Malay ms Gujarati gu
Chinese Traditional zh-TW Thai th
Maltese mt Haitian Creole ht
Croatian hr Turkish tr
Norwegian no Hebrew iw
Czech cs Ukrainian uk
Persian fa Hindi hi
Danish da Urdu ur
Polish pl Hungarian hu
Dutch nl Vietnamese vi
Portuguese pt Icelandic is
English en Welsh cy
Yiddish yi Indonesian id

 

<실제 활용>

from PyDictionary import PyDictionary

dict = PyDictionary()

# to translate into Korea
translation = dict.translate("sad", 'ko')
print(translation)
## 슬퍼

 

반응형

댓글