Git Product home page Git Product logo

hanja's Introduction

hanja: 한자-한글 변환 라이브러리

한자-한글 변환기에서 사용되는 모듈입니다.

Installation

pip install hanja

Usage

필요한 모듈 import 하기

>>> from hanja import hanja, hangul

한글 초성, 중성, 종성 분리

>>> hangul.separate(u'가') (0, 0, 0) >>> hangul.separate(u'까') (1, 0, 0)

튜플(tuple)의 마지막 원소가 0이면 종성이 없는 글자라고 판단할 수 있다.

>>> hangul.separate(u'한') (18, 0, 4)

'ㅎ'은 19번째 자음, 'ㅏ'는 첫번째 모음, 'ㄴ'은 다섯번째 자음이라는 것을 알 수 있다.

초성, 중성, 종성을 조합하여 한 글자를 만듦

>>> hangul.build(0, 0, 0) u'uac00' >>> print Hangul.build(0, 0, 0) 가

주어진 글자가 한글인지의 여부를 판별

>>> hangul.is_hangul(u'가') True >>> hangul.is_hangul(u'a') False

한글로 된 부분과 한자로 된 부분을 분리

리스트가 아닌 제네레이터(generator)를 반환한다.

>>> '은 이다.

>>> [x for x in hanja.split_hanja(u'大韓民國은 **共和國이다.')] [u'u5927u97d3u6c11u570b', u'uc740 ', u'u6c11u4e3bu5171u548cu570b', u'uc774ub2e4.']

주어진 글자가 한자인지의 여부를 판별

>>> hanja.is_hanja(u'韓') True

>>> hanja.is_hanja(u'한') False

문장 변환

치환 모드 변환:

>>> hanja.translate(u'大韓民國은 **共和國이다.', 'substitution') 대한민국은 민주공화국이다.

혼용 모드 변환:

>>> hanja.translate(u'大韓民國은 **共和國이다.', 'combination') <span class="hanja">大韓民國</span><span class="hangul">(대한민국)</span>은 <span class="hanja">**共和國</span><span class="hangul">(민주공화국)</span>이다.

hanja's People

Contributors

suminb avatar futurulus avatar dahlia avatar

Watchers

Jihui Choi avatar James Cloos 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.