├── LICENSE ├── README.md └── hira.go /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * The names of its contributors may not be used to endorse or 14 | promote products derived from this software without specific prior 15 | written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hira accepts, as argument text or as standard input, romaji 2 | text. It copies the text to standard output, converting 3 | the text that matches the romaji format to hiragana. 4 | Note that the output may not be accurate because of 5 | false matches and the inability to generate things like 6 | the tsu consonant-extending symbol. 7 | -------------------------------------------------------------------------------- /hira.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Hira accepts, as argument text or as standard input, romaji 7 | text. It copies the text to standard output, converting 8 | the text that matches the romaji format to hiragana. 9 | Note that the output may not be accurate because of 10 | false matches and the inability to generate things like 11 | the tsu consonant-extending symbol. 12 | */ 13 | package main // import "robpike.io/cmd/hira" 14 | 15 | import ( 16 | "fmt" 17 | "io" 18 | "log" 19 | "os" 20 | "strings" 21 | 22 | "robpike.io/nihongo" 23 | ) 24 | 25 | func main() { 26 | if len(os.Args) == 1 { 27 | _, err := io.Copy(os.Stdout, nihongo.HiraganaReader(os.Stdin)) 28 | if err != nil { 29 | log.Fatal(err) 30 | } 31 | return 32 | } 33 | text := nihongo.HiraganaString(strings.Join(os.Args[1:], " ")) 34 | fmt.Printf("%s\n", text) 35 | } 36 | --------------------------------------------------------------------------------