josa 0.1.2

Korean language josa selector
Documentation
  • Coverage
  • 80%
    12 out of 15 items documented2 out of 5 items with examples
  • Size
  • Source code size: 14 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.79 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • yujingaya/josa
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yujingaya

Josa

Idiomatic josa selector.

crates.io version crates.io license crates.io download

Josa is a Rust library to select appropriate josas for korean language.

Overview

push_josa method

Josa is an extension trait implemented for String type. Its API works just like push_str method on String.

use josa::JosaExt;
use josa::Josa::{EunNeun, IGa};

let mut user = "유진".to_owned();
let mut mackerel = "고등어".to_owned();

user.push_josa(EunNeun);
mackerel.push_josa(IGa);

let sentence = format!("{} {} 먹고싶다", user, mackerel);

assert_eq!(sentence, "유진은 고등어가 먹고싶다");

:warning: Like push_str does, push_josa expects String, not str, as its argument.

+, += operator

You can use +, += operator to append josa.

use josa::Josa::{EunNeun, IGa};

let user = "유진".to_owned();
let mackerel = "고등어".to_owned();

let sentence = format!("{} {} 먹고싶다", user + EunNeun, mackerel + IGa);

assert_eq!(sentence, "유진은 고등어가 먹고싶다");

select method

In case you want to append a josa to formatted text such as <span>고양이</span>, you can use select method.

use josa::select;
use josa::Josa::IGa;

let cat = "고양이";
let josa = select(cat, IGa).unwrap();

let cat = format!(r#"<span class="bold">{}</span>{}"#, cat, josa);

assert_eq!(cat, r#"<span class="bold">고양이</span>가"#);

Usage

Add josa as a dependency in your Cargo.toml.

[dependencies]
josa = "0.1.2"

Now you can use josa crate.

use josa::*;
// Use here..

Documentation

See docs.rs

Roadmap

select macro

As soon as hygiene 2.0 (#54727) arrives stable, we will add support for following macro:

select!("{}{은} {}{가} 먹고싶다", user, mackerel);

which is terser than current syntax:

Hangul enum variants

As soon as non-ASCII identifiers (#55467) arrives stable, we will change the names of josas to Hangul:

format!("{} {} 먹고싶다", user + 은는, mackerel + 이가);

License

Distributed under the MIT license.