GithubHelp home page GithubHelp logo

atomicmeganerd / pinyin_tone_marks Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 54 KB

This is a Rust program which converts pinyin with numbers like ni3hao3 to pinyin with tone marks

Rust 94.39% Dockerfile 2.59% Nix 3.02%

pinyin_tone_marks's Introduction

Rust Pinyin Tone Mark Converter

Rust

Introduction

This Rust program will take a source text file with numerical Pinyin markup (Ni3 hao3) and it will convert it to use the proper Pinyin tone marks (Nǐ Hǎo).

The rules for writing the source documents are very simple: For the pinyin corresponding to each character put a number from 1-4 following it for the tone. Ignore the neutral tone. Use v for ü.

Source Pinyin Examples

  • 你好(nǐhǎo) you would write: ni3hao3.
  • 现在让我们都考虑一下(Xiànzài ràng wǒmen dōu kǎolǜ yíxià) write: Xian4zai4 rang4 wo3men dou1 kao3lv4 yi2xia4 (not the v used for ü).

Installation

The best way to install this is with the Docker container. Run the following:

git clone <REPO>
cd pinyin_tone_marks
docker build -t pinyin_tone_marks:latest .

Running

Run with docker. Use a bind mount to link your local directory with /data and then use the paths /data/INPUT.md and /data/OUTPUT.md so the container knows where to find the files inside the bind mount.

docker run -v "$PWD:/data" -t pinyin_tone_marks:latest /data/input.md /data/output.md
  • In this example input.md is the input file which must exist in your current directory. This is the source file that contains the text with the pinyin tone numbers.
  • The file output.md does not need to exist, it will be created. It will be overwritten if it is present. This is the output file that will contain the text after it has been converted to use tone marks.

Acknowledgements

This is inspired by the Pinyin Joe macros for Word and Excel, though I totally designed this implementation myself and did not even examine the source code for those macros as this was a programming challenge I wanted to do for fun:

https://www.pinyinjoe.com/pinyin/pinyin_macro_faq.htm

pinyin_tone_marks's People

Contributors

atomicmeganerd avatar

Watchers

 avatar  avatar  avatar

pinyin_tone_marks's Issues

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.