-
Notifications
You must be signed in to change notification settings - Fork 35
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
Zip up Rule directories and unzip on demand #252
Comments
I can see this is at least partially implemented. Should I be able to set the Language preference from a web assembly and then process MathML? I've made a stab at creating a basic wasm/javascript interface: https://github.com/brichwin/MathCATForWeb/ If I try to set the If I don't set the <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MathCAT Web</title>
</head>
<body>
<script type="module">
import init, { wasm_set_rules_dir, wasm_get_version, wasm_set_preference, wasm_set_mathml, wasm_get_spoken_text, wasm_get_braille } from './pkg/mathcat_web.js';
async function set_mathcat_pref(pref, value) {
try {
await wasm_set_preference(pref, value);
console.log(`${pref} Preference set to ${value}`);
} catch (error) {
console.error(`Error setting ${pref} preference to ${value}: ${error}`);
}
}
async function run() {
await init();
console.log('MathCAT Version:', wasm_get_version());
try {
await wasm_set_rules_dir('Rules');
console.log('Rules directory set');
await set_mathcat_pref('Language', 'en');
await set_mathcat_pref('SpeechStyle', 'ClearSpeak');
try {
const canonicalMathML = await wasm_set_mathml(`<math><mrow><mi>x</mi><mo>=</mo><msup><mi>y</mi><mn>2</mn></msup></mrow></math>`);
console.log('Canonical MathML:', canonicalMathML);
const spokenText = await wasm_get_spoken_text();
console.log('Spoken Text:', spokenText);
} catch (error) {
console.error('Error processing MathML:', error);
}
try {
const braille = await wasm_get_braille('');
console.log('Braille:', braille);
} catch (error) {
console.error('Error getting braille:', error);
}
} catch (error) {
console.error('Error setting rules directory:', error);
console.error('Cannot continue, rules directory must be set before calling other MathCAT functions.')
}
}
run();
</script>
</body>
</html> |
Ah, okay. I'm a little bit more awake now and realized it doesn't look like my calls to
Since I can compile the MathCATDemo project and that works I'm guessing that my MathCATForWeb isn't configuring the build of MathCAT correctly to trigger all the right conditional compiles. |
Looks like I didn't check in the latest thing I found I could do in Cargo.toml: I think you want to add Because I didn't publish the latest version which has the zip file fixes, you can't use directly refer to 0.6.4 from another project. But this "patch" feature allows you to get around that by telling Rust not to looking in crates.io for a published version. I'm not 100% sure I have the syntax right. I copied and modified it from some Rust documentation. That might help. |
Each language file is about 500k. As the number of languages gets bigger, this is means a substantial size increase for MathCAT.
There is a huge amount of compression that can happen when these are zipped up. Typically, only one or two languages will get used, so zipping up each language directory can save a lot of space.
Implementation ideas:
._Rules.txt
file that has the rules listed, one per line (SimpleSpeech, ClearSpeak).The text was updated successfully, but these errors were encountered: