https://github.com/ysugimoto/go-kakasi
C binding library of kakasi.
https://github.com/ysugimoto/go-kakasi
go kakasi
Last synced: 6 months ago
JSON representation
C binding library of kakasi.
- Host: GitHub
- URL: https://github.com/ysugimoto/go-kakasi
- Owner: ysugimoto
- Created: 2021-01-24T03:54:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-11T09:52:43.000Z (about 3 years ago)
- Last Synced: 2025-04-28T11:13:19.599Z (6 months ago)
- Topics: go, kakasi
- Language: Go
- Homepage:
- Size: 2.38 MB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-kakasi
go-kakasi is a C binding library of [kakasi](http://kakasi.namazu.org/index.html.en).
Just wraps pre-built library, you can use kakasi in your Go program.## Requirements
- Go: We built with `1.16beta1`, I appreciate if you can ensure it's be able to build with older version :-)
- gcc## Usage
This package bundles prebuilt static library, therefore you don't worry what cgo does:
```Go
package mainimport (
"log"
"github.com/ysugimoto/go-kakasi"
)func main() {
text := "日本語"
transformed, err := kakasi.Transform(text, kakasi.WithKanji(kakasi.ASCII))
if err != nil {
log.Fatalln(err)
}
log.Printf("Transformed: %s -> %s\n", text, transformed)
}
```## Customize / Transform Options
go-kakasi accepts transform option as `kakasi.WithXXX` which corresponds to original kakasi transformation mode.
| Option | Accept Character | remarks |
| :----------------------------- | :-------------------------------------------------------------------------------------- | :------------------------------------------------------ |
| WithWakatigaki() | - | Enable wakatigaki mode |
| WithCapitalize() | - | Enable Capitalize mode, only enables -Ja or -Jj option) |
| WithUppercase() | - | Enable Upcase mode, only enables -Ja or -Jj option) |
| WithFurigana | - | Enable Furigana mode. |
| WithHiragana(Character) | kakasi.ASCII, kakasi.JISROMAN, kakasi.KatakanaJIS0201, kakasi.Katakana | Set Hiragana transformation mode. |
| WithKatakana(Character) | kakasi.ASCII, kakasi.JISROMAN, kakasi.KatakanaJIS0201, kakasi.Hiragana | Set Katakana transformation mode. |
| WithKatakanaJIS0201(Character) | kakasi.ASCII, kakasi.JISROMAN, kakasi.Katakana, kakasi.Hiragana | Set KatakanaJIS0201 transformation mode. |
| WithKanji(Character) | kakasi.ASCII, kakasi.JISROMAN, kakasi.KatakanaJIS0201, kakasi.Katakana, kakasi.Hiragana | Set Kanji transformation mode. |
| WithASCII(Character) | kakasi.JISROMAN, kakasi.Sign | Set ASCII transformation mode. |
| WithJISROMAN(Character) | kakasi.ASCII, kakasi.Sign | Set JISROMAN transformation mode. |
| WithGraphic(Character) | kakasi.ASCII, kakasi.JISROMAN, kakasi.Sign | Set Graphic transformation mode. |
| WithSign(Character) | kakasi.ASCII, kakasi.JISROMAN | Set Sign transformation mode. |## Development
Currently, this package uses kakasi stable version of `2.3.6`, build and tested following environments:
- **darwin**: OS X 10.15.7 (Catalina)
- **linux**: Ubuntu 16.04 (Xenial, in docker)
- **linux**: Debian 10 (buster, in CircleCI using go1.15.7)If you want to build kakasi for your environment, You can rebuilt static library as following:
```shell
git checkout https://github.com/ysugimoto/go-kakasi
cd go-kakasi
# Build kakasi in your environment
make all
# Note that if you're linux, it will be overriden `deps/linux/*` files.
```I appreciate it you let me know some other environment also works fine (especially Windows!)
## License
GNU General Public License, vesion 2
https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html## Author
Yoshiaki Sugimoto
And, very thanks for kakasi's anthor: Hironobu Takahasi