Fix subscripted-variable false positives; finalize plugin metadata
verify-calculations.sh mistook subscripted/numbered variables (x_1, x1, 3x_1) for bare numeric equations, flagging e.g. "x_1 = 0" as the false claim "1 = 0". The single-letter variable regex only excluded adjacent letters, not trailing digits/underscores, and the prose segment extractor could start a fresh match right after such a break, mining a free digit out of the identifier. Also carries over the author/repository metadata and the SSH-vs-HTTP install note for the Forgejo marketplace (DISABLE_HTTP_GIT blocks the https URL; the ssh:// path has no /forgejo/ segment). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
318644f4b0
commit
f672241e9c
4 changed files with 38 additions and 5 deletions
|
|
@ -185,9 +185,20 @@ MATH_RUN = re.compile(r'(?:[0-9]|\bmod\b|\bphi\b|\bgcd\b|\blcm\b|[+\-*/^()≡=,%
|
|||
def extract_segments(line):
|
||||
"""Pull the mathematical runs out of a line that also carries prose, so
|
||||
`Euler's theorem gives 8^6 mod 15 = ... = 4 mod 15.` still gets checked
|
||||
instead of being skipped because the sentence as a whole won't parse."""
|
||||
instead of being skipped because the sentence as a whole won't parse.
|
||||
|
||||
A letter breaks a run (so identifiers don't get read as arithmetic), but
|
||||
a digit/underscore right after it doesn't - so for `x_1 = 0` the `_`
|
||||
broke the run and the following `1` started a *new* one, mining the
|
||||
bogus standalone claim `1 = 0` out of a variable name. A run that starts
|
||||
right after a letter/digit/underscore is such a fragment, chopped out of
|
||||
a longer identifier, not a real standalone number - discard it instead
|
||||
of checking it."""
|
||||
segments = []
|
||||
for m in MATH_RUN.finditer(line):
|
||||
start = m.start()
|
||||
if start > 0 and re.match(r'[a-zA-Z0-9_]', line[start - 1]):
|
||||
continue
|
||||
seg = m.group(0).strip(' ,;:.')
|
||||
if not seg or not re.search(r'≡|=', seg):
|
||||
continue
|
||||
|
|
@ -284,8 +295,13 @@ def verify_claim(line):
|
|||
# meaningless and slow enough to blow the hook's timeout.
|
||||
if re.search(r'[a-zA-Z]{2,}', re.sub(r'\b(mod|phi|gcd|lcm)\b', '', body)):
|
||||
return ('skip', None)
|
||||
if len(parts) == 2 and re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z])', body):
|
||||
var = re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z])', body).group(0)
|
||||
# A trailing digit/underscore must also break the match (not just a
|
||||
# trailing letter), so a subscripted name like `x_1` or `x1` isn't
|
||||
# mistaken for the lone variable `x` with its subscript silently
|
||||
# dropped. A LEADING digit is fine and must stay allowed: `2x` is
|
||||
# ordinary coefficient notation for `2*x`.
|
||||
if len(parts) == 2 and re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z0-9_])', body):
|
||||
var = re.search(r'(?<![a-zA-Z])[a-zA-Z](?![a-zA-Z0-9_])', body).group(0)
|
||||
if var in ('e', 'I', 'N', 'S', 'O'):
|
||||
return ('skip', None)
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue