Does light charge the quons? › Files cited on the page › check_section12_fable/
quotes_check.py
#!/usr/bin/env python3
"""r28: find every copy of Doug's quoted messages in the repository's text files and report variants.
For each distinctive phrase, every line containing it is found; the quoted span (between the nearest
curly or straight double quotes around the phrase) is extracted; distinct variants are printed with
their files and line numbers."""
import os, re, sys, collections
ROOT = '/home/doug/aetherscience.org/aspden-investigation'
PHRASES = [
'lets do something simpler',
'proceed, commit the locks',
'whittaker book a complete review',
'No the whittaker document deserves',
'This seat does it, reviews wait',
'Then I want to extend the atom/molecule',
'fine the comments are low priority',
'Make sure we write up this model',
'WE know that light slows down',
'fable is ready for your review',
'fable finished task 1',
'Proceed and describe maccullagh',
'resists compression and stays uniform',
]
EXTS = ('.md', '.txt', '.py')
SKIP = ('/site/', '/.git/', '/__pycache__', '/qwen', '/Qwen')
def files():
for dp, dn, fn in os.walk(ROOT):
if any(s in dp + '/' for s in SKIP):
continue
for f in fn:
if f.endswith(EXTS):
yield os.path.join(dp, f)
QUOTE_CHARS = '"“”'
def extract(line, idx):
# find nearest quote char before idx and after idx+len
left = max([line.rfind(q, 0, idx) for q in QUOTE_CHARS])
rights = [line.find(q, idx) for q in QUOTE_CHARS]
rights = [r for r in rights if r >= 0]
right = min(rights) if rights else -1
if left < 0 or right < 0:
return None
return line[left + 1:right]
for ph in PHRASES:
variants = collections.defaultdict(list)
for path in files():
try:
with open(path, encoding='utf-8', errors='replace') as fh:
for n, line in enumerate(fh, 1):
i = line.find(ph)
if i < 0:
continue
q = extract(line.rstrip('\n'), i)
key = q if q is not None else '<unquoted>: ' + line.strip()[:160]
variants[key].append(f'{os.path.relpath(path, ROOT)}:{n}')
except OSError:
pass
print('=' * 100)
print('PHRASE:', ph, '| distinct variants:', len(variants))
for k, v in sorted(variants.items(), key=lambda kv: -len(kv[1])):
print('-' * 60)
print(repr(k))
for loc in v:
print(' ', loc)