Skip to content

v0.4.2: Romaji overhaul

Choose a tag to compare

@Chaoses-Ib Chaoses-Ib released this 19 Feb 10:45
· 14 commits to master since this release
a87c3ba

Breaking changes

  • ib-matcher: No breaking changes
  • ib-romaji: Some functions' input type is changed from &(impl ?Sized + AsRef<str>) to impl Into<Input<'h>>. Most code should still work.

ib-romaji v0.2.0

Major overhual (#12,#13):

  • Fully support n apostrophe
  • Fully support single kanji noma
  • convert: add hepburn_ime
  • matcher: partial_word at kana boundary by default
  • Word dictionary size is reduced by 3%, so init time (and binary size) should be ~3% smaller.
    • Overall size (with matcher) is reduced by 108 KiB.

Update docs:

ib-matcher v0.4.2

  • MatchConfig add matcher() for convenient.
  • syntax::glob: allow logos v0.16
  • macros: add assert_match!() for tests

Update docs:

MatchConfig and Japanese romaji matching examples:

// cargo add ib-matcher --features romaji,macros
use ib_matcher::{assert_match, matcher::MatchConfig};

let c = MatchConfig::builder().romaji(Default::default()).build();
// kya n
assert_match!(c.matcher("kyan").find("キャン"), Some((0, 9)));
// kya ni
assert_match!(c.matcher("kyan").find("キャニ"), None);
// Partial match (`b.is_pattern_partial()`) is disabled by default.

// kya n(n'/nn) i se kai nyo nyo
assert_match!(c.matcher("nisekainyonyo" ).find("キャンヰ世界ニョニョ"), None);
assert_match!(c.matcher("n'isekainyonyo").find("キャンヰ世界ニョニョ"), Some((6, 24)));
assert_match!(c.matcher("nnisekainyonyo").find("キャンヰ世界ニョニョ"   ), Some((6, 24)));

// shu u se i pa tchi/cchi
assert_match!(c.matcher("shuuseipatchi").find("修正パッチ"), Some((0, 15)));
assert_match!(c.matcher("shuuseipacchi").find("集成パッチ"), Some((0, 15)));

// shi ka no ko no ko no ko ko shi ta n ta n
assert_match!(c.matcher("shikanokonokonokokoshitantan").find("鹿乃子のこのこ虎視眈々"), Some((0, 33)));

Partial matches

Many Japanese words are composed of multiple kanas (Japanese letters), while each kana's romaji may be composed of multiple English letters. So unlike pinyin, there are three partial matching options in romaji matching:

  • No partial matching.

    This is the default before v0.4.2, ib-romaji v0.2.

    To use this option, you can set RomajiMatchConfigBuilder::partial_word(false). But it's probably not what users would want as some words can be pretty long.

  • Partially match words, but not kanas.

    The became the default after v0.4.2, since the former default is confusing to new users.

    TODO: Due to the current implementation, this may partially match a kanji.

  • Partially match both words and kanas.

    To use this option, set IbMatcherBuilder::is_pattern_partial(true), which also works the same for pinyin matching.

ib-pinyin-ahk2 v0.4.2

  • Smaller binary size (x86-64 -0.5 KiB → 488/660 KiB)