-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from ZeroX-DG/method-definition
Method definition
- Loading branch information
Showing
17 changed files
with
382 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
### Changed | ||
|
||
- `vi::telex` & `vi::vni` are deprecated & will be removed in the next release. Users are recommended to use `vi::methods` instead. | ||
- `vi::telex::transform_buffer` & `vi::vni::transform_buffer` are deprecated. Users are recommended to use `vi::transform_buffer` instead. | ||
|
||
### Added | ||
|
||
- `vi::methods` module containing method definition & transforming functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use phf::phf_map; | ||
use vi::{ | ||
processor::{LetterModification, ToneMark}, | ||
Action, Definition, | ||
}; | ||
|
||
// Custom vni method with ư short hand using the w character | ||
const MY_VNI: Definition = phf_map! { | ||
'1' => &[Action::AddTonemark(ToneMark::Acute)], | ||
'2' => &[Action::AddTonemark(ToneMark::Grave)], | ||
'3' => &[Action::AddTonemark(ToneMark::HookAbove)], | ||
'4' => &[Action::AddTonemark(ToneMark::Tilde)], | ||
'5' => &[Action::AddTonemark(ToneMark::Underdot)], | ||
'6' => &[Action::ModifyLetter(LetterModification::Circumflex)], | ||
'7' => &[Action::ModifyLetter(LetterModification::Horn)], | ||
'8' => &[Action::ModifyLetter(LetterModification::Breve)], | ||
'9' => &[Action::ModifyLetter(LetterModification::Dyet)], | ||
'z' => &[Action::ResetInsertedƯ, Action::InsertƯ], | ||
'0' => &[Action::RemoveToneMark], | ||
}; | ||
|
||
fn main() { | ||
let inputs = "Xin hay4 mo73 toang het61 nhzng4 canh1 cza3 cua3 qua1 khz1 de963 thuyen62 toi6 nzong gio1 lang4 quen6 ra khoi7"; | ||
|
||
let words = inputs.split(' '); | ||
|
||
let mut result = String::new(); | ||
for word in words { | ||
vi::transform_buffer(&MY_VNI, word.chars(), &mut result); | ||
result.push(' '); | ||
} | ||
|
||
println!("{}", result); // prints "Xin hãy mở toang hết những cánh cửa của quá khứ để thuyền tôi nương gió lãng quên ra khơi" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.