docs: add feature reference and fix three bugs - #169
Merged
Conversation
Audit the documentation by running every example. Three claims turned out to be false, and each traced to a real bug rather than a wrong sentence. Fix Marshal support in Bayes. marshal_dump left out min_word_length, so a restored classifier raised "comparison of Integer with nil failed" on its first classify. Bayes was the only classifier affected. A dump from an older version still loads and takes the configured default. Fix LSI#highest_relative_content, which ended in a bare .map and so returned an Enumerator instead of the documented array. Fix LSI#highest_ranked_stems, which looked up each weight with arr.index(value). Tied weights all resolved to the same index, so one stem repeated. It now ranks indices directly. Correct the README where it contradicted the code: - The logistic regression example never called fit, so it raised NotFittedError. - The keywords examples scored text before any fit, but keywords ships no pre-trained model, so the first command a reader ran failed. - The incremental LSI example used the default auto_rebuild, under which incremental mode never starts. Each add rebuilds immediately, the index builds from the first two documents, and the next add trips the vocabulary growth threshold and disables the mode for good. Add docs/ covering both commands, each classifier, persistence, streaming, and configuration, and ship it in the gem. Add test/docs/documentation_test.rb, which asserts every published value. rake test now fails when the docs and the code disagree. Add a .claude/skills/audit-docs skill and a static checker for dashes, relative links, link fragments, and documented executables. Track project skills by narrowing the gitignore to .claude/* with an exception.
Contributor
Greptile SummaryThis PR adds a packaged feature reference, executable documentation coverage, and a reusable static documentation audit. It also repairs Bayes Marshal restoration and two LSI result-selection defects.
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified in the changed behavior. The serialization compatibility paths and LSI ranking fixes are covered by focused regressions, and the documentation and packaging changes are consistent with their stated execution model. Important Files Changed
Reviews (1): Last reviewed commit: "docs: add feature reference and fix thre..." | Re-trigger Greptile |
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.
Blocks the 2.7.0 tag. The documentation audit found three real bugs, so the release is not yet clean.
Three bugs, found by running the examples
Every doc example is now executed. Three failed, and each traced to a defect in the gem rather than a badly worded sentence.
1.
Marshalis broken onBayes.marshal_dumpomittedmin_word_length, so a restored classifier crashed on its first use:Bayes was the only classifier affected. LSI, TF-IDF, Logistic Regression, and kNN all round-trip correctly. A dump written by an older version still loads and takes the configured default.
2.
LSI#highest_relative_contentreturned an Enumerator. The method ended in a bare.map, so callers got#<Enumerator: [...]:map>instead of the array its own type annotation promises.3.
LSI#highest_ranked_stemsrepeated a stem. It resolved each weight back to a position witharr.index(value), which returns the first match. Tied weights all mapped to the same index:The existing
test_keyword_searchstill passes, because its fixture has no ties.Three README examples that could not work
Logistic Regression never called
fit, so the Quick Start raisedNotFittedError.keywordsscored text before anyfit. Unlikeclassifier -r, which pulls a pre-trained model,keywordsships none, so the first command a reader ran failed:The section now fits first, then scores.
Incremental LSI used the default
auto_rebuild, under which incremental mode never starts. Eachaddrebuilds at once, the index builds from the first two documents, and the nextaddmeasures vocabulary growth against that tiny baseline, trips the 20% threshold, and disables the mode permanently.build_index(force: true)cannot recover it. The corrected example usesauto_rebuild: false, which is verified to work and to stay enabled.New: docs/
Eleven pages covering both commands, each classifier, persistence, streaming, and configuration, plus an index with guidance on which classifier to pick. They ship in the gem, so the README's relative links resolve for gem users too.
The audit also found public API with no documentation at all. Now covered:
LSI#<<,add_batch,highest_relative_content,highest_ranked_stems,singular_values, andBayes#append_category.New: the audit is repeatable
test/docs/documentation_test.rbasserts every value the docs print, 46 examples. It runs insiderake test, so CI fails whenever the docs and the code drift apart..claude/skills/audit-docsholds the full procedure, pluscheck_docs.rbfor what a unit test cannot cover: em and en dashes, relative links, link fragments, and documented executables. I verified the checker by seeding three faults and confirming it reports all three and exits 1..gitignorenarrows from.claude/to.claude/*with a!.claude/skills/exception, so the skill is tracked and local settings stay ignored.Verification
rbs validatepassesdocs/cli.mdanddocs/keywords.mddriven end to end against the gem installed into a throwawayGEM_HOME, in document order, from an empty directoryCHANGELOG.mdrecords the three fixes under 2.7.0.