Skip to content
Japanese text difficulty analyzer
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
LICENSE
README.md
index.js
package.json

README.md

muzukashii - Japanese Text Difficulty Analyzer

Analyze Japanese texts to find out how difficult they are for foreign readers.

Note that this library completely ignores vocabulary or grammar - it only takes kanji into account.

Features:

  • counts kanji per difficulty, ie. JLPT level or jouyou grade
  • support for custom kanji groups (can be used for kanji from some Japanese textbook or just kanji you've learned)
  • works in browsers (with browserify)

Installation

npm install muzukashii

Usage

var muzukashii = require('muzukashii');

muzukashii.categorize('');
// => { jlpt: 'n4', jlptVocabulary: 'n5', jouyou: '6' }

muzukashii.analyze('学生です');
/* =>
  { totalKanjiCount: 2,
    uniqueKanjiCount: 2,
    groups:
     { jlpt: { n5: 2 }, jlptVocabulary: { n5: 2 }, jouyou: { '1': 2 } },
    kanji:
     { '学': { jlpt: 'n5', jlptVocabulary: 'n5', jouyou: '1' },
       '生': { jlpt: 'n5', jlptVocabulary: 'n5', jouyou: '1' } } }
*/

var customAnalyzer = muzukashii.custom({
  someKanjiBook: {
    chapter1: '一ニ三四五六七八九十',
    chapter2: '東西南北左右'
  }
});

customAnalyzer.categorize('');
// => { someKanjiBook: 'chapter1' }

customAnalyzer.analyze('一月');
/* =>
  { totalKanjiCount: 2,
    uniqueKanjiCount: 2,
    groups: { someKanjiBook: { chapter1: 1, unknown: 1 } },
    kanji:
     { '一': { someKanjiBook: 'chapter1' },
       '月': { someKanjiBook: 'unknown' } } }
*/

More examples

License

The code is available under MIT license.

You can’t perform that action at this time.