Giter Site home page Giter Site logo

hanzi.jl's Introduction

Hanzi.jl

Build Status

An open-source library for romanizing Hanzi written in Julia that supports pinyin and Wade-Giles romanization.

Dependencies

This library requires a minimum of Julia 1.0 and does not depend on any external libraries.

Usage

Hanzi.jl exports two functions: pinyin and wadegiles. Both functions expect a string as input and will product a Vector{Vector{String}}, where each Vector{String} are the possible pronunciations for a given Hanzi. By default, only one pronunciation per character will be returned, meaning each Vector{String} will have only one item. Setting the option multiple=true in the function call will return multiple pronunciations for applicable characters. If non-Hanzi characters are encountered adjacent to each other, they will be returned as single-item Vector{String}s.

Usage examples

using Hanzi

Hanzi.pinyin("") # [["qiū"]]
Hanzi.pinyin("", multiple=true) # [["qiū"]]
Hanzi.pinyin("") # [["shì"]]
Hanzi.pinyin("", multiple=true) # [["shì", "tí"]]
Hanzi.pinyin("你好") # [["nǐ"], ["hǎo"]]
Hanzi.pinyin("你好", multiple=true) # [["nǐ"], ["hǎo", "hào"]]
Hanzi.pinyin("我叫John。你呢?") # [["wǒ"], ["jiào"], ["John。"], ["nǐ"], ["ne"], ["?"]]
Hanzi.pinyin("我叫John。你呢?", multiple=true) # [["wǒ"], ["jiào"], ["John。"], ["nǐ"], ["ne", "ní", "nǐ", "nī"], ["?"]]

Hanzi.wadegiles("") # [["ch'iu1"]]
Hanzi.wadegiles("", multiple=true) # [["ch'iu1"]]
Hanzi.wadegiles("") # [["shih4"]]
Hanzi.wadegiles("", multiple=true) # [["shih4", "t'i2"]]
Hanzi.wadegiles("你好") # [["ni3"], ["hao3"]]
Hanzi.wadegiles("你好", multiple=true) # [["ni3"], ["hao3", "hao4"]]
Hanzi.wadegiles("我叫John。你呢?") # [["wo3"], ["chiao4"], ["John。"], ["ni3"], ["ne"], ["?"]]
Hanzi.wadegiles("我叫John。你呢?", multiple=true) # [["wo3"], ["chiao4"], ["John。"], ["ni3"], ["ne", "ni2", "ni3", "ni1"], ["?"]]

Special thanks

Thank you to @mozillazg and the maintainers and contributors of python-pinyin (a similar library for Python) for providing publicly available and MIT-licensed data used in this project.

Project information

This project was started by Nicolas Antonio Cloutier in 2024. There are no additional contributors as of yet. If you have suggestions, issues, or additions, feel free to open an issue or pull request on the GitHub page. This project operates under the MIT license. Licensing information can be found in the file entitled LICENSE in this project's top-level directory.

hanzi.jl's People

Contributors

dependabot[bot] avatar nicoacloutier avatar

Watchers

 avatar

hanzi.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

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.