Code Monkey home page Code Monkey logo

hanziconv's Introduction

Hanzi Converter 繁簡轉換器 | 繁简转换器

This tool converts between simplified and traditional Chinese Characters. It consists of two parts:

  • a command line tool: hanzi-convert
  • a python library: hanziconv

This module supports both Python 2 and 3

Build Status

Latest Version

Documentation

Source Code

License

Installation

$ pip install hanziconv

Uninstallation

$ [sudo] pip uninstall hanziconv

Command Line Tool

Synopsis

$ ./hanzi-convert --help
usage: hanzi-convert [-h] [-o OUTFILE] [-s] [-v] infile

Simplified and Traditional Chinese Character Conversion
Version 0.3.2 (By Bernard Yue)

Converting to Traditional Hanzi by default with no -s flag

positional arguments:
  infile                filename | "-", corresponds to stdin

optional arguments:
  -h, --help            show this help message and exit
  -o OUTFILE, --output OUTFILE
                        filename to save output, stdout if omitted
  -s, --simplified      convert to simplified characters
  -v, --version         show program's version number and exit

Example

Conversion from stdin

$ ./hanzi-convert -
Press Crtl-D when finished
Typing away
Now write some chinese characters
繁简转换器
^D
Typing away
Now write some chinese characters
繁簡轉換器
$

Python API

Example

>>> from hanziconv import HanziConv
>>> print(HanziConv.toSimplified('繁簡轉換器'))
繁简转换器
>>> print(HanziConv.toTraditional('繁简转换器'))
繁簡轉換器
>>> HanziConv.same('繁簡轉換器', '繁简转换器')
True

Testing

The module uses pytest. Use pip to install pytest.

$ [sudo] pip install pytest

Then checkout source code and run test as normal.

$ git clone https://github.com/berniey/hanziconv
$ cd hanziconv
$ python setup.py test

You are encouraged to use virtualenv and virtualenvwrapper for to avoid changing your currently operating environment.

License

This module is distributed under Apache License Version 2.0.

The character map used in this module is based on the Multi-function Chinese Character Database developed by Chinese University of Hong Kong.

hanziconv's People

Contributors

berniey avatar burntsushi avatar

Watchers

 avatar  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.