character_converter

Crates.iocharacter_converter
lib.rscharacter_converter
version2.1.5
sourcesrc
created_at2020-05-05 15:58:14.936026
updated_at2023-11-10 23:08:46.875684
descriptionTurn Traditional Chinese script ot Simplified Chinese script and vice-versa and tokenize.
homepage
repositoryhttps://github.com/sotch-pr35mac/character_converter
max_upload_size
id237771
size7,349,334
Preston Wang-Stosur-Bassett (sotch-pr35mac)

documentation

README

character_converter


About

Turn Traditional Chinese script to Simplified Chinese script and vice-versa. Check string script to determine if string is Traditional or Simplified Chinese Characters.

This package also includes a largest first matching tokenizer.

Usage

extern crate character_converter;

use character_converter::{is_traditional, is_simplified, traditional_to_simplified, simplified_to_traditional, tokenize};

let traditional_text = "歐洲";
let simplified_text = "欧洲";

// Check script
assert!(is_traditional(traditional_text));

assert!(!is_simplified(traditional_text));

// Convert script
let result_three = traditional_to_simplified(traditional_text);
assert_eq!(result_three, simplified_text);

let result_four = simplified_to_traditional(simplified_text);
assert_eq!(result_four, traditional_text);

// Tokenize
let string = "好好学习天天向上.";
let tokens = vec!["好好", "学习", "天天", "向上"];
assert_eq!(tokens, tokenize(string));

Benchmarks

Run benchmarks using the nightly bench feature:

cargo +nightly bench --features=bench

License

MIT

Commit count: 70

cargo fmt