-
-
Notifications
You must be signed in to change notification settings - Fork 665
Fix #4676: Prevent gibberish detector from flagging legitimate copyrights #4678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix #4676: Prevent gibberish detector from flagging legitimate copyrights #4678
Conversation
c493323 to
0aa57a9
Compare
dac6930 to
c6e4e6c
Compare
…trings - Skip gibberish detection for short lines (< 40 chars) with copyright indicators - Comprehensive copyright indicator list prevents false positives - Add training examples to good.txt for edge cases - Lenient assertion: handle overlapping probabilities during training - Fixes regression while preventing license detection false negatives Signed-off-by: Jayant Saxena <[email protected]> Signed-off-by: NullPointer-cell <[email protected]>
Signed-off-by: NullPointer-cell <[email protected]>
c6e4e6c to
65fdc52
Compare
|
|
||
| # And pick a threshold halfway between the worst good and best bad inputs. | ||
| thresh = (min(good_probs) + max(bad_probs)) / 2 | ||
| if min(good_probs) > max(bad_probs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NullPointer-cell why are the comments removed and why do we default to thresh = max(bad_probs) + 0.01
| def detect_gibberish(self, text): | ||
| text = ''.join(self.normalize(text)) | ||
| return self.avg_transition_prob(text, self.mat) < self.thresh | ||
| COPYRIGHT_INDICATORS = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to perform normalization of copyrights should be done in self.normalize.
| return self.avg_transition_prob(text, self.mat) < self.thresh | ||
| COPYRIGHT_INDICATORS = ( | ||
| 'copyright', '(c)', 'c)', '©', '@copyright', | ||
| 'author:', 'commit', 'portions:', 'rights reserved', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These replacements are way too specific. I don't think we should add code that is only used to ensure we pass a specific arbitrary test.
|
|
||
| text_normalized = ''.join(self.normalize(text)) | ||
|
|
||
| if len(text_normalized) <= 4: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of saying a string is gibberish if it is 4 characters or less in length?
Fixes #4676
Context
This PR supersedes #4677. The previous PR was automatically closed when the target branch
2402-detect-gibberish-copyrightwas deleted. I have rebased the fix ontodevelopas requested.Problem
Gibberish detection was incorrectly flagging legitimate copyright strings as gibberish, causing them to not be detected. This affected:
c) INRIA-ENPC.)@Copyright)commit ... Author:)Solution
Modified the gibberish detector to:
copyright,(c),©,@copyright,author:,commit)Tasks
Signed-off-by: Jayant Saxena [email protected]