Skip to content

Commit

Permalink
Merge pull request #664 from Speech-Rule-Engine/2d_fractions
Browse files Browse the repository at this point in the history
2d fractions
  • Loading branch information
zorkow committed Jun 27, 2022
2 parents d3f748e + 43bb2e6 commit c40b190
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
4 changes: 3 additions & 1 deletion mathmaps/nemeth/messages/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
"DECIMAL_MARK": ".",
"DIGIT_GROUP": ",",
"JOINER_SUBSUPER": "",
"JOINER_FRAC": ""
"JOINER_FRAC": "",
"SPACE": "",
"HYPER": "3"
},
"unitTimes": ""
}
Expand Down
13 changes: 13 additions & 0 deletions mathmaps/nemeth/rules/nemeth.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,19 @@
"@role=\"prime\"",
"count(children/*)=4"
],
[
"Precondition",
"hyperfraction",
"default",
"self::fraction",
"CQFhyperFraction"
],
[
"Alias",
"hyperfraction",
"self::fraction",
"contains(@grammar, \"hyperfraction\")"
],
[
"Precondition",
"fraction",
Expand Down
7 changes: 6 additions & 1 deletion mathmaps/nemeth/rules/nemeth_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,15 @@
"quadruple-prime",
"[t] \"⠄⠄⠄⠄\""
],
[
"Action",
"hyperfraction",
"[p] (layout:beginfraction); [t] CSFopenFraction; [n] children/*[1] (layout:numerator, grammar:hyperfraction); [t] CSFoverFraction; [n] children/*[2] (layout:denominator, grammar:hyperfraction); [t] CSFcloseFraction; [p] (layout:endfraction)"
],
[
"Action",
"fraction",
"[p] (layout:beginfraction); [t] CSFopenFraction; [n] children/*[1] (layout:numerator); [t] CSFoverFraction; [n] children/*[2] (layout:denominator); [t] CSFcloseFraction; [p] (layout:endfraction)"
"[t] CSFopenFraction; [n] children/*[1]; [t] CSFoverFraction; [n] children/*[2]; [t] CSFcloseFraction"
],
[
"Action",
Expand Down
22 changes: 11 additions & 11 deletions mathmaps/nemeth/symbols/math_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -2339,7 +2339,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨"
"default": "⠨⠨"
}
},
"key": "227B"
Expand All @@ -2357,7 +2357,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨"
"default": "⠨⠨"
}
},
"key": "227D"
Expand All @@ -2375,7 +2375,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠈⠱"
"default": "⠨⠨⠈⠱"
}
},
"key": "227F"
Expand All @@ -2393,7 +2393,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠌⠨"
"default": "⠌⠨"
}
},
"key": "2281"
Expand Down Expand Up @@ -6227,7 +6227,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨"
"default": "⠨⠨"
}
},
"key": "2AB0"
Expand All @@ -6245,7 +6245,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠌⠱"
"default": "⠨⠨⠌⠱"
}
},
"key": "2AB2"
Expand All @@ -6263,7 +6263,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠨⠅"
"default": "⠨⠨⠨⠅"
}
},
"key": "2AB4"
Expand All @@ -6281,7 +6281,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠌⠨⠅"
"default": "⠨⠨⠌⠨⠅"
}
},
"key": "2AB6"
Expand All @@ -6299,7 +6299,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠈⠱⠈⠱"
"default": "⠨⠨⠈⠱⠈⠱"
}
},
"key": "2AB8"
Expand All @@ -6317,7 +6317,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠌⠈⠱⠈⠱"
"default": "⠨⠨⠌⠈⠱⠈⠱"
}
},
"key": "2ABA"
Expand All @@ -6335,7 +6335,7 @@
"category": "Sm",
"mappings": {
"default": {
"default": "⠨⠨⠈⠨⠨"
"default": "⠨⠨⠈⠨⠨"
}
},
"key": "2ABC"
Expand Down
12 changes: 9 additions & 3 deletions ts/speech_rules/nemeth_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export function overBevelledFraction(node: Element): string {
);
}

export function hyperFractionBoundary(node: Element): Element[] {
return LOCALE.MESSAGES.regexp.HYPER ===
MathspeakUtil.fractionNestingDepth(node).toString() ? [node] : [];
}


/**
* Nested Braille radicals in Nemeth putting together the nesting counter with
* the correct indicator string as postfix.
Expand Down Expand Up @@ -321,14 +327,14 @@ export function relationIterator(
(first &&
content.parentNode.parentNode &&
content.parentNode.parentNode.previousSibling)
? [AuditoryDescription.create({ text: '⠀' + base }, {})]
? [AuditoryDescription.create({ text: LOCALE.MESSAGES.regexp.SPACE + base }, {})]
: [];
const right =
(rightChild && DomUtil.tagName(rightChild) !== 'EMPTY') ||
(!contentNodes.length &&
content.parentNode.parentNode &&
content.parentNode.parentNode.nextSibling)
? [AuditoryDescription.create({ text: '⠀' }, {})]
? [AuditoryDescription.create({ text: LOCALE.MESSAGES.regexp.SPACE }, {})]
: [];
const descrs = Engine.evaluateNode(content);
first = false;
Expand Down Expand Up @@ -373,7 +379,7 @@ export function implicitIterator(
const right = rightChild && DomUtil.tagName(rightChild) === 'NUMBER';
return contextDescr.concat(
left && right && content.getAttribute('role') === SemanticRole.SPACE
? [AuditoryDescription.create({ text: '⠀' }, {})]
? [AuditoryDescription.create({ text: LOCALE.MESSAGES.regexp.SPACE }, {})]
: []
);
};
Expand Down
1 change: 1 addition & 0 deletions ts/speech_rules/other_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function BrailleRules() {
CSFoverFraction: NemethUtil.overFraction,

CSFoverBevFraction: NemethUtil.overBevelledFraction,
CQFhyperFraction: NemethUtil.hyperFractionBoundary,
// Radical function.
CSFopenRadical: NemethUtil.openingRadical,
CSFcloseRadical: NemethUtil.closingRadical,
Expand Down

0 comments on commit c40b190

Please sign in to comment.