Skip to content

KBFuncs: no wrapped strpiece positions, valid JSON arrays - #44

Merged
ddehilster merged 1 commit into
VisualText:masterfrom
ddehilster:fix/strpiece-length-arithmetic
Oct 19, 2026
Merged

ddehilster merged 1 commit into
VisualText:masterfrom
ddehilster:fix/strpiece-length-arithmetic

Conversation

@ddehilster

@ddehilster ddehilster commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

This brings this repo's KBFuncs.nlp copies in step with the canonical fix in VisualText/visualtext-files#247. Background: since engine 4.2.15 a negative strpiece position counts from the end, so a position computed as strlength(s) - k wraps round when s is short.

One script replaced the functions in every copy, and only where a copy held the known old text, so every copy now has the same code:

  • StripEndDigits: "item" comes back "item", not "ite". A one-letter name no longer depends on -1 wrapping.
  • SeparateConCount (where present): only trailing digits count. "a1b2" gives "a1b" and 2, not "a1" and 12.
  • JsonKBRecurse (where present): an array followed by a plain sibling is now valid JSON, and adjacent arrays with different names stay separate. The stray hier.txt debug file is gone. Shapes that were already valid JSON are written byte for byte as before. This matches the jsonwrite fix in jsonwrite writes valid, separate arrays (4.2.37) nlp-engine#796.

Changed: files and business, which only use StripEndDigits. The nlp-tutorials, nlpfix-analyzers and parse-en-us submodules have their own PRs.

Output unchanged. Every analyzer here was run on its inputs before and after with engine 4.2.36, and all output files were compared. The only difference was the analyzer's own path in init.log.

🤖 Generated with Claude Code

Brings this repo's KBFuncs.nlp copies in step with the canonical
visualText/spec/KBFuncs.nlp fix (VisualText/visualtext-files, same
branch name). The functions were replaced by one script, and only where
a copy held the known old text, so every copy got the same code:

- StripEndDigits: a one-letter name only came back right because
  position -1 wraps since engine 4.2.15, and a name with no trailing
  digits lost its last letter ("item" -> "ite"). It now counts positions
  up from 0.
- SeparateConCount (where present): only the trailing digits count
  ("a1b2" is "a1b" + "2", not "a1" + "12"); no position arithmetic that
  can go negative.
- JsonKBRecurse (where present): an array followed by a plain sibling is
  now valid JSON, adjacent arrays with different names stay separate,
  and the stray hier.txt debug file is gone. Shapes that were valid JSON
  are written byte for byte as before; matches the jsonwrite builtin fix
  in VisualText/nlp-engine#796.

Each analyzer was run on its inputs before and after with engine 4.2.36:
output unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ddehilster
ddehilster merged commit 04acbfd into VisualText:master Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant