-
Notifications
You must be signed in to change notification settings - Fork 1
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 #4 from Thaza-Kun/Thaza-Kun/issue3
Mengasingkan kod teras dalam subcrate 'onc'
- Loading branch information
Showing
17 changed files
with
640 additions
and
696 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 @@ | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
test-rust: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Wasm-pack | ||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | ||
|
||
- name: Set Node.js 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- run: yarn test |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,26 @@ | ||
workspace = { members = ["onc"] } | ||
|
||
[package] | ||
name = "wasm-rs" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
crate-type = ["cdylib"] | ||
crate-type = ["lib", "cdylib"] | ||
|
||
[dependencies] | ||
clap = { version = "4.5.4", features = ["cargo"] } | ||
itertools = "0.12.1" | ||
nom = "7.1.3" | ||
lazy_static = { version = "1.4.0", optional = true } | ||
onc = { version = "0.1.0", path = "onc" } | ||
serde = { version = "1.0.197", features = ["derive"] } | ||
serde-wasm-bindgen = "0.6.5" | ||
toml = "0.8.11" | ||
wasm-bindgen = { version = "0.2.92", features = ["serde"] } | ||
|
||
[features] | ||
lazystatic = ["dep:lazy_static"] | ||
|
||
[[example]] | ||
name = "imbuhan" | ||
required-features = ["lazystatic"] |
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,80 @@ | ||
use std::collections::HashSet; | ||
|
||
use wasm_rs::functions::{parse_default_tatabunyi_toml, parse_imbuhan_toml}; | ||
use wasm_rs::imbuhan::JenisKata; | ||
|
||
lazy_static::lazy_static! { | ||
static ref INPUTS: [(&'static str, HashSet<JenisKata>); 3] = [ | ||
("susyi", HashSet::from([JenisKata::Nama])), | ||
("terang", HashSet::from([JenisKata::Nama, JenisKata::Kerja])), | ||
("merah", HashSet::from([JenisKata::Sifat])) | ||
]; | ||
} | ||
const IMBUHAN_CONFIG: &'static str = r#" | ||
[[imbuhan]] | ||
ganti.awal = { "" = "ng", "k" = "ng", "g" = "ngg", "h" = "ng", "q" = "ngq", "b" = "mb", "v" = "mv", "f" = "mf", "p" = "m", "c" = "nc", "d" = "nd", "j" = "nj", "sy" = "nsy", "t" = "n", "z" = "z", "s" = "ny" } | ||
untuk = ["kata kerja"] | ||
awal = "me" | ||
[[imbuhan]] | ||
untuk = ["kata nama"] | ||
awal = "per" | ||
[[imbuhan]] | ||
untuk = ["kata nama", "kata kerja"] | ||
awal = "juru" | ||
[[imbuhan]] | ||
untuk = ["kata kerja", "kata sifat"] | ||
awal = "ter" | ||
[[imbuhan]] | ||
untuk = ["kata sifat"] | ||
awal = "se" | ||
[[imbuhan]] | ||
ganti.awal = { "" = "ng", "k" = "ng", "g" = "ngg", "h" = "ng", "q" = "ngq", "b" = "mb", "v" = "mv", "f" = "mf", "p" = "m", "c" = "nc", "d" = "nd", "j" = "nj", "sy" = "nsy", "t" = "n", "z" = "z", "s" = "ny" } | ||
untuk = ["kata kerja"] | ||
awal = "me" | ||
akhir = "kan" | ||
[[imbuhan]] | ||
untuk = ["kata nama", "kata kerja", "kata sifat"] | ||
awal = "ke" | ||
akhir = "an" | ||
"#; | ||
const PHONOTACTIC_CONFIG: &'static str = r#" | ||
default = "Melayu Moden" | ||
[[phonotactic]] | ||
name = "Melayu Moden" | ||
definition.onset = [["sp", "spr", "sw", "sk", "skr", "st", "str", "kl", "fl", "bl", "pl", "pr", "kr", "gr", "tr", "dr", "kh", "sy", "gh", "ny", "ng", "v", "x", "q", "f", "y", "w", "m", "n", "p", "t", "c", "k", "b", "d", "j", "g", "s", "h", "l", "r"]] | ||
definition.nucleus = [["a", "e", "i", "o", "u"]] | ||
definition.coda = [["ks", "ns", "nk", "lf", "rt", "rd", "rt", "kh", "sy", "gh", "ng", "q", "f", "b", "m", "n", "p", "t", "k", "s", "h", "l", "r"]] | ||
"#; | ||
|
||
fn main() { | ||
println!("<< Example: Imbuhan >>"); | ||
let imbuhans = parse_imbuhan_toml(IMBUHAN_CONFIG.to_string()); | ||
let phonotactic = parse_default_tatabunyi_toml(PHONOTACTIC_CONFIG.to_string()); | ||
|
||
for (n, (input, set)) in INPUTS.iter().enumerate() { | ||
println!("\n[E.g. {}] ========", n + 1); | ||
let input = String::from(*input); | ||
println!("Input\t\t: {}", &input); | ||
println!("Golongan Kata\t: {:?}", &set); | ||
|
||
let mut items = Vec::<String>::new(); | ||
|
||
for imbuhan in &imbuhans { | ||
if imbuhan.contains( | ||
set.contains(&JenisKata::Nama), | ||
set.contains(&JenisKata::Kerja), | ||
set.contains(&JenisKata::Sifat), | ||
) { | ||
items.push(imbuhan.transform_string_with(&input, &phonotactic)); | ||
} | ||
} | ||
println!("Results\t\t: {}", items.join(", ")) | ||
} | ||
} |
Oops, something went wrong.