stuff
This commit is contained in:
parent
bc92231240
commit
b8225c639e
11904 changed files with 1472749 additions and 133 deletions
36
node_modules/speech-rule-engine/mjs/enrich_mathml/enrich.js
generated
vendored
Normal file
36
node_modules/speech-rule-engine/mjs/enrich_mathml/enrich.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { Debugger } from '../common/debugger.js';
|
||||
import * as DomUtil from '../common/dom_util.js';
|
||||
import { EnginePromise } from '../common/engine.js';
|
||||
import * as Semantic from '../semantic_tree/semantic.js';
|
||||
import * as EnrichMathml from './enrich_mathml.js';
|
||||
import './enrich_case_factory.js';
|
||||
export function semanticMathmlNode(mml) {
|
||||
const clone = DomUtil.cloneNode(mml);
|
||||
const tree = Semantic.getTree(clone);
|
||||
return EnrichMathml.enrich(clone, tree);
|
||||
}
|
||||
export function semanticMathmlSync(expr) {
|
||||
const mml = DomUtil.parseInput(expr);
|
||||
return semanticMathmlNode(mml);
|
||||
}
|
||||
export function semanticMathml(expr, callback) {
|
||||
EnginePromise.getall().then(() => {
|
||||
const mml = DomUtil.parseInput(expr);
|
||||
callback(semanticMathmlNode(mml));
|
||||
});
|
||||
}
|
||||
export function testTranslation(expr) {
|
||||
Debugger.getInstance().init();
|
||||
const mml = semanticMathmlSync(prepareMmlString(expr));
|
||||
Debugger.getInstance().exit();
|
||||
return mml;
|
||||
}
|
||||
export function prepareMmlString(expr) {
|
||||
if (!expr.match(/^<math/)) {
|
||||
expr = '<math>' + expr;
|
||||
}
|
||||
if (!expr.match(/\/math>$/)) {
|
||||
expr += '</math>';
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue