From dd3e473c347b3712b6b0d3af8331f0c5333f11d7 Mon Sep 17 00:00:00 2001 From: zorkow Date: Thu, 6 Jun 2024 14:44:37 +0200 Subject: [PATCH 1/7] fix nonbreaking spaces issue in function names --- ts/semantic_tree/semantic_node.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/semantic_tree/semantic_node.ts b/ts/semantic_tree/semantic_node.ts index a1a9bc2c1..531484048 100644 --- a/ts/semantic_tree/semantic_node.ts +++ b/ts/semantic_tree/semantic_node.ts @@ -367,6 +367,7 @@ export class SemanticNode { if (this.textContent === content) { return; } + content = content.replace(/\s/g, ' '); const meaning = SemanticMap.Meaning.get(content); this.textContent = content; this.role = meaning.role; @@ -667,7 +668,7 @@ export class SemanticNode { */ private addAnnotation_(domain: string, annotation: string) { const content = this.annotation[domain]; - if (content) { + if (content && !content.includes(annotation)) { content.push(annotation); } else { this.annotation[domain] = [annotation]; From a552ecc54414af1a160277867006a0465b6873af Mon Sep 17 00:00:00 2001 From: zorkow Date: Thu, 6 Jun 2024 14:45:00 +0200 Subject: [PATCH 2/7] fix nemeth issue on missing annotation --- ts/speech_rules/nemeth_util.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ts/speech_rules/nemeth_util.ts b/ts/speech_rules/nemeth_util.ts index adb25db3e..5604066e5 100644 --- a/ts/speech_rules/nemeth_util.ts +++ b/ts/speech_rules/nemeth_util.ts @@ -331,7 +331,7 @@ export function relationIterator( const childNodes = nodes.slice(0); let first = true; let parentNode = nodes[0].parentNode.parentNode as Element; - let match = parentNode.getAttribute('annotation').match(/depth:(\d+)/); + let match = parentNode.getAttribute('annotation')?.match(/depth:(\d+)/); let depth = match ? match[1] : ''; let contentNodes: Element[]; if (nodes.length > 0) { @@ -454,7 +454,7 @@ export function contentIterator( ) { let func = suCI(nodes, context); let parentNode = nodes[0].parentNode.parentNode as Element; - let match = parentNode.getAttribute('annotation').match(/depth:(\d+)/); + let match = parentNode.getAttribute('annotation')?.match(/depth:(\d+)/); let depth = match ? match[1] : ''; return function() { const descrs = func(); From 0129d5386d893365b974b0a30ca0208adcea1ae0 Mon Sep 17 00:00:00 2001 From: zorkow Date: Thu, 6 Jun 2024 14:45:16 +0200 Subject: [PATCH 3/7] fix limit issue on simple prefix operators (@pkra) --- ts/semantic_tree/semantic_annotator.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ts/semantic_tree/semantic_annotator.ts b/ts/semantic_tree/semantic_annotator.ts index 28398fc03..e0e40fd51 100644 --- a/ts/semantic_tree/semantic_annotator.ts +++ b/ts/semantic_tree/semantic_annotator.ts @@ -44,6 +44,7 @@ export class SemanticAnnotator { */ public annotate(node: SemanticNode) { node.childNodes.forEach(this.annotate.bind(this)); + node.contentNodes.forEach(this.annotate.bind(this)); node.addAnnotation(this.domain, this.func(node)); } } @@ -81,6 +82,9 @@ export class SemanticVisitor { for (let i = 0, child; (child = node.childNodes[i]); i++) { result = this.visit(child, result[1] as { [key: string]: any }); } + for (let i = 0, content; (content = node.contentNodes[i]); i++) { + result = this.visit(content, result[1] as { [key: string]: any }); + } return result; } } From bc2a96bb6c3c01b782ab4a7547573e0286908264 Mon Sep 17 00:00:00 2001 From: zorkow Date: Mon, 10 Jun 2024 23:22:42 +0200 Subject: [PATCH 4/7] make space replacement for function lookup less intrusive --- ts/semantic_tree/semantic_node.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ts/semantic_tree/semantic_node.ts b/ts/semantic_tree/semantic_node.ts index 531484048..affa0f7ba 100644 --- a/ts/semantic_tree/semantic_node.ts +++ b/ts/semantic_tree/semantic_node.ts @@ -367,8 +367,7 @@ export class SemanticNode { if (this.textContent === content) { return; } - content = content.replace(/\s/g, ' '); - const meaning = SemanticMap.Meaning.get(content); + const meaning = SemanticMap.Meaning.get(content.replace(/\s/g, ' ')); this.textContent = content; this.role = meaning.role; this.type = meaning.type; From 88954d053d24d33fde5c7da89ac37bf00e12d838 Mon Sep 17 00:00:00 2001 From: zorkow Date: Tue, 11 Jun 2024 18:53:58 +0200 Subject: [PATCH 5/7] improve label propagation heuristic to avoid unit annotation --- ts/semantic_tree/semantic_mathml.ts | 3 +++ ts/speech_rules/clearspeak_util.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ts/semantic_tree/semantic_mathml.ts b/ts/semantic_tree/semantic_mathml.ts index 458207b31..ce31da9ac 100644 --- a/ts/semantic_tree/semantic_mathml.ts +++ b/ts/semantic_tree/semantic_mathml.ts @@ -326,6 +326,9 @@ export class SemanticMathml extends SemanticAbstractParser { } const label = this.parse(children[0]); label.role = SemanticRole.LABEL; + if (label.childNodes[0]?.type === SemanticType.TEXT) { + label.childNodes[0].role = SemanticRole.LABEL; + } const newNode = this.getFactory().makeBranchNode( SemanticType.ROW, this.parseList(children.slice(1)), diff --git a/ts/speech_rules/clearspeak_util.ts b/ts/speech_rules/clearspeak_util.ts index bb732f620..314d0b606 100644 --- a/ts/speech_rules/clearspeak_util.ts +++ b/ts/speech_rules/clearspeak_util.ts @@ -405,7 +405,8 @@ export function isSmallVulgarFraction(node: Element): Element[] { */ function isUnitExpression(node: SemanticNode): boolean { return ( - node.type === SemanticType.TEXT || + (node.type === SemanticType.TEXT && + node.role !== SemanticRole.LABEL) || (node.type === SemanticType.PUNCTUATED && node.role === SemanticRole.TEXT && isNumber_(node.childNodes[0]) && From eff387e7508686bcc1e25958aff2985fe28754f0 Mon Sep 17 00:00:00 2001 From: zorkow Date: Tue, 11 Jun 2024 22:55:52 +0200 Subject: [PATCH 6/7] update test module --- sre-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sre-tests b/sre-tests index 3845f689e..9b9d56ada 160000 --- a/sre-tests +++ b/sre-tests @@ -1 +1 @@ -Subproject commit 3845f689e67e0ed3ffa8b146e1354ea58dfb7a46 +Subproject commit 9b9d56adac5c074e923374a5ba0496c9ade25f23 From d43cfb8e7767aa526d1600af7388066a732855f2 Mon Sep 17 00:00:00 2001 From: zorkow Date: Tue, 11 Jun 2024 23:12:06 +0200 Subject: [PATCH 7/7] update test module --- sre-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sre-tests b/sre-tests index 9b9d56ada..360bc46fe 160000 --- a/sre-tests +++ b/sre-tests @@ -1 +1 @@ -Subproject commit 9b9d56adac5c074e923374a5ba0496c9ade25f23 +Subproject commit 360bc46fee2db8ebaa575a4a347c75ce894c982b