From 468d7125a588a0f74102362cf4278515c66559e5 Mon Sep 17 00:00:00 2001 From: zorkow Date: Wed, 13 Nov 2024 15:36:36 +0100 Subject: [PATCH 1/4] fix reported by pkra 2024/08/29 --- ts/semantic_tree/semantic_processor.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ts/semantic_tree/semantic_processor.ts b/ts/semantic_tree/semantic_processor.ts index c70721622..b31744b84 100644 --- a/ts/semantic_tree/semantic_processor.ts +++ b/ts/semantic_tree/semantic_processor.ts @@ -3195,12 +3195,15 @@ export class SemanticProcessor { newNodes.push(SemanticProcessor.getInstance().row(firstComp)); } } - return [ - SemanticProcessor.getInstance().punctuatedNode_(newNodes, partition.rel) - ]; + return (newNodes.length === 1 && partition.rel.length === 1) ? newNodes : + [ + SemanticProcessor.getInstance().punctuatedNode_(newNodes, partition.rel) + ]; } // TODO: Refine roles to reflect same roles. Find sequences of punctuation + // TODO: Extend punctuated nodes to include elements outside the current scope + // Example: a\mathinner{...\_\_\_} // elements and separate those out or at least rewrite ellipses. /** * Create a punctuated node. From 22b46788e90a1922f7a172670721fb3b565834c6 Mon Sep 17 00:00:00 2001 From: zorkow Date: Wed, 13 Nov 2024 15:40:33 +0100 Subject: [PATCH 2/4] add explicit rebuild to cli --- ts/common/cli.ts | 3 +++ ts/common/processor_factory.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ts/common/cli.ts b/ts/common/cli.ts index 4a1bc634e..1d390b8ad 100644 --- a/ts/common/cli.ts +++ b/ts/common/cli.ts @@ -303,6 +303,9 @@ export class Cli { .option('-m, --mathml', 'Generate enriched MathML.', () => processor('enriched') ) + .option('-u, --rebuild', 'Rebuild semantic tree from enriched MathML.', () => + processor('rebuild') + ) .option( '-t, --latex', 'Accepts LaTeX input for certain locale/modality combinations.', diff --git a/ts/common/processor_factory.ts b/ts/common/processor_factory.ts index 4c849b2f9..1d50d4e2e 100644 --- a/ts/common/processor_factory.ts +++ b/ts/common/processor_factory.ts @@ -27,6 +27,7 @@ import * as SpeechGeneratorFactory from '../speech_generator/speech_generator_fa import * as SpeechGeneratorUtil from '../speech_generator/speech_generator_util.js'; import * as WalkerFactory from '../walker/walker_factory.js'; import * as WalkerUtil from '../walker/walker_util.js'; +import { RebuildStree } from '../walker/rebuild_stree.js'; import * as DomUtil from './dom_util.js'; import { Engine, SREError } from './engine.js'; import * as EngineConst from '../common/engine_const.js'; @@ -272,6 +273,19 @@ set( }) ); +// rebuild: Rebuild semnatic tree from Enriched MathML node. +set( + new Processor('rebuild', { + processor: function (expr) { + let rebuilt = new RebuildStree(DomUtil.parseInput(expr)); + return rebuilt.stree.xml(); + }, + pprint: function (tree) { + return DomUtil.formatXml(tree.toString()); + } + }) +); + set( new Processor('walker', { processor: function (expr: string) { From 319908cbf63e721e07b91dc221580f2ea417242e Mon Sep 17 00:00:00 2001 From: zorkow Date: Wed, 13 Nov 2024 23:31:56 +0100 Subject: [PATCH 3/4] Update tests. --- sre-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sre-tests b/sre-tests index 5cce73574..e742c40fd 160000 --- a/sre-tests +++ b/sre-tests @@ -1 +1 @@ -Subproject commit 5cce73574d2c0bef209db33c899379685bf80289 +Subproject commit e742c40fd21b2c198f6b2c3544df52ebd0bc852a From dbb5beb01d4e3d160f6bc7fd93a851eddb4dda56 Mon Sep 17 00:00:00 2001 From: zorkow Date: Thu, 14 Nov 2024 09:57:15 +0100 Subject: [PATCH 4/4] update github actions for tests --- .github/workflows/node.js.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index cbb40468d..66abedbdd 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -17,7 +17,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 name: Install pnpm with: version: 8 @@ -27,7 +27,7 @@ jobs: run: pnpm i; pnpm build - name: Upload build - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: sre-library path: | @@ -47,14 +47,14 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 name: Install pnpm with: version: 8 run_install: false - name: Downloading the build - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: sre-library