jReadability allows python developers to calculate the readability of Japanese text using the model developed by Jae-ho Lee and Yoichiro Hasebe in Introducing a readability evaluation system for Japanese language education and Readability measurement of Japanese texts based on levelled corpora. Note that this is not an official implementation.
You can play with an interactive demo here.
pip install jreadability
from jreadability import compute_readability
# "Good morning! The weather is nice today."
text = 'γγ―γγγγγγΎγοΌδ»ζ₯γ―倩ζ°γγγγ§γγγ'
score = compute_readability(text)
print(score) # 6.438000000000001
Level | Readability score range |
---|---|
Upper-advanced | [0.5, 1.5) |
Lower-advanced | [1.5, 2.5) |
Upper-intermediate | [2.5, 3.5) |
Lower-intermediate | [3.5, 4.5) |
Upper-elementary | [4.5, 5.5) |
Lower-elementary | [5.5, 6.5) |
Note that this readability calculator is specifically for non-native speakers learning to read Japanese. This is not to be confused with something like grade level or other readability scores meant for native speakers.
readability = {mean number of words per sentence} * -0.056
+ {percentage of kango} * -0.126
+ {percentage of wago} * -0.042
+ {percentage of verbs} * -0.145
+ {percentage of particles} * -0.044
+ 11.724
* "kango" (ζΌ’θͺ) means Japanese word of Chinese origin while "wago" (εθͺ) means native Japanese word.
The readability scores produced by this python package tend to differ slightly from the scores produced on the official jreadability website. This is likely due to the version difference in UniDic between these two implementations as this package uses UniDic 2.1.2 while theirs uses UniDic 2.2.0. This issue may be resolved in the future.
jreadability makes use of fugashi's tagger under the hood and initializes a new tagger everytime compute_readability
is invoked. If you are processing a large number of texts, it is recommended to initialize the tagger first on your own, then pass it as an argument to each subsequent compute_readability
call.
from fugashi import Tagger
texts = [...]
tagger = Tagger()
for text in texts:
score = compute_readability(text, tagger) # fast :D
#score = compute_readability(text) # slow :'(
...
The official jReadability implementation can be found on jreadability.net
A node.js implementation can also be found here.