https://github.com/zhangsoledad/alchemic_pinyin
Elixir汉字转化拼音
https://github.com/zhangsoledad/alchemic_pinyin
elixir pinyin
Last synced: 7 months ago
JSON representation
Elixir汉字转化拼音
- Host: GitHub
- URL: https://github.com/zhangsoledad/alchemic_pinyin
- Owner: zhangsoledad
- License: mit
- Created: 2016-03-29T05:39:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-07T02:08:03.000Z (about 4 years ago)
- Last Synced: 2025-03-24T00:37:17.099Z (7 months ago)
- Topics: elixir, pinyin
- Language: Elixir
- Homepage: https://hex.pm/packages/alchemic_pinyin
- Size: 194 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# alchemic_pinyin
[](https://travis-ci.org/zhangsoledad/alchemic_pinyin.svg?branch=master)
[](http://inch-ci.org/github/zhangsoledad/alchemic_pinyin)
中文汉字转拼音
>Inspired by [chinese_pinyin](https://github.com/flyerhzm/chinese_pinyin).
## Installation
1. Add pinyin to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:alchemic_pinyin, "~> 0.1.0"}]
end
```
2. Ensure pinyin is started before your application:
```elixir
def application do
[applications: [:alchemic_pinyin]]
end
```
## Usage
```bash
iex> Pinyin.from_string("龡龢龣龤龥癩")
"chui he jue xie yu la"
iex> Pinyin.from_string("龡龢龣龤龥癩", tone: true)
"chùi hé júe xíe yù là"
iex> Pinyin.from_string("龡龢龣龤龥癩", splitter: "-")
"chui-he-jue-xie-yu-la"
iex> Pinyin.from_string("龡龢龣龤龥癩", [], &String.first/1)
"c"
```
## benchmark
```
mix bench
```
OS X
2.7 GHz Intel Core i5
8 GB 1867 MHz DDR3
```bash
Settings:
duration: 1.0 s
BasicBench
[14:01:23] 1/1: hello pinyin
Finished in 4.11 seconds
BasicBench
hello pinyin 500000 6.73 µs/op
```