Skip to content

Latest commit

 

History

History
66 lines (53 loc) · 2.18 KB

README.md

File metadata and controls

66 lines (53 loc) · 2.18 KB

kanaconv Build Status GoDoc

日本語のひらがなカタカナ、全角半角を変換するパッケージ written in Go

Installation

go get -u github.com/miiton/kanaconv

Usage

import (
    "fmt"
    "github.com/miiton/kanaconv"
)

func main() {
    fmt.Println(kanaconv.HiraganaToKatakana("ひらがなをカタカナに"))
    // ヒラガナヲカタカナニ
    fmt.Println(kanaconv.KatakanaToHiragana("カタカナをひらがなに"))
    // かたかなをひらがなに
    fmt.Println(kanaconv.HankakuToZenkaku("ハンカクヲゼンカクニ"))
    // ハンカクヲゼンカクニ
    fmt.Println(kanaconv.ZenkakuToHankaku("ゼンカクヲハンカクニ"))
    // ゼンカクヲハンカクニ
	fmt.Println(kanaconv.SmartConv("カタカナは全角に統一EISUUJI+=−,記号は半角に統一します"))
    // カタカナは全角に統一EISUUJI+=-,記号は半角に統一します
}

Benchmarks

  • MacBook Air (11-inch, Mid 2011)
% go test -bench .
PASS
BenchmarkHiraganaToKatakana-4    1000000      1657 ns/op
BenchmarkKatakanaToHiragana-4    1000000      1597 ns/op
BenchmarkHankakuToZenkaku-4      1000000      1995 ns/op
BenchmarkZenkakuToHankaku-4      1000000      2008 ns/op
BenchmarkSmartConv-4             1000000      2063 ns/op
ok      github.com/miiton/kanaconv9.450s
  • MacBook Pro (15-inch, 2016)
% go test -bench .
goos: darwin
goarch: amd64
pkg: github.com/miiton/kanaconv
BenchmarkHiraganaToKatakana-8    3000000       533 ns/op
BenchmarkKatakanaToHiragana-8    3000000       519 ns/op
BenchmarkHankakuToZenkaku-8      2000000       795 ns/op
BenchmarkZenkakuToHankaku-8      2000000       709 ns/op
BenchmarkSmartConv-8             2000000       820 ns/op
PASS
ok      github.com/miiton/kanaconv      11.271s

Referenced