https://github.com/apertium/wasm
https://github.com/apertium/wasm
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/apertium/wasm
- Owner: apertium
- Created: 2022-12-29T13:28:12.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T11:07:28.000Z (almost 3 years ago)
- Last Synced: 2025-07-19T17:53:10.151Z (4 months ago)
- Language: Shell
- Homepage:
- Size: 1.95 KB
- Stars: 2
- Watchers: 11
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
After building CG-3, run a HTTP daemon in its `build/src` folder and load `vislcg3.html` and run the code below in the console.
```javascript
{
let cglb = Module.cwrap('cg3_grammar_load_buffer', 'number', ['string', 'number']);
let cac = Module.cwrap('cg3_applicator_create', 'number', ['number']);
let crgotf = Module.cwrap('cg3_run_grammar_on_text_fns', null, ['number', 'string', 'string']);
let g = cglb('DELIMITERS = "<.>"; SELECT (tag) ;', 'DELIMITERS = "<.>"; SELECT (tag) ;'.length);
let a = cac(g);
FS.writeFile('/tmp/input.txt', '""\n\t"woørd" tag\n\t"woård" nottag\n');
crgotf(a, '/tmp/input.txt', '/tmp/output.txt');
console.log(FS.readFile('/tmp/output.txt', {'encoding': 'utf8'}));
}
```
Yields output:
```
""
"woørd" tag
```
Some CG-3 changes were needed to make it build, add a text I/O function, and export all needed functions:
https://github.com/GrammarSoft/cg3/commit/38b5949d5679ea35b0ed998300d19766e489f7e0
Similar changes are likely needed for all other tools.