Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikeikeikeike/exkanji
A Elixir library for translating between hiragana, katakana, romaji, kanji and sound. It uses Mecab.
https://github.com/ikeikeikeike/exkanji
elixir mecab
Last synced: 12 days ago
JSON representation
A Elixir library for translating between hiragana, katakana, romaji, kanji and sound. It uses Mecab.
- Host: GitHub
- URL: https://github.com/ikeikeikeike/exkanji
- Owner: ikeikeikeike
- License: mit
- Created: 2016-01-24T11:19:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-13T13:12:47.000Z (over 6 years ago)
- Last Synced: 2024-10-15T17:16:50.828Z (24 days ago)
- Topics: elixir, mecab
- Language: Elixir
- Homepage: https://github.com/ikeikeikeike/exkanji
- Size: 30.3 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A Elixir library for translating between hiragana, katakana, romaji and kanji. It uses Mecab. (Translations and Internationalizations)
- fucking-awesome-elixir - exkanji - A Elixir library for translating between hiragana, katakana, romaji and kanji. It uses Mecab. (Translations and Internationalizations)
- awesome-elixir - exkanji - A Elixir library for translating between hiragana, katakana, romaji and kanji. It uses Mecab. (Translations and Internationalizations)
README
# Exkanji
[![Build Status](http://img.shields.io/travis/ikeikeikeike/exkanji.svg?style=flat-square)](http://travis-ci.org/ikeikeikeike/exkanji)
[![Hex version](https://img.shields.io/hexpm/v/exkanji.svg "Hex version")](https://hex.pm/packages/exkanji)
[![Hex downloads](https://img.shields.io/hexpm/dt/exkanji.svg "Hex downloads")](https://hex.pm/packages/exkanji)
[![Inline docs](https://inch-ci.org/github/ikeikeikeike/exkanji.svg)](http://inch-ci.org/github/ikeikeikeike/exkanji)
[![hex.pm](https://img.shields.io/hexpm/l/ltsv.svg)](https://github.com/ikeikeikeike/exkanji/blob/master/LICENSE)A Elixir library for translating between hiragana, katakana, romaji, kanji and sound. It uses Mecab.
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add exkanji to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:exkanji, "~> x.x"}]
end
```2. Exkanji package needs `nkf` and `mecab` command and it needs to install those in your environment when you don't have those.
```zsh
$ brew install nkf
$ brew install mecab mecab-ipadic
```# Usage
Exkanji provides some convinient functions in Exkanji module through Exkanji.Translator and Exkanji.Mecab.
Those provided functions are able to translate into hiragana(ひらがな), katakana(カタカナ), romaji(ローマ字) and sound(五十音).Into hiragana(ひらがな)
```Elixir
iex(1)> Exkanji.hiragana "a a A ア ア ァ ァ あ ぁ 亜"
"あ あ あ あ あ ぁ ぁ あ ぁ あ"
iex(2)> Exkanji.hiragana "平仮名 ひらがな hiragana"
"ひらがな ひらがな ひらがな"
```Into katakana(カタカナ)
```Elixir
iex(3)> Exkanji.katakana "a a A ア ア ァ ァ あ ぁ 亜"
"ア ア ア ア ア ァ ァ ア ァ ア"
iex(4)> Exkanji.katakana "片仮名 かたかな katakana"
"カタカナ カタカナ カタカナ"
```Into romaji(ローマ字)
```Elixir
iex(5)> Exkanji.romaji "a a A ア ア ァ ァ あ ぁ 亜"
"a a a a a ァ ァ a ァ a"
iex(6)> Exkanji.romaji "ローマ字 ろーまじ ローマジ"
"ro-maji ro-maji ro-maji"
```Into sound(五十音)
```Elixir
iex(7)> Exkanji.sound "よろしく"
"や"
iex(8)> Exkanji.sound "夜露死苦"
"や"
```## As a Morphological Analyzer.
Exkanji is capable of detecting Part-of-Speech from text, As a Morphological Analyzer. It uses Mecab.
```Elixir
iex(1)> Exkanji.parse "エモい"
{:ok,
[%Exkanji.Mecab{base: "*", cform: "*", ctype: "*",
feature: "名詞,一般,*,*,*,*,*", hiragana: nil, pos: "名詞",
pos1: "一般", pos2: "*", pos3: "*", pron: nil, read: nil, romaji: nil,
surface: "エモ"},
%Exkanji.Mecab{base: "いる", cform: "一段", ctype: "連用形",
feature: "動詞,自立,*,*,一段,連用形,いる,イ,イ", hiragana: nil,
pos: "動詞", pos1: "自立", pos2: "*", pos3: "*", pron: "イ",
read: "イ", romaji: nil, surface: "い"}]}
```It also makes to change that sets Mecab's dictionaly into second arguments in Exkanji.parse function.
```Elixir
iex(2)> Exkanji.parse "エモい", dict: "/opt/local/lib/mecab/dic/neologd-utf8"
{:ok,
[%Exkanji.Mecab{base: "エモい", cform: "*", ctype: "*",
feature: "名詞,固有名詞,一般,*,*,*,エモい,エモイ,エモイ",
hiragana: nil, pos: "名詞", pos1: "固有名詞", pos2: "一般",
pos3: "*", pron: "エモイ", read: "エモイ", romaji: nil,
surface: "エモい"}]}
```[API Reference](http://hexdocs.pm/exkanji/).