Skip to content

mòine

mòine is a Python and Rust library for romanization-aware string comparison. It implements Lattice Path Edit Distance (Kaji, 2023), a distance metric that compares strings through possible reading paths rather than only through visible surface characters.

>>> import moine
>>> moine.distance("moine", "モイニャ", lang="ja")
2
>>> moine.distance("もいにゃ", "モイニャ", lang="ja")
0
>>> moine.distance("weishiji", "威士忌", lang="zh")
0
>>> moine.distance("布納哈奔", "布納哈本", lang="zh")
0

What It Is For

mòine is useful for matching noisy Japanese or Chinese search/input strings, especially when surface forms differ but reading paths stay close.

  • Japanese comparison uses UniDic-CWJ-derived reading artifacts.
  • Chinese comparison uses CC-CEDICT-derived no-tone pinyin artifacts.
  • Python APIs include distance, damerau_distance, ratio, partial_ratio, and cdist.
  • Rust users can use the published crate and detailed API documentation on docs.rs.

Try It

Open the browser demo Read the Python API reference

Name

The project name is inspired by Bunnahabhain Mòine, a Scotch whisky.