fix(way-match): address 6 code review items from PR #15#23
Merged
Conversation
- Fix body_start pointer arithmetic in suggest mode (#18): use +4 for \n--- then optionally skip trailing newline, instead of assuming +5 - Move large stack arrays to heap (#16, #21): SuggestEntry[], vocab_words[], unused_words[] in cmd_suggest (~2.1MB) and TokenList in index_document (~512KB) now use calloc/free - Fix JSON parser substring matching (#17): json_get_string and json_get_number now verify matched "key" is followed by colon (key position), preventing false matches against values
- Document why NCD fallback uses hardcoded 0.58 threshold (#19): BM25 and NCD scales don't map cleanly, fixed value tuned against test corpus - Fix find_best_match to return highest-scoring way (#20): BM25 path now scores all ways and returns best match above threshold; NCD keeps first-match behavior (binary scorer)
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.
Summary
Addresses all 6 code review issues filed after PR #15 merge:
+5on both paths, fallback path only needs+4then optional newline skipcmd_suggest—SuggestEntry[],vocab_words[],unused_words[]nowcalloc/freeTokenListto heap inindex_document— called in loops, safer on heapjson_get_string/json_get_numbernow verify"key"is followed by colon, not matching as a valuefind_best_matchto return highest-scoring way — BM25 scores all ways and picks best, NCD keeps first-matchTest plan
make -f tools/way-match/Makefile localbuilds cleanCloses #16, closes #17, closes #18, closes #19, closes #20, closes #21