Kanjika
A practical Ruby gem for Japanese verb conjugation. Kanjika provides an easy-to-use interface for conjugating Japanese verbs across multiple forms including masu (polite), te, and potential forms.
Installation
System Requirements
Kanjika requires MeCab (a Japanese morphological analyzer) to be installed on your system.
Ubuntu/Debian:
sudo apt-get install mecab libmecab-dev mecab-ipadic-utf8macOS:
brew install mecab mecab-ipadicOther systems: Please refer to the MeCab installation guide.
Gem Installation
Add this line to your application's Gemfile:
gem 'kanjika'And then execute:
bundle installOr install it yourself as:
gem install kanjikaFeatures
- ๐ Japanese verb conjugation (multiple forms)
- ๐ Support for all verb types: Godan (ไบๆฎต / ใใ ใ), Ichidan (ไธๆฎต / ใใกใ ใ), and Irregular verbs
- ๐ Multiple conjugation forms: te-form, masu-form, potential
- ๐ฏ Simple and intuitive API
- โก Built on top of Ve and Mojinizer for accurate morphological analysis
Usage
Basic Conjugation
Kanjika provides two main ways to conjugate verbs:
Using the module-level method
require 'kanjika'
# Conjugate directly
Kanjika.conjugate("้ฃในใ", :masu) # => "้ฃในใพใ" (ใในใพใ / tabemasu - eat/will eat)
Kanjika.conjugate("ๆธใ", :te) # => "ๆธใใฆ" (ใใใฆ / kaite - write and...)
# Negative forms
Kanjika.conjugate("้ฃในใ", :masu, negative: true) # => "้ฃในใพใใ" (ใในใพใใ / tabemasen - don't eat)
Kanjika.conjugate("้ฃในใ", :te, negative: true) # => "้ฃในใชใใฆ" (ใในใชใใฆ / tabenakute - not eating/without eating)Using the Verb object
verb = Kanjika.verb('ๆธใ') # ๆธใ = ใใ (kaku - to write)
# Get the masu form (polite present/future)
verb.conjugate(:masu) # => "ๆธใใพใ" (ใใใพใ / kakimasu - write/will write)
verb.to(:masu) # => "ๆธใใพใ" (alias)
# Get the te form (connective)
verb.conjugate(:te) # => "ๆธใใฆ" (ใใใฆ / kaite - write and...)
# Get the potential form (can do)
verb.conjugate(:potential) # => "ๆธใใ" (ใใใ / kakeru - can write)
# Negative forms
verb.conjugate(:masu, negative: true) # => "ๆธใใพใใ" (ใใใพใใ / kakimasen - don't write)
verb.conjugate(:te, negative: true) # => "ๆธใใชใใฆ" (ใใใชใใฆ / kakanakute - not writing/without writing)Supported Conjugation Forms
Masu Form (Polite Present)
Kanjika.conjugate("้ฃในใ", :masu) # => "้ฃในใพใ" (ใในใพใ / tabemasu - eat/will eat)
Kanjika.conjugate("ๆธใ", :masu) # => "ๆธใใพใ" (ใใใพใ / kakimasu - write/will write)
Kanjika.conjugate("ใใ", :masu) # => "ใใพใ" (shimasu - do/will do)
# Negative
Kanjika.conjugate("้ฃในใ", :masu, negative: true) # => "้ฃในใพใใ" (ใในใพใใ / tabemasen - don't eat)Te Form (Conjunctive)
Kanjika.conjugate("้ฃในใ", :te) # => "้ฃในใฆ" (ใในใฆ / tabete - eat and...)
Kanjika.conjugate("ๆธใ", :te) # => "ๆธใใฆ" (ใใใฆ / kaite - write and...)
Kanjika.conjugate("้ฃฒใ", :te) # => "้ฃฒใใง" (ใฎใใง / nonde - drink and...)
Kanjika.conjugate("่ฒทใ", :te) # => "่ฒทใฃใฆ" (ใใฃใฆ / katte - buy and...)
# Negative
Kanjika.conjugate("้ฃในใ", :te, negative: true) # => "้ฃในใชใใฆ" (ใในใชใใฆ / tabenakute - not eating/without eating)Potential Form (Can do)
Kanjika.conjugate("้ฃในใ", :potential) # => "้ฃในใใใ" (ใในใใใ / taberareru - can eat)
Kanjika.conjugate("ๆธใ", :potential) # => "ๆธใใ" (ใใใ / kakeru - can write)
Kanjika.conjugate("้ฃฒใ", :potential) # => "้ฃฒใใ" (ใฎใใ / nomeru - can drink)
Kanjika.conjugate("ใใ", :potential) # => "ใงใใ" (dekiru - can do)Verb Types
Kanjika handles all three types of Japanese verbs:
Godan Verbs (ไบๆฎตๅ่ฉ / ใใ ใใฉใใ)
Verbs that end in u-column sounds. Examples:
- ๆธใ (ใใ / kaku) - to write
- ้ฃฒใ (ใฎใ / nomu) - to drink
- ่ฒทใ (ใใ / kau) - to buy
- ่ฉฑใ (ใฏใชใ / hanasu) - to speak
Ichidan Verbs (ไธๆฎตๅ่ฉ / ใใกใ ใใฉใใ)
Verbs that end in -eru or -iru. Examples:
- ้ฃในใ (ใในใ / taberu) - to eat
- ่ฆใ (ใฟใ / miru) - to see
- ่ตทใใ (ใใใ / okiru) - to wake up
Irregular Verbs
Only two main irregular verbs:
- ใใ (suru) - to do
- ๆฅใ (ใใ / kuru) - to come
Pronunciation Guide
To help beginners, we're adding pronunciation guides for the kanji used in this documentation and in the code. Each entry below shows the kanji, its furigana (kana reading), and its romaji.
- ้ฃในใ (ใในใ / taberu): to eat
- ๆธใ (ใใ / kaku): to write
- ้ฃฒใ (ใฎใ / nomu): to drink
- ่ฒทใ (ใใ / kau): to buy
- ่ฉฑใ (ใฏใชใ / hanasu): to speak
- ่ฆใ (ใฟใ / miru): to see
- ่ตทใใ (ใใใ / okiru): to wake up
- ใใ (suru): to do
- ๆฅใ (ใใ / kuru): to come
- ไบๆฎต (ใใ ใ / godan): five-step (verb type)
- ไธๆฎต (ใใกใ ใ / ichidan): one-step (verb type)
Examples
# ้ฃในใ (ใในใ / taberu - to eat) - Ichidan
verb = "้ฃในใ"
Kanjika.conjugate(verb, :masu) # => "้ฃในใพใ" (ใในใพใ / tabemasu - eat/will eat)
Kanjika.conjugate(verb, :te) # => "้ฃในใฆ" (ใในใฆ / tabete - eat and...)
Kanjika.conjugate(verb, :potential) # => "้ฃในใใใ" (ใในใใใ / taberareru - can eat)
# ๆธใ (ใใ / kaku - to write) - Godan
verb = "ๆธใ"
Kanjika.conjugate(verb, :masu) # => "ๆธใใพใ" (ใใใพใ / kakimasu - write/will write)
Kanjika.conjugate(verb, :te) # => "ๆธใใฆ" (ใใใฆ / kaite - write and...)
Kanjika.conjugate(verb, :potential) # => "ๆธใใ" (ใใใ / kakeru - can write)
# ใใ (suru - to do) - Irregular
verb = "ใใ"
Kanjika.conjugate(verb, :masu) # => "ใใพใ" (shimasu - do/will do)
Kanjika.conjugate(verb, :te) # => "ใใฆ" (shite - do and...)
Kanjika.conjugate(verb, :potential) # => "ใงใใ" (dekiru - can do)Development
After checking out the repo, run:
bundle installRun the tests:
bundle exec rspecRun the linter:
bundle exec standardrbContributing
Bug reports and pull requests are welcome on GitHub at https://github.com/fagnerpereira/kanjika_gem.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Roadmap
See ROADMAP.md for the full list of proposed features awaiting discussion.
Here are some of the features we're planning to add to Kanjika:
-
More Conjugation Forms: We'll be adding support for more conjugation forms, such as:
- Passive (e.g., ้ฃในใใใ (ใในใใใ) - taberareru)
- Causative (e.g., ้ฃในใใใ (ใในใใใ) - tabesaseru)
- Volitional (e.g., ้ฃในใใ (ใในใใ) - tabeyou)
- Imperative (e.g., ้ฃในใ (ใในใ) - tabero)
- Adjective Conjugation: Support for i-adjectives and na-adjectives.
- Verb Transitivity: The ability to identify if a verb is transitive or intransitive.
- Kanji Pronunciation: We will add comments to the code to help beginners with the pronunciation of unknown kanji.
- Web Interface: A simple web interface to demonstrate the gem's capabilities.
License
The gem is available as open source under the terms of the MIT License.
Credits
Built with: