From 8c212739b11c0aa77dbc329a34ec7d8c83024c7f Mon Sep 17 00:00:00 2001 From: deelawn Date: Wed, 12 Jul 2023 19:27:55 +0200 Subject: [PATCH] Readme and slight logic change --- README.md | 40 +++++++++++++++++++++++++++++++++++++++- kana.go | 2 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e6607dc..f403220 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,42 @@ # WanaKana [![godoc](https://godoc.org/github.com/deelawn/wanakana?status.svg)](https://godoc.org/github.com/deelawn/wanakana) [![Coverage Status](https://coveralls.io/repos/github/deelawn/wanakana/badge.svg)](https://coveralls.io/github/deelawn/wanakana) -[![Go Report Card](https://goreportcard.com/badge/github.com/deelawn/wanakana)](https://goreportcard.com/report/github.com/deelawn/wanakana) \ No newline at end of file +[![Go Report Card](https://goreportcard.com/badge/github.com/deelawn/wanakana)](https://goreportcard.com/report/github.com/deelawn/wanakana) + +This repo is a port of Wanikani's JS implementation located [here](https://github.com/WaniKani/WanaKana). + +No errors are returned by any of the exported functions or methods; this is to keep the behavior the same as the original implementation, but there is an argument to be made to change this. + +## Improvements +If anyone would like to make a PR to improve this repository, here are a few suggestions regarding what could be done: +[] Improve tree caching -- currently only one tree can be stored in the cache and it is not modifiable +[] Add a wasm compilation target and add support for binding and unbinding an element similar to what the original implementation is capable of +[] Move the tree generation logic into a `generate` package. Running `go generate` should generate source code with the `go:embed` directive along with all of the key/value pairs to store in the tree. This makes it more transparent as to what each tree contains by default rather than having to decipher how it is being generated. + +## Usage +Here is an example of how this package can be used: +``` go +package main + +import ( + "fmt" + + "github.com/deelawn/wanakana" + "github.com/deelawn/wanakana/config" +) + +func main() { + + romaji := "okonomiyakinikuman" + options := config.Options{ + IMEMode: config.ToKanaMethodKatakana, + } + + kana := wanakana.ToKana(romaji, options, nil) + + fmt.Println(kana) +} + +``` + +This produces `オコノミヤキニクマン` diff --git a/kana.go b/kana.go index efcce51..5665d2b 100644 --- a/kana.go +++ b/kana.go @@ -37,7 +37,7 @@ func ToKana(input string, options config.Options, treeMap *tree.Map) string { tokens := transform.ToKanaToken( []rune(strings.ToLower(input)), treeMap, - !(options.IMEMode == config.ToKanaMethodNone), + options.IMEMode != config.ToKanaMethodNone, ) var result string