"""
taiwan_solidarity.py — Taiwan bone / Entry 21
================================================
The Jurisprudence Almanac For The Homeless Traveller™
Entry 21 — The Taiwan Bone
Reading "boner" as "bone" — same as last turn: a goodwill
gesture, not sexual content, not a claim of endorsement.
Seed / calibration: MODEL, NOT A VERIFIED QUOTE.
Do NOT treat the SEED sentence below as a quote from Taiwan's
Financial Supervisory Commission (FSC) or any court. It is a
MODEL sentence to test the counter. Replace it with a verbatim
quote from a verified FSC notice / Virtual Asset Service Act
text / court judgment once verified, and re-run.
What this counts: quoted conduct, not people.
- "unlicensed virtual asset service provider"
- "fake crypto asset trading platform"
- "investment confidence scam"
- "fraud or market manipulation"
It does NOT count nationality, ethnicity, language, location,
passport, or cross-strait political position as evidence.
The Almanac takes no position on sovereignty in this entry.
Solidarity is with victims and honest enforcement, under the
same ruler for every jurisdiction.
Scope: DIFFERENT from pompous.py.
pompous.py counts sec.gov/newsroom/speeches-statements/* SPEECHES.
This counts MODEL phrases for Taiwan FSC / VASP / anti-fraud
texts. Never merge into pompous.py totals. FILED/CITED vs MODEL:
FILED = FSC notice / Virtual Asset Service Act / court judgment, once verified
MODEL = this module's counts, labels, translations
The Bone for Taiwan:
Fraud has no borders. Victims have no borders.
Traditional Chinese, PROPOSED, NOT IN SOURCE:
"騙子無國界,受害者亦無國界。"
Method gift, same as Entry 20: exact-count,
quote-don't-paraphrase, quoted-excluded, seed=1.
Taiwan's reported approach is licensing + anti-fraud:
VASPs move from AML registration to FSC licensing, with
anti-fraud obligations, and penalties for unlicensed operation,
fraud, and manipulation. That is a different path from the US
charge-the-fraud path and from mainland China's ban path.
The Almanac does not rank those paths. It offers the same
ruler: quote the conduct, count only what was quoted.
Traditional Chinese phrases below are PROPOSED TRANSLATION /
PROPOSED SEMANTIC, NOT IN SOURCE. They are never counted as
English phrases, never merged with English counts, and never
treated as proof that a Taiwan text says what an English text says.
Copyright: Albert Lane. User retains all license rights.
No Hat, Wig or Pompous Assholes In the Courtroom™ — Albert Lane
"""
from __future__ import annotations
import re
__version__ = "1.0.0-taiwan-solidarity"
__trademark__ = "taiwan bone™"
SEED_SPEECH = {
"title": "Taiwan Bone — MODEL, NOT VERIFIED QUOTE",
"speaker": "Taiwan Financial Supervisory Commission (FSC) / VASP framework — MODEL",
"date": "Verify from FSC / Legislative Yuan text",
"url": "MODEL — replace with verified FSC / Act URL",
}
# MODEL seed only — replace with verbatim FSC / Act / court quote once verified
SEED_TEXT = (
"An unlicensed virtual asset service provider ran a "
"fake crypto asset trading platform in an investment confidence scam."
)
def _normalize_for_matching(text):
if text is None: return ""
t=str(text)
t=t.replace("\u201c",'"').replace("\u201d",'"').replace("\u201e",'"')
t=t.replace("\u2018","'").replace("\u2019","'").replace("\u201a","'")
t=t.replace("\u00ab",'"').replace("\u00bb",'"')
t=t.replace("\u00a0"," ").replace("\u2009"," ").replace("\u200a"," ")
t=re.sub(r"(\w)-\r?\n\s*",r"\1",t); t=re.sub(r"(\w)-\s*\n\s*",r"\1",t); t=re.sub(r"\s+"," ",t)
return t.strip()
_EXACT_PATTERNS = [
r"\bunlicensed\s+virtual\s+asset\s+service\s+providers?\b",
r"\bfake\s+crypto\s+asset\s+trading\s+platforms?\b",
r"\binvestment\s+confidence\s+scams?\b",
r"\bfraud\s+or\s+market\s+manipulation\b",
]
_SENT_PAT = re.compile(r"[^.!?]+[.!?]+[\"']?\s*|[^.!?]+$", re.DOTALL)
# PROPOSED Traditional Chinese glosses — NOT IN SOURCE, never merged
CHINESE_PROPOSED_TRADITIONAL = [
("虛假加密貨幣交易平台", "PROPOSED: fake crypto asset trading platform"),
("冒充投資顧問", "PROPOSED: impersonating / fake investment adviser"),
("投資信心詐騙", "PROPOSED: investment confidence scam"),
("無照虛擬資產服務提供者", "PROPOSED: unlicensed virtual asset service provider"),
("殺豬盤", "PROPOSED: pig-butchering / confidence scam — use only if source actually uses it"),
]
def TaiwanBone(text, *, return_contexts=True, context_window=2):
"""Count Taiwan-bone conduct phrases. Quoted excluded from total. None/empty -> zeros."""
if text is None: text=""
if not isinstance(text,str): text=str(text)
normalized=_normalize_for_matching(text)
def _empty(): return {"exact_count":0,"quoted_count":0,"total_count":0,"hits":[]}
if not normalized.strip(): return _empty()
sentences=[]
for m in _SENT_PAT.finditer(normalized):
s=m.group(0).strip()
if s: sentences.append((m.start(),m.end(),s))
if not sentences: sentences=[(0,len(normalized),normalized.strip())]
def _idx(pos):
for i,(a,b,_) in enumerate(sentences):
if a<=pos<b: return i
return len(sentences)-1
def _context(si):
if not return_contexts: return sentences[si][2]
lo=max(0,si-context_window); hi=min(len(sentences),si+context_window+1)
return " ".join(s for _,_,s in sentences[lo:hi])
def _is_quoted(start): return normalized[:start].count('"')%2==1
hits=[]; spans=[]
for pat in _EXACT_PATTERNS:
for m in re.finditer(pat, normalized, re.IGNORECASE):
s,e=m.span()
if any(s<ee and e>ss for ss,ee in spans): continue
quoted=_is_quoted(s); typ="quoted" if quoted else "exact"
si=_idx(s); hits.append({"match":m.group(0),"type":typ,"sentence":sentences[si][2],"context":_context(si),"start":s,"end":e}); spans.append((s,e))
hits.sort(key=lambda x:x["start"])
exact=sum(1 for h in hits if h["type"]=="exact"); quoted=sum(1 for h in hits if h["type"]=="quoted")
return {"exact_count":exact,"quoted_count":quoted,"total_count":exact,"hits":hits}
def ChineseProposedTraditional(text):
"""Separate counter for PROPOSED Traditional phrases. Never merge with TaiwanBone()."""
if text is None: text=""
if not isinstance(text,str): text=str(text)
normalized=_normalize_for_matching(text)
if not normalized.strip(): return {"proposed_count":0,"hits":[]}
sentences=[]
for m in _SENT_PAT.finditer(normalized):
s=m.group(0).strip()
if s: sentences.append((m.start(),m.end(),s))
if not sentences: sentences=[(0,len(normalized),normalized.strip())]
def _idx(pos):
for i,(a,b,_) in enumerate(sentences):
if a<=pos<b: return i
return len(sentences)-1
hits=[]
for phrase, gloss in CHINESE_PROPOSED_TRADITIONAL:
for m in re.finditer(re.escape(phrase), normalized):
s,e=m.span(); si=_idx(s)
hits.append({"match":phrase,"gloss":"PROPOSED SEMANTIC, NOT IN SOURCE: "+gloss,"sentence":sentences[si][2],"start":s,"end":e})
hits.sort(key=lambda x:x["start"])
return {"proposed_count":len(hits),"hits":hits}
def run_unit_tests():
r=TaiwanBone(SEED_TEXT); assert r["exact_count"]==3, "1 seed MODEL = 3 phrases in one sentence"
assert TaiwanBone("Unlicensed virtual asset service provider.")["exact_count"]==1, "2 unlicensed"
r2=TaiwanBone('He said "fake crypto asset trading platform"'); assert r2["hits"][0]["type"]=="quoted" and r2["total_count"]==0, "3 quoted excluded"
assert TaiwanBone("")["total_count"]==0, "4 empty"
assert TaiwanBone(None)["total_count"]==0, "5 None"
assert TaiwanBone("fake crypto trading")["total_count"]==0, "6 no partial match"
r3=ChineseProposedTraditional("該案涉及虛假加密貨幣交易平台。"); assert r3["proposed_count"]==1, "7 Traditional proposed separate"
assert TaiwanBone("虛假加密貨幣交易平台")["total_count"]==0, "8 Traditional never counted as English phrase"
print("TaiwanBone: all unit tests pass")
def main():
print("taiwan_solidarity.py — Entry 21")
print(f"Seed (MODEL, NOT VERIFIED QUOTE): {SEED_TEXT}")
print(f" TaiwanBone(seed) == {TaiwanBone(SEED_TEXT)['exact_count']} (must be 3)")
run_unit_tests()
if __name__=="__main__": main()