Project

kanjika

0.0
No release in over a year
japanese language tools
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 0.2.2
~> 0.0.4
 Project Readme

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-utf8

macOS:

brew install mecab mecab-ipadic

Other systems: Please refer to the MeCab installation guide.

Gem Installation

Add this line to your application's Gemfile:

gem 'kanjika'

And then execute:

bundle install

Or install it yourself as:

gem install kanjika

Features

  • ๐ŸŽŒ 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 install

Run the tests:

bundle exec rspec

Run the linter:

bundle exec standardrb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fagnerpereira/kanjika_gem.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. 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:

  • Ve - Japanese morphological analyzer
  • Mojinizer - Japanese character utilities