Skip to content

fix: read numeric KBB attribute values as numbers, not strings (#439) + 3.7.4 - #688

Merged
ddehilster merged 1 commit into
masterfrom
fix/kbb-numeric-value-typing
Jul 8, 2026
Merged

ddehilster merged 1 commit into
masterfrom
fix/kbb-numeric-value-typing

Conversation

@ddehilster

Copy link
Copy Markdown
Member

Summary

Fixes the engine (read) half of #439: .kbb attribute values that are numeric were being stored as strings.

Root cause

CG::parseKBBLine stored every attribute value via addSval (string). But num/float values are serialized unquoted in a KBB, so on read they came back as the string "42" rather than the number 42 — the KBB round-trip flattened all types to strings.

Fix (read side)

An unquoted value that is numeric is now stored via addVal (number); a double-quoted value (openDouble) is always kept as a string. So:

KBB value Stored as
count=42 (unquoted, numeric) number ✅ (was string)
price=3 number ✅
color=red (unquoted, non-numeric) string
label="12345" (quoted) string ✅ (quoted stays string)

Verified by loading a KBB and checking attrtype()/getnumval(). No regression: emailaddress and telephone (real .kbb country lists) still load and extract.

The other half lives in the analyzers repo

The write side is NLP++ code — SaveKB in the KBFuncs.nlp library (package-analyzers), not the engine. It already writes num/float unquoted, but string values go through QuoteIfNeeded, which only quotes on space/punct — so a numeric-looking string like 12345 is written unquoted and would now read back as a number. For full round-trip fidelity, SaveKB should quote string values always. That's a separate change in the analyzers repo (I can take it next).

Per the maintainer decision on this issue, unquoted-numeric → number everywhere; existing KBs get the corrected typing (regenerate any that relied on the old string storage).

Bumps NLP_ENGINE_VERSION → 3.7.4.

Fixes #439.

🤖 Generated with Claude Code

CG::parseKBBLine stored every attribute value via addSval (string), so a KBB
value written unquoted -- which is how num/float values are serialized -- was
read back as the string "42" instead of the number 42.

An unquoted value that is numeric is now stored via addVal (number); a
double-quoted value (openDouble) is always kept as a string. This lets a KBB
round-trip num/float vs string instead of flattening everything to strings.

Verified by loading a KBB and checking attrtype():
  count=42        -> num (attrtype 1), getnumval = 42
  price=3         -> num
  color=red       -> string (unquoted, non-numeric)
  label="12345"   -> string (quoted stays string)
No regression: emailaddress and telephone analyzers still load and extract.

Bumps NLP_ENGINE_VERSION to 3.7.4.

Note: the complementary write-side change lives in the analyzers' NLP++ KBFuncs
library (SaveKB): string values must be written quoted (currently QuoteIfNeeded
only quotes on space/punct, so a numeric-looking string is written unquoted).
Tracked separately for the analyzers repo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ddehilster
ddehilster merged commit 0dd214c into master Jul 8, 2026
7 checks passed
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.

KBB file: numeric attribute value stored only as string

1 participant