-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more concice benches, add json example
- Loading branch information
Showing
14 changed files
with
258 additions
and
49 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
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 |
---|---|---|
@@ -1,27 +1,77 @@ | ||
( | ||
patterns: [ | ||
// highly nested | ||
("a", {"Any": [ | ||
{"Original": ()}, | ||
{"Literal": "B"}, | ||
{"Literal": "Flat"}, | ||
]}), | ||
("VeryLongNonExistent12344343243244234", {"Any": [{"Original": ()}]}), | ||
("you", {"Any": [ | ||
{"Any": [ | ||
{"Any": [ | ||
{"Any": [ | ||
{"Any": [ | ||
{"Any": [ | ||
{"Any": [ | ||
{"Any": [ | ||
{"Literal": "nestednormalizeme"}, | ||
{"Any": [ | ||
{"Original": ()}, | ||
]}, | ||
]}, | ||
]}, | ||
]}, | ||
]}, | ||
]}, | ||
]}, | ||
]}, | ||
]}), | ||
// many items | ||
("o", {"Any": [ | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
{"Any": [{"Original": ()}]}, | ||
]}), | ||
], | ||
) |
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,7 +1,13 @@ | ||
( | ||
patterns: [ | ||
("a", {"Concat": ({"Literal": "first"}, {"Original": ()})}), | ||
("VeryLongNonExistent12344343243244234", {"Concat": ({"Original": ()}, {"Literal": "first"})}), | ||
("you", {"Concat": ({"Literal": "left"}, {"Literal": "right"})}), | ||
// use \w+ and \W+ to vary string lengths | ||
(r"\w+", {"Concat": ( | ||
{"Original": ()}, | ||
{"Original": ()}, | ||
)}), | ||
(r"\W+", {"Concat": ( | ||
{"Original": ()}, | ||
{"Original": ()}, | ||
)}), | ||
], | ||
) |
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,7 +1,7 @@ | ||
( | ||
patterns: [ | ||
("a", {"Literal": "B"}), | ||
("VeryLongNonExistent12344343243244234", {"Literal": "wdwdffhskhfkshekfhKFE"}), | ||
("you", {"Literal": "normalizeme"}), | ||
("a", {"Literal": "A"}), | ||
("o", {"Literal": "short"}), | ||
(r"\d+", {"Literal": "veryLongStringaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234123412344rhrkghsghkgshal;ghaslfnkhsgkshgshgsjdgjkdngkjgh"}), | ||
], | ||
) |
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,7 +1,5 @@ | ||
( | ||
patterns: [ | ||
("a", {"Lower": {"Original": ()}}), | ||
("VeryLongNonExistent12344343243244234", {"Lower": {"Original": ()}}), | ||
("you", {"Lower": {"Original": ()}}), | ||
(r"\w+", {"Lower": {"Lower": {"Lower": {"Lower": {"Lower": {"Original": ()}}}}}}), | ||
], | ||
) |
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,7 +1,7 @@ | ||
( | ||
patterns: [ | ||
("a", {"Original": ()}), | ||
("VeryLongNonExistent12344343243244234", {"Original": ()}), | ||
("you", {"Original": ()}), | ||
// varying string lenghts | ||
(r"\w+", {"Original": ()}), | ||
(r"\W+", {"Original": ()}), | ||
], | ||
) |
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,7 +1,5 @@ | ||
( | ||
patterns: [ | ||
("a", {"Upper": {"Original": ()}}), | ||
("VeryLongNonExistent12344343243244234", {"Upper": {"Original": ()}}), | ||
("you", {"Upper": {"Original": ()}}), | ||
(r"\w+", {"Upper": {"Upper": {"Upper": {"Upper": {"Upper": {"Original": ()}}}}}}), | ||
], | ||
) |
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,70 @@ | ||
{ | ||
"words": [ | ||
["epic", {"Literal": "ebin"}], | ||
[":?\\]", {"Any": [ | ||
{"Literal": ":D"}, | ||
{"Literal": ":DD"}, | ||
{"Literal": ":DDD"} | ||
]}] | ||
], | ||
"patterns": [ | ||
["xc", {"Literal": "gg"}], | ||
["c", {"Literal": "g"}], | ||
["k", {"Literal": "g"}], | ||
["t", {"Literal": "d"}], | ||
["p", {"Literal": "b"}], | ||
["x", {"Literal": "gs"}], | ||
["\\Bng\\b", {"Literal": "gn"}], | ||
["$", {"Weights": [ | ||
[1, {"Original": null}], | ||
[1, {"Any": [ | ||
{"Literal": " :D"}, | ||
{"Literal": " :DD"}, | ||
{"Literal": " :DDD"}, | ||
{"Literal": " :DDDD"}, | ||
{"Literal": " :DDDDD"} | ||
]}] | ||
]}] | ||
], | ||
"intensities": { | ||
"1": {"Extend": { | ||
"patterns": [ | ||
["$", {"Weights": [ | ||
[1, {"Original": null}], | ||
[2, {"Any": [ | ||
{"Literal": " :DD"}, | ||
{"Literal": " :DDD"}, | ||
{"Literal": " :DDDD"}, | ||
{"Literal": " :DDDDD"}, | ||
{"Literal": " :DDDDDD"} | ||
]}] | ||
]}] | ||
], | ||
"words": [ | ||
[":?\\]", {"Any": [ | ||
{"Literal": ":DD"}, | ||
{"Literal": ":DDD"}, | ||
{"Literal": ":DDDD"} | ||
]}] | ||
] | ||
}}, | ||
"2": {"Extend": { | ||
"patterns": [ | ||
["$", {"Any": [ | ||
{"Literal": " :DDDD"}, | ||
{"Literal": " :DDDDD"}, | ||
{"Literal": " :DDDDDD"}, | ||
{"Literal": " :DDDDDDD"}, | ||
{"Literal": " :DDDDDDDD"} | ||
]}] | ||
], | ||
"words": [ | ||
[":?\\]", {"Any": [ | ||
{"Literal": ":DDDD"}, | ||
{"Literal": ":DDDDD"}, | ||
{"Literal": ":DDDDDD"} | ||
]}] | ||
] | ||
}} | ||
} | ||
} |
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,41 @@ | ||
mod utils; | ||
|
||
use sayit::Accent; | ||
use std::{fs, path::PathBuf}; | ||
use utils::read_sample_file_lines; | ||
|
||
pub fn read_accent(filename: PathBuf) -> Accent { | ||
let content = fs::read_to_string(&filename).unwrap(); | ||
serde_json::from_str::<Accent>(&content) | ||
.expect(&format!("parsing accent {}", filename.display())) | ||
} | ||
|
||
#[test] | ||
fn json_examples_work() { | ||
let lines = read_sample_file_lines(); | ||
|
||
let mut tested_at_least_one = false; | ||
|
||
for entry in fs::read_dir("examples").unwrap() { | ||
let path = entry.unwrap().path(); | ||
|
||
if !path.is_file() { | ||
continue; | ||
} | ||
|
||
if !path.extension().is_some_and(|ext| ext == "json") { | ||
continue; | ||
} | ||
|
||
println!("running {}", path.display()); | ||
let accent = read_accent(path); | ||
for line in &lines { | ||
for intensity in accent.intensities() { | ||
accent.say_it(&line, intensity); | ||
} | ||
} | ||
tested_at_least_one = true; | ||
} | ||
|
||
assert!(tested_at_least_one); | ||
} |
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,40 @@ | ||
mod utils; | ||
|
||
use sayit::Accent; | ||
use std::{fs, path::PathBuf}; | ||
use utils::read_sample_file_lines; | ||
|
||
pub fn read_accent(filename: PathBuf) -> Accent { | ||
let content = fs::read_to_string(&filename).unwrap(); | ||
ron::from_str::<Accent>(&content).expect(&format!("parsing accent {}", filename.display())) | ||
} | ||
|
||
#[test] | ||
fn ron_examples_work() { | ||
let lines = read_sample_file_lines(); | ||
|
||
let mut tested_at_least_one = false; | ||
|
||
for entry in fs::read_dir("examples").unwrap() { | ||
let path = entry.unwrap().path(); | ||
|
||
if !path.is_file() { | ||
continue; | ||
} | ||
|
||
if !path.extension().is_some_and(|ext| ext == "ron") { | ||
continue; | ||
} | ||
|
||
println!("running {}", path.display()); | ||
let accent = read_accent(path); | ||
for line in &lines { | ||
for intensity in accent.intensities() { | ||
accent.say_it(&line, intensity); | ||
} | ||
} | ||
tested_at_least_one = true; | ||
} | ||
|
||
assert!(tested_at_least_one); | ||
} |
Oops, something went wrong.