fix(mining): add tech-term stopwords and sentence-start filter to entity detector#780
Open
arnoldwender wants to merge 2 commits intoMemPalace:developfrom
Open
Conversation
cbdfcdb to
886ce52
Compare
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
Fixes #476 —
entity_detector.pywas flagging common technical terms (e.g.Handler,Service,Node,Client) as entity candidates, and capturing sentence-opening words likeOnethat happen to be capitalized.Changes
mempalace/entity_detector.py_TECH_STOPWORDSfrozenset (~60 architecture/runtime/doc terms) merged intoSTOPWORDSviaSTOPWORDS = STOPWORDS | _TECH_STOPWORDSre.findallloop inextract_candidates()withre.finditerthat checks the 50-character window before each match; words at position 0 or immediately following.,!,?, or\nare skipped (sentence-start filter)_SENTENCE_END_REcompiled regex constant for the sentence-end checktests/test_entity_detector.pytest_extract_candidates_finds_frequent_namesandtest_detect_entities_with_person_fileto place names mid-sentence (after an opener like "Today", "Later", etc.) so the sentence-start filter does not discard them — reflects correct expected behaviorTest plan
uv run pytest tests/test_entity_detector.py -v— 32/32 passedHandler,Service,Node,Clientno longer appear indetect_entities()output on a typical codebase READMEOne,Twoat sentence start are no longer capturedCloses #476