-
Notifications
You must be signed in to change notification settings - Fork 0
Embed detect-writing-script #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
276eb89
Embed detect-writing-script
IvanUkhov 4912e8c
Adjust the readme
IvanUkhov 60f97b0
Read the data
IvanUkhov f1effaf
Set up data.rs
IvanUkhov 8b857d9
Add an implementation with tests
IvanUkhov 7d7595d
Update the source
IvanUkhov 1c6f932
Show the totals
IvanUkhov 70a963a
Bump the version number
IvanUkhov 3028125
Rename State to Context
IvanUkhov 6f773ec
Add a benchmark
IvanUkhov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| [submodule "vendor/detect-writing-scripts/source"] | ||
| path = vendor/detect-writing-script/source | ||
| url = https://github.com/bramstein/detect-writing-script.git |
This file contains hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
| use std::collections::BTreeMap; | ||
| use std::fs::File; | ||
| use std::io::Write; | ||
| use std::path::Path; | ||
|
|
||
| const DATA: &str = include_str!("vendor/detect-writing-script/data.json"); | ||
|
|
||
| macro_rules! ok( | ||
| ($result:expr) => ($result.unwrap()); | ||
| ); | ||
|
|
||
| fn main() { | ||
| let data: BTreeMap<String, Vec<[u32; 2]>> = ok!(serde_json::from_str(DATA)); | ||
| let script_count = data.len(); | ||
|
|
||
| let root = ok!(std::env::var("OUT_DIR")); | ||
| let path = Path::new(&root).join("data.rs"); | ||
| let mut file = ok!(File::create(&path)); | ||
| ok!(write!( | ||
| file, | ||
| r#" | ||
| const SCRIPT_COUNT: usize = {script_count}; | ||
| "#, | ||
| )); | ||
| } | ||
This file contains hidden or 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 +1,21 @@ | ||
| //! Detection of writing scripts from Unicode codepoints. | ||
|
|
||
| include!(concat!(env!("OUT_DIR"), "/data.rs")); | ||
|
|
||
| /// A match. | ||
| #[derive(Clone, Copy)] | ||
| pub struct Match { | ||
| pub name: &'static str, | ||
| pub count: usize, | ||
| pub score: f64, | ||
| } | ||
|
|
||
| /// Detect writing scripts given ranges of Unicode codepoints. | ||
| pub fn detect<T>(_codepoints: T, _threshold: f64) -> Vec<Match> | ||
| where | ||
| T: IntoIterator<Item = [u32; 2]>, | ||
| { | ||
| let _ = [0; SCRIPT_COUNT]; | ||
|
|
||
| unimplemented!() | ||
| } |
This file contains hidden or 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,5 @@ | ||
| data.json: | ||
| node \ | ||
| --input-type=module \ | ||
| --eval "import data from './source/data/scripts.js'; console.log(JSON.stringify(data, null, 2))" \ | ||
| > $@ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.