Let one analyzer run another's passes on a node (4.1.0) - #739
Merged
Merged
Conversation
callanalyzer(pnode, concept, "name") runs the named analyzer's passes on the subtree under pnode, in the caller's parse tree and KB. callconcept() gives the called analyzer the concept it was handed. The called analyzer is built on first use and stays in the VTRun registry, together with its .dict and .kbb files read into the shared KB and its *full files registered for lazy lookup. On each call its tokenizer passes are skipped, a dicttok pass looks up the subtree's words (lazy files included) via the new DICTTok::applyToSubtree, G() variables start empty, and no per-pass .tree dumps are written. Self-calls and cycles are refused. CG::openFullDict/openFullKBB now clear the lazy-lookup miss cache, so a word missed before a lazy file was registered is looked up in it. NlpDebug::suspend/resume keep the debugger's pause points off inside a called analyzer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new NLP++ builtin,
callanalyzer(pnode, concept, "name"), lets one analyzer be built from several separately written analyzers that all share one parse tree and one knowledge base.callconcept()is how the called analyzer gets the concept it was handed.pnode(its rules seepnode's children, andpnroot()ispnode). Its changes stay in the caller's tree.callconcept()returns the caller's concept itself; nothing is copied.kb/user.dictand.kbbfiles into the shared KB;*fullfiles are registered for lazy lookup. Later calls read nothing. Its.kbfiles are not read, because they would add every attribute value a second time.dicttok/dicttokzpass instead looks up the subtree's words, lazy*fullfiles included, gives them their dictionary attributes, and matches phrases (DICTTok::applyToSubtree);G()variables start empty;G("$apppath")is the called analyzer's folder; no per-pass.treedumps, which are named by pass number and would overwrite the caller's.err.log.Also
CG::openFullDict/openFullKBBnow clearfullMissCache_. A word looked up before a lazy file was registered was cached as absent and never searched for in that file.NlpDebug::suspend/resume: the debugger does not stop inside a called analyzer, and a nested analysis no longer leaves it disarmed.Tests
New CI step (Windows and Linux) with fixtures
tests/call-analyzerandtests/call-analyzer-callee. It checks that only the given nodes change, a word found only in the callee's lazyshades-full.dictis resolved, the callee loads once for two calls,G()stays separate, and self-calls, back-calls and unknown names return 0.Locally on Windows: every fixture step in
build-windows.ymlpasses, including the rule-level debugger step, and parse-en-us produces afinal.treebyte-identical to the golden copy.Not tested: compiled analyzers calling
callanalyzer(theArunforms build but have not been run), and a call made with a debugger attached.Known, not fixed here
An analyzer whose
kb/userholds.dictfiles but nohier.kbsegfaults on its first attribute add (seen while writing the fixtures, which now include ahier.kb).Help pages: separate PR in VisualText/visualtext-files; merge it after this ships.
🤖 Generated with Claude Code