Repository navigation
Analyze one text zone at a time (zone _TEXTZONE) - #12
Merged
Merged
Conversation
The passes after zaplines now run once per text zone (paragraph), and each zone's tree is freed when its passes are done, so memory goes by the largest paragraph rather than the whole document: Pride and Prejudice peaks at 150 MB instead of 473 MB, with 99.995% of its 151,646 tags the same. Needs engine 4.2.47+ (4.2.49+ compiled). Passes after endzone run once, after the last zone: trav_dict, ne_xml, fin, displayKB, and docfin, a new pass for the end-of-document work of two per-zone passes (pos_out_noscore's postofile(), xmlrecursive's xmlend/closefile). Per-zone passes write their headers once per document (rule_out, ne_out, buff_out, xmlrecursive, and pos_out_noscore's KB reset and treebank blurb), and pos_out_noscore carries its line state from zone to zone, so tags.txt, pos.txt, np.txt, rule.txt and the KB are byte-identical to an unzoned run on the three test inputs. The one difference in them: KB facts that later passes learn in one paragraph are known to the next one's earlier passes, so in business.txt AMRP and TAI get stems instead of being unknown. Co-Authored-By: Claude Opus 5.5 <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.
parse-en-us now runs its passes after
zaplinesonce per text zone (paragraph). Each zone's tree is freed when its passes finish, so memory follows the largest paragraph instead of the whole document.The two runs were on different builds (x64 earlier, x86 now), so the times are only roughly comparable.
Requires engine 4.2.47 or later, or 4.2.49 or later when compiled (VisualText/nlp-engine#807). Please merge after 4.2.49 is released: older engines don't know the
zoneline.What changed
analyzer.seq:zone _TEXTZONEline afterzaplines;endzoneline, after whichdocfin,trav_dict,ne_xml,finanddisplayKBrun once, after the last zone.docfinpass: the end-of-document work of two per-zone passes,pos_out_noscore'spostofile()andxmlrecursive'sxmlend()/closefile().G()flags.G()resets per input file, so the guards work the same with or without zoning:rule_outne_outbuff_outxmlrecursivepos_out_noscore(its POS-list reset and treebank blurb)pos_out_noscorecarries its line state from zone to zone, so the blank lines intags.txtcome out the same.Same output
On
business.txt,doj.txtandtest.txt, compared with an unzoned run on the same engine:tags.txt,pos.txt,np.txt,rule.txtand the final KB dump;doj.txtandtest.txt: every output file the same;business.txt: KB facts that later passes learn in one paragraph are now known to the next paragraph's early passes, so AMRP and TAI get stems instead of being unknown. That changesclause_ne.txt,out.xmlandunknown.txt, and removes three "Unhandled period" and three "More than one POS in caps list" messages;dump.txt,wsd.txt) list the same lines, interleaved per zone.The KB dump is now
ana137.kbb, notana136.kbb, becausedocfinadds a pass.Trade-off in the debugger
With
-DEV, passes after the zone line write trees only for the first three zones (z001-ana###.tree,z002-…,z003-…), andfinal.treekeeps each paragraph as a stub. Clicking such a pass in VS Code (4.3.18+) opens the first zone's tree. On a multi-paragraph input you no longer see a later paragraph at every pass. To debug one, delete thezoneandendzonelines; the analyzer runs the same either way.🤖 Generated with Claude Code