Skip to content

Commit

Permalink
Auto merge of mozillazg#31 - mozillazg:develop, r=mozillazg
Browse files Browse the repository at this point in the history
v0.13.0
  • Loading branch information
bors-homu committed Apr 29, 2018
2 parents ff1ea6f + 8c9f2aa commit d5b7945
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 143 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "tools/pinyin-data"]
path = tools/pinyin-data
[submodule "_tools/pinyin-data"]
path = _tools/pinyin-data
url = https://github.com/mozillazg/pinyin-data.git
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
language: go
go:
- 1.2
- 1.3
- 1.4
- 1.5
- 1.6
- 1.7
- tip
- '1.2'
- '1.3'
- '1.4'
- '1.5'
- '1.6'
- '1.7'
- '1.8'
- '1.9'
- '1.10'
- 'master'

sudo: false

Expand All @@ -18,7 +21,11 @@ before_install:

script:
- go run pinyin/main.go abc
- go run pinyin/main.go -s Normal abc
- go run pinyin/main.go -s zhao abc
- echo "abc" | go run pinyin/main.go
- echo "abc" > abc.txt && go run pinyin/main.go < abc.txt
- $HOME/gopath/bin/goveralls -service=travis-ci -v -package .

matrix:
allow_failures:
- go: master
65 changes: 52 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# Changelog


## 0.12.0 (2017-04-25)
## [0.13.0] (2018-04-29)

* **Changed** 使用 [pinyin-data][pinyin-data] v0.5.1 的拼音数据 (via [#30])
* **Changed** 修改命令行工具 `-s` 参数的值(thanks [@wdscxsj][@wdscxsj] via [#19][#19]):
* `Normal` 改为 `zhao`
* `Tone` 改为 `zh4ao`
* `Tone2` 改为 `zha4o`
* `Tone3` 改为 `zhao4`
* `Initials` 改为 `zh`
* `FirstLetter` 改为 `z`
* `Finals` 改为 `ao`
* `FinalsTone` 改为 `4ao`
* `FinalsTone2` 改为 `a4o`
* `FinalsTone3` 改为 `ao4`
* **Changed** 严格限制命令行参数中 `-s` 选项的值(thanks [@wdscxsj][@wdscxsj] via [#20][#20]):


## [0.12.0] (2017-04-25)


* **NEW** 命令行程序支持通过 -s 指定新增的 `Tone3``FinalsTone3` 拼音风格
Expand All @@ -15,7 +32,7 @@
* **Changed** use [pinyin-data](https://github.com/mozillazg/pinyin-data) v0.4.1


## 0.11.0 (2016-10-28)
## [0.11.0] (2016-10-28)

* **Changed** 不再使用 `0` 表示轻声(因为之前并没有正确的实现这个功能, 同时也觉得这个功能没必要)。
顺便修复了 Tone2 中 `ü` 标轻声的问题(像 `侵略 -> qi1n lv0e4`
Expand All @@ -33,12 +50,12 @@



## 0.10.0 (2016-10-18)
## [0.10.0] (2016-10-18)

* **Changed** use [pinyin-data](https://github.com/mozillazg/pinyin-data) v0.4.0


## 0.9.0 (2016-09-04):
## [0.9.0] (2016-09-04):

* **NEW** 新增 `func Convert(s string, a *Args) [][]string`
* **NEW** 新增 `func LazyConvert(s string, a *Args) []string`
Expand All @@ -47,20 +64,20 @@



## 0.8.0 (2016-08-19)
## [0.8.0] (2016-08-19)

* **Changed** use [pinyin-data](https://github.com/mozillazg/pinyin-data) v0.3.0
* Fixed [#13](https://github.com/mozillazg/go-pinyin/issues/13) . thanks [@aisq2008](https://github.com/aisq2008)
* Fixed pinyin of 罗


## 0.7.0 (2016-08-02)
## [0.7.0] (2016-08-02)

* **Changed** use [pinyin-data](https://github.com/mozillazg/pinyin-data) v0.2.0
* **Improved** golint and gofmt


## 0.6.0 (2016-05-14)
## [0.6.0] (2016-05-14)

* **NEW** 命令行程序支持指定拼音风格:

Expand All @@ -86,7 +103,7 @@



## 0.5.0 (2016-03-12)
## [0.5.0] (2016-03-12)

* **CHANGE** 改为使用来自 [pinyin-data](https://github.com/mozillazg/pinyin-data) 的拼音数据。
* **NEW** 命令行程序支持从标准输入读取数据(支持管道和重定向输入):
Expand All @@ -99,7 +116,7 @@
```


## 0.4.0 (2016-01-29)
## [0.4.0] (2016-01-29)

* **NEW** `Args` 结构体新增 field: `Fallback func(r rune, a Args) []string`
用于处理没有拼音的字符(默认忽略没有拼音的字符):
Expand All @@ -120,7 +137,7 @@
```
## 0.3.0 (2015-12-29)
## [0.3.0] (2015-12-29)
* fix "当字符串中有非中文的时候,会出现下标越界的情况"(影响 `pinyin.LazyPinyin``pinyin.Slug` ([#1](https://github.com/mozillazg/go-pinyin/issues/1)))
* 调整对非中文字符的处理:当遇到没有拼音的字符时,直接忽略
Expand All @@ -135,12 +152,12 @@
```
## 0.2.1 (2015-08-26)
## [0.2.1] (2015-08-26)
* `yu`, `y`, `w` 不是声母
## 0.2.0 (2015-01-04)
## [0.2.0] (2015-01-04)
* 新增 `func NewArgs() Args`
* 解决 `Args.Separator` 无法赋值为 `""` 的 BUG
Expand All @@ -154,9 +171,31 @@
* `FINALS_TONE` -> `FinalsTone`
* `FINALS_TONE2` -> `FinalsTone2`
## 0.1.1 (2014-12-07)
## [0.1.1] (2014-12-07)
* 更新拼音库
## 0.1.0 (2014-11-23)
* Initial Release
[pinyin-data]: https://github.com/mozillazg/pinyin-data
[@wdscxsj]: https://github.com/wdscxsj
[#19]: https://github.com/mozillazg/go-pinyin/pull/19
[#20]: https://github.com/mozillazg/go-pinyin/pull/20
[#30]: https://github.com/mozillazg/go-pinyin/pull/30
[0.1.1]: https://github.com/mozillazg/go-pinyin/compare/v0.1.0...v0.1.1
[0.2.0]: https://github.com/mozillazg/go-pinyin/compare/v0.1.1...v0.2.0
[0.2.1]: https://github.com/mozillazg/go-pinyin/compare/v0.2.0...v0.2.1
[0.3.0]: https://github.com/mozillazg/go-pinyin/compare/v0.2.1...v0.3.0
[0.4.0]: https://github.com/mozillazg/go-pinyin/compare/v0.3.0...v0.4.0
[0.5.0]: https://github.com/mozillazg/go-pinyin/compare/v0.4.0...v0.5.0
[0.6.0]: https://github.com/mozillazg/go-pinyin/compare/v0.5.0...v0.6.0
[0.7.0]: https://github.com/mozillazg/go-pinyin/compare/v0.6.0...v0.7.0
[0.8.0]: https://github.com/mozillazg/go-pinyin/compare/v0.7.0...v0.8.0
[0.9.0]: https://github.com/mozillazg/go-pinyin/compare/v0.8.0...v0.9.0
[0.10.0]: https://github.com/mozillazg/go-pinyin/compare/v0.9.0...v0.10.0
[0.11.0]: https://github.com/mozillazg/go-pinyin/compare/v0.10.0...v0.11.0
[0.12.0]: https://github.com/mozillazg/go-pinyin/compare/v0.11.0...v0.12.0
[0.13.0]: https://github.com/mozillazg/go-pinyin/compare/v0.12.0...v0.13.0
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ test:

.PHONY: gen_pinyin_dict
gen_pinyin_dict:
@go run tools/gen_pinyin_dict.go tools/pinyin-data/pinyin.txt pinyin_dict.go
@go run _tools/gen_pinyin_dict.go _tools/pinyin-data/pinyin.txt pinyin_dict.go

.PHONY: lint
lint:
gofmt -s -w . pinyin tools
gofmt -s -w . pinyin _tools
golint .
golint pinyin
golint tools
golint _tools
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ Related Projects
* [mozillazg/rust-pinyin](https://github.com/mozillazg/rust-pinyin): 汉语拼音转换工具 Rust 版。


pinyin data
-----------------

* 使用 [pinyin-data](https://github.com/mozillazg/pinyin-data) 的拼音数据


License
---------

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions _tools/pinyin-data
Submodule pinyin-data added at 28b94c
2 changes: 1 addition & 1 deletion pinyin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// Meta
const (
Version = "0.12.0"
Version = "0.13.0"
Author = "mozillazg, 闲耘"
License = "MIT"
Copyright = "Copyright (c) 2016 mozillazg, 闲耘"
Expand Down
43 changes: 20 additions & 23 deletions pinyin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func main() {
heteronym := flag.Bool("e", false, "启用多音字模式")
style := flag.String("s", "Tone", "指定拼音风格。可选值:Normal, Tone, Tone2, Tone3, Initials, FirstLetter, Finals, FinalsTone, FinalsTone2, FinalsTone3")
style := flag.String("s", "zh4ao", "指定拼音风格。可选值:zhao, zh4ao, zha4o, zhao4, zh, z, ao, 4ao, a4o, ao4")
flag.Parse()
hans := flag.Args()
stdin := []byte{}
Expand All @@ -25,35 +25,32 @@ func main() {
}

if len(hans) == 0 {
fmt.Println("请至少输入一个汉字: pinyin [-e] [-s STYLE] HANS [HANS ...]")
fmt.Fprintln(os.Stderr, "请至少输入一个汉字: pinyin [-e] [-s STYLE] HANS [HANS ...]")
os.Exit(1)
}

args := pinyin.NewArgs()
if *heteronym {
args.Heteronym = true
}
switch *style {
case "Normal":
args.Style = pinyin.Normal
case "Tone2":
args.Style = pinyin.Tone2
case "Tone3":
args.Style = pinyin.Tone3
case "Initials":
args.Style = pinyin.Initials
case "FirstLetter":
args.Style = pinyin.FirstLetter
case "Finals":
args.Style = pinyin.Finals
case "FinalsTone":
args.Style = pinyin.FinalsTone
case "FinalsTone2":
args.Style = pinyin.FinalsTone2
case "FinalsTone3":
args.Style = pinyin.FinalsTone3
default:
args.Style = pinyin.Tone

styleValues := map[string]int{
"zhao": pinyin.Normal,
"zh4ao": pinyin.Tone,
"zha4o": pinyin.Tone2,
"zhao4": pinyin.Tone3,
"zh": pinyin.Initials,
"z": pinyin.FirstLetter,
"ao": pinyin.Finals,
"4ao": pinyin.FinalsTone,
"a4o": pinyin.FinalsTone2,
"ao4": pinyin.FinalsTone3,
}
if value, ok := styleValues[*style]; !ok {
fmt.Fprintf(os.Stderr, "无效的拼音风格:%s\n", *style)
os.Exit(1)
} else {
args.Style = value
}

pys := pinyin.Pinyin(strings.Join(hans, ""), args)
Expand Down
Loading

0 comments on commit d5b7945

Please sign in to comment.