v2.1: DB restoration (209k entries), cipher fixes & renames, generator tools
- Restore ~64k entries removed by earlier over-aggressive cleanup (alphabet ends A/B/C/X/Y/Z) plus specialty dbs and Thelemic recovery - Fix case-sensitivity bug in precomputed values (Capitals/Alphanumeric Case Sensitive) - Fix bracket-annotation over-counting in digit-aware ciphers - Sort db alphabetically so added entries surface in match lists - Rename Latin->Latin (Jewish), Alphanumeric Satanic->Alphanumeric Case Sensitive - UI: text selection no longer minimizes the modal - Add tools/ generator to rebuild db.json from db.txt
This commit is contained in:
1 parent
210427478f
commit
d5c5cab184
9 files changed
+64176
-7
No files matched your search
@@ -0,0 +1,34 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v2.1 — Database Restoration & Bug Fixes
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Database grown from ~145,800 to **209,667 curated entries**:
|
||||||
|
- Specialty databases: Liber AL verses, Latin words, Roman numerals, spelled-out
|
||||||
|
numbers/digits, and Illuminati/esoteric terms (~34k).
|
||||||
|
- Restoration of ~20k entries that an earlier over-aggressive cleanup had removed,
|
||||||
|
concentrated in the alphabet "ends" (A, B, C, X, Y, Z) plus O/U/T/I.
|
||||||
|
- Recovery of ~7.7k Thelemic/Hermetic terms (Liber AL, CCRU/Numogram, Rosicrucian,
|
||||||
|
Crowley mottos).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **Case-sensitivity bug** (precomputed `db.json`): Capitals Added, Capitals Mixed,
|
||||||
|
Reverse Caps Added/Mixed, and Alphanumeric Case Sensitive returned incorrect values
|
||||||
|
for capitalized input. The cipher engine now respects the per-cipher case-sensitive flag.
|
||||||
|
- **Bracket-annotation bug**: entries with `[N]` display annotations (Roman numerals,
|
||||||
|
number words) over-counted the bracketed digits in digit-aware ciphers (Alphanumeric
|
||||||
|
Qabbala, Synx, Alphanumeric Primes, etc.). Annotations are now stripped before scoring,
|
||||||
|
matching the live engine.
|
||||||
|
- **Match ordering**: the database is now alphabetically sorted, so newly added entries
|
||||||
|
surface correctly in same-value match lists (previously appended entries were buried).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **Cipher names** (display only — values unchanged):
|
||||||
|
- `Latin` → `Latin (Jewish)`, `Latin Ordinal` → `Latin Ordinal (Jewish Ord.)`,
|
||||||
|
`Latin Reduction` → `Latin Reduction (Jewish Red.)`
|
||||||
|
- `Alphanumeric Satanic` → `Alphanumeric Case Sensitive`
|
||||||
|
- **UI**: selecting/copying text from a result cell no longer minimizes the modal.
|
||||||
|
|
||||||
|
### Tools
|
||||||
|
- Added `tools/generate_db_json.py` (+ `tools/all_ciphers.py`) to rebuild the precomputed
|
||||||
|
`db.json` from `db.txt`. See README.
|
||||||
+4
-4
@@ -495,7 +495,7 @@ cipherList = [
|
|||||||
false
|
false
|
||||||
),
|
),
|
||||||
new cipher(
|
new cipher(
|
||||||
"Latin",
|
"Latin (Jewish)",
|
||||||
"Latin",
|
"Latin",
|
||||||
260,
|
260,
|
||||||
100,
|
100,
|
||||||
@@ -513,7 +513,7 @@ cipherList = [
|
|||||||
false
|
false
|
||||||
),
|
),
|
||||||
new cipher(
|
new cipher(
|
||||||
"Latin Ordinal",
|
"Latin Ordinal (Jewish Ord.)",
|
||||||
"Latin",
|
"Latin",
|
||||||
259,
|
259,
|
||||||
65,
|
65,
|
||||||
@@ -531,7 +531,7 @@ cipherList = [
|
|||||||
false
|
false
|
||||||
),
|
),
|
||||||
new cipher(
|
new cipher(
|
||||||
"Latin Reduction",
|
"Latin Reduction (Jewish Red.)",
|
||||||
"Latin",
|
"Latin",
|
||||||
277,
|
277,
|
||||||
46,
|
46,
|
||||||
@@ -892,7 +892,7 @@ cipherList = [
|
|||||||
false
|
false
|
||||||
),
|
),
|
||||||
new cipher(
|
new cipher(
|
||||||
"Alphanumeric Satanic",
|
"Alphanumeric Case Sensitive",
|
||||||
"Other",
|
"Other",
|
||||||
32,
|
32,
|
||||||
68,
|
68,
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ $(document).ready(function(){
|
|||||||
// Click/tap on table cells to minimize (not on interactive elements)
|
// Click/tap on table cells to minimize (not on interactive elements)
|
||||||
$("body").on("click", "#QueryTable td, #QueryTable th", function (e) {
|
$("body").on("click", "#QueryTable td, #QueryTable th", function (e) {
|
||||||
if ($(e.target).is("input, button, a, select")) return;
|
if ($(e.target).is("input, button, a, select")) return;
|
||||||
|
// Don't minimize if the user is selecting/copying text from the cell
|
||||||
|
if (window.getSelection && window.getSelection().toString().length > 0) return;
|
||||||
if (!$("#queryArea").hasClass("minimizeQuery")) {
|
if (!$("#queryArea").hasClass("minimizeQuery")) {
|
||||||
toggleQueryMinimize();
|
toggleQueryMinimize();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -11,14 +11,14 @@
|
|||||||
<!-- Android Web App - Add to Home Screen -->
|
<!-- Android Web App - Add to Home Screen -->
|
||||||
<link rel="manifest" href="manifest.json" />
|
<link rel="manifest" href="manifest.json" />
|
||||||
|
|
||||||
<script src="config.js?v=2"></script>
|
<script src="config.js?v=3"></script>
|
||||||
<script src="lib/jquery.min.js?v=2"></script>
|
<script src="lib/jquery.min.js?v=2"></script>
|
||||||
<!-- html2canvas v1.0.0-alpha.12 -->
|
<!-- html2canvas v1.0.0-alpha.12 -->
|
||||||
|
|
||||||
<script src="calc/gematria.js?v=2"></script>
|
<script src="calc/gematria.js?v=2"></script>
|
||||||
<script src="calc/calc.js?v=2"></script>
|
<script src="calc/calc.js?v=2"></script>
|
||||||
<script src="calc/init-variables.js?v=2"></script>
|
<script src="calc/init-variables.js?v=3"></script>
|
||||||
<script src="calc/ciphers.js?v=2"></script>
|
<script src="calc/ciphers.js?v=3"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="calc/styles.css?v=2" />
|
<link rel="stylesheet" type="text/css" href="calc/styles.css?v=2" />
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Tools
|
||||||
|
|
||||||
|
## Rebuilding the precomputed database (`db.json`)
|
||||||
|
|
||||||
|
The calculator works out of the box in **live mode** — it loads `db.txt` (one phrase per
|
||||||
|
line) and computes cipher values on the fly. For **instant matching** (~100ms vs 2–5s per
|
||||||
|
query), it can instead load a precomputed `db.json` containing all 69 cipher values per entry.
|
||||||
|
|
||||||
|
`db.json` is a build artifact derived from `db.txt` + `calc/ciphers.js`. It is not committed
|
||||||
|
to the repo (it's large). Two ways to get it:
|
||||||
|
|
||||||
|
1. **Download** the prebuilt `db.json` from the latest [GitHub Release](../../releases).
|
||||||
|
Place it next to `index.html`.
|
||||||
|
2. **Regenerate** it yourself:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 tools/generate_db_json.py db.txt db.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Requires Python 3. Reads cipher definitions from `calc/ciphers.js`, scores every entry in
|
||||||
|
`db.txt` against all 69 English-applicable ciphers, and writes `db.json`.
|
||||||
|
|
||||||
|
The calculator auto-detects `db.json` (see `databaseMode` in `config.js`, default `"auto"`):
|
||||||
|
it tries `db.json` first and falls back to `db.txt` if absent.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
- `generate_db_json.py` — builds `db.json` from a flat `db.txt`.
|
||||||
|
- `all_ciphers.py` — parses `calc/ciphers.js` and scores text against all English ciphers
|
||||||
|
(used by the generator). Handles case-sensitive ciphers and strips `[...]` display
|
||||||
|
annotations before scoring, matching the live engine.
|
||||||
Binary file not shown.
@@ -0,0 +1,178 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Complete cipher engine — parses ALL ciphers from ciphers.js and scores entries.
|
||||||
|
Only applies English-alphabet ciphers to English text (skips Hebrew, Greek, Arabic, Russian).
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def parse_ciphers_js(filepath):
|
||||||
|
"""Parse ciphers.js and extract all cipher definitions."""
|
||||||
|
with open(filepath, "r", encoding="utf-8") as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
# Match each cipher constructor call
|
||||||
|
# Pattern: new cipher("name", "category", hue, sat, light, [chars], [values], diacritics, enabled, caseSensitive)
|
||||||
|
pattern = re.compile(
|
||||||
|
r'new cipher\(\s*'
|
||||||
|
r'"([^"]+)",\s*' # name
|
||||||
|
r'"([^"]+)",\s*' # category
|
||||||
|
r'[\d.]+,\s*' # hue
|
||||||
|
r'[\d.]+,\s*' # saturation
|
||||||
|
r'[\d.]+,\s*' # lightness
|
||||||
|
r'\[([^\]]+)\],\s*' # characters array
|
||||||
|
r'\[([^\]]+)\],\s*' # values array
|
||||||
|
r'(true|false)\s*,\s*' # diacritics
|
||||||
|
r'(true|false)\s*,\s*' # enabled
|
||||||
|
r'(true|false)\s*\)', # case_sensitive
|
||||||
|
re.DOTALL
|
||||||
|
)
|
||||||
|
|
||||||
|
ciphers = []
|
||||||
|
for match in pattern.finditer(content):
|
||||||
|
name = match.group(1)
|
||||||
|
category = match.group(2)
|
||||||
|
chars_str = match.group(3)
|
||||||
|
vals_str = match.group(4)
|
||||||
|
diacritics = match.group(5) == "true"
|
||||||
|
enabled = match.group(6) == "true"
|
||||||
|
case_sensitive = match.group(7) == "true"
|
||||||
|
|
||||||
|
chars = [int(x.strip()) for x in chars_str.split(",") if x.strip()]
|
||||||
|
vals = [int(x.strip()) for x in vals_str.split(",") if x.strip()]
|
||||||
|
|
||||||
|
if len(chars) != len(vals):
|
||||||
|
continue
|
||||||
|
|
||||||
|
ciphers.append({
|
||||||
|
"name": name,
|
||||||
|
"category": category,
|
||||||
|
"char_codes": chars,
|
||||||
|
"values": vals,
|
||||||
|
"char_map": dict(zip(chars, vals)),
|
||||||
|
"diacritics": diacritics,
|
||||||
|
"enabled": enabled,
|
||||||
|
"case_sensitive": case_sensitive,
|
||||||
|
})
|
||||||
|
|
||||||
|
return ciphers
|
||||||
|
|
||||||
|
|
||||||
|
def filter_english_ciphers(ciphers):
|
||||||
|
"""Keep only ciphers that map standard English lowercase letters (a-z, codes 97-122).
|
||||||
|
Skip Hebrew, Greek, Arabic, Russian ciphers."""
|
||||||
|
skip_categories = {"Hebrew", "Greek", "Arabic", "Russian"}
|
||||||
|
english_ciphers = []
|
||||||
|
for c in ciphers:
|
||||||
|
if c["category"] in skip_categories:
|
||||||
|
continue
|
||||||
|
# Check if this cipher maps at least a-z
|
||||||
|
has_english = any(97 <= code <= 122 for code in c["char_codes"])
|
||||||
|
if has_english:
|
||||||
|
english_ciphers.append(c)
|
||||||
|
return english_ciphers
|
||||||
|
|
||||||
|
|
||||||
|
def compute_value(text, cipher):
|
||||||
|
"""Compute gematria value of text using given cipher."""
|
||||||
|
char_map = cipher["char_map"]
|
||||||
|
total = 0
|
||||||
|
for ch in text:
|
||||||
|
lowered = ch.lower() if not cipher.get("case_sensitive") else ch
|
||||||
|
if len(lowered) != 1:
|
||||||
|
continue
|
||||||
|
code = ord(lowered)
|
||||||
|
if code in char_map:
|
||||||
|
total += char_map[code]
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
# Singleton: loaded ciphers
|
||||||
|
_CIPHERS = None
|
||||||
|
_CIPHERS_PATH = os.path.join(os.path.dirname(__file__), "..", "calc", "ciphers.js")
|
||||||
|
|
||||||
|
|
||||||
|
def get_ciphers():
|
||||||
|
global _CIPHERS
|
||||||
|
if _CIPHERS is None:
|
||||||
|
all_ciphers = parse_ciphers_js(_CIPHERS_PATH)
|
||||||
|
_CIPHERS = filter_english_ciphers(all_ciphers)
|
||||||
|
return _CIPHERS
|
||||||
|
|
||||||
|
|
||||||
|
def score_all_ciphers(text):
|
||||||
|
"""Score text against ALL English ciphers. Returns dict of cipher_name -> value."""
|
||||||
|
ciphers = get_ciphers()
|
||||||
|
return {c["name"]: compute_value(text, c) for c in ciphers}
|
||||||
|
|
||||||
|
|
||||||
|
def score_entry_full(text, hot_numbers=None):
|
||||||
|
"""Score entry with all ciphers and check against hot numbers.
|
||||||
|
Returns dict with values, hits, and significance score."""
|
||||||
|
values = score_all_ciphers(text)
|
||||||
|
|
||||||
|
if hot_numbers is None:
|
||||||
|
hot_numbers = DEFAULT_HOT_NUMBERS
|
||||||
|
|
||||||
|
hits = {}
|
||||||
|
significance = 0
|
||||||
|
for cipher_name, val in values.items():
|
||||||
|
if val in hot_numbers:
|
||||||
|
tier = hot_numbers[val]
|
||||||
|
if tier not in hits:
|
||||||
|
hits[tier] = []
|
||||||
|
hits[tier].append((cipher_name, val))
|
||||||
|
significance += 10 if tier == "t1" else 3
|
||||||
|
|
||||||
|
return {
|
||||||
|
"values": values,
|
||||||
|
"hits": hits,
|
||||||
|
"significance": significance,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Will be updated after book extraction completes
|
||||||
|
DEFAULT_HOT_NUMBERS = {}
|
||||||
|
# Build from tiers
|
||||||
|
_T1 = {11, 13, 22, 26, 27, 33, 38, 39, 42, 47, 52, 58, 62, 66, 69, 73, 74,
|
||||||
|
77, 88, 93, 99, 101, 108, 112, 119, 137, 147, 153, 156, 174, 187,
|
||||||
|
201, 206, 216, 227, 260, 314, 322, 333, 351, 444, 555, 666, 777,
|
||||||
|
888, 911, 999, 1776}
|
||||||
|
_T2 = {3, 5, 7, 9, 12, 17, 19, 23, 28, 30, 32, 35, 36, 37, 40, 44, 46,
|
||||||
|
48, 49, 50, 51, 53, 55, 56, 57, 59, 60, 61, 63, 64, 65, 67, 68,
|
||||||
|
70, 71, 72, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89,
|
||||||
|
90, 91, 92, 94, 95, 96, 97, 98, 100, 104, 105, 106, 107, 110,
|
||||||
|
113, 116, 117, 118, 120, 121, 123, 128, 131, 133, 139, 142, 144,
|
||||||
|
149, 150, 151, 155, 157, 159, 160, 163, 166, 169, 170, 173, 175,
|
||||||
|
177, 180, 188, 189, 191, 193, 196, 199, 200, 203, 209, 211, 212,
|
||||||
|
213, 218, 223, 229, 233, 239, 241, 243, 246, 249, 252, 253, 257,
|
||||||
|
263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337,
|
||||||
|
347, 349, 353, 359, 367, 373, 379, 383, 389, 397}
|
||||||
|
|
||||||
|
for n in _T1:
|
||||||
|
DEFAULT_HOT_NUMBERS[n] = "t1"
|
||||||
|
for n in _T2:
|
||||||
|
if n not in DEFAULT_HOT_NUMBERS:
|
||||||
|
DEFAULT_HOT_NUMBERS[n] = "t2"
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
ciphers = get_ciphers()
|
||||||
|
print(f"Loaded {len(ciphers)} English-applicable ciphers:\n")
|
||||||
|
for c in ciphers:
|
||||||
|
print(f" {c['name']:30s} [{c['category']}]")
|
||||||
|
|
||||||
|
print(f"\n--- Sample scoring ---")
|
||||||
|
test_words = ["God", "Masonry", "Jesus", "Freemason", "English", "Gematria",
|
||||||
|
"Bible", "asdfghjkl", "Climate Change Hoax"]
|
||||||
|
for word in test_words:
|
||||||
|
result = score_entry_full(word)
|
||||||
|
# Show only the 4 base ciphers + any ciphers that hit hot numbers
|
||||||
|
base = {k: v for k, v in result["values"].items()
|
||||||
|
if k in ("Ordinal", "Reduction", "Reverse Ordinal", "Reverse Reduction")}
|
||||||
|
base_str = ", ".join(f"{k}={v}" for k, v in base.items())
|
||||||
|
hit_count = sum(len(v) for v in result["hits"].values())
|
||||||
|
print(f" {word:30s} sig={result['significance']:>3} base:[{base_str}] hot_hits={hit_count}")
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Generate db.json (HYPER_CYPHERS v2) from a flat db.txt.
|
||||||
|
|
||||||
|
Computes all 69 English-applicable ciphers per entry and emits the JSON shape
|
||||||
|
the calculator's loadPrecomputedDB() expects.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python3 generate_db_json.py [input.txt] [output.json]
|
||||||
|
|
||||||
|
Defaults: db_track_a.txt -> db_track_a.json
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from datetime import date
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from all_ciphers import get_ciphers, compute_value
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
in_path = Path(sys.argv[1] if len(sys.argv) > 1 else "db_track_a.txt")
|
||||||
|
out_path = Path(sys.argv[2] if len(sys.argv) > 2 else "db_track_a.json")
|
||||||
|
|
||||||
|
print(f"Input: {in_path}")
|
||||||
|
print(f"Output: {out_path}")
|
||||||
|
|
||||||
|
ciphers = get_ciphers()
|
||||||
|
cipher_order = [c["name"] for c in ciphers]
|
||||||
|
print(f"Computing {len(ciphers)} ciphers per entry...")
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
with open(in_path, encoding="utf-8") as f:
|
||||||
|
for i, line in enumerate(f):
|
||||||
|
if i == 0:
|
||||||
|
continue # skip CREATE_GEMATRO_DB header
|
||||||
|
line = line.rstrip("\r\n").strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
entries.append(line)
|
||||||
|
|
||||||
|
n = len(entries)
|
||||||
|
print(f"Entries to score: {n}")
|
||||||
|
|
||||||
|
t0 = time.time()
|
||||||
|
data = []
|
||||||
|
for idx, phrase in enumerate(entries):
|
||||||
|
# Match the live engine (gematria.js:23, optAllowPhraseComments=true): strip [...]
|
||||||
|
# annotations before computing so digit-counting ciphers (AQ/Synx/etc.) don't count
|
||||||
|
# bracketed display digits. Display text (row[0]) keeps the brackets.
|
||||||
|
compute_text = re.sub(r"\[.+\]", "", phrase).strip() or phrase
|
||||||
|
row = [phrase] + [compute_value(compute_text, c) for c in ciphers]
|
||||||
|
data.append(row)
|
||||||
|
if (idx + 1) % 10000 == 0:
|
||||||
|
elapsed = time.time() - t0
|
||||||
|
rate = (idx + 1) / elapsed
|
||||||
|
eta = (n - idx - 1) / rate
|
||||||
|
print(f" {idx + 1:>7}/{n} ({(idx+1)/n*100:5.1f}%) rate={rate:.0f}/s eta={eta:.0f}s")
|
||||||
|
|
||||||
|
out = {
|
||||||
|
"version": 2,
|
||||||
|
"format": "HYPER_CYPHERS",
|
||||||
|
"generated": date.today().isoformat(),
|
||||||
|
"entries": n,
|
||||||
|
"cipher_order": cipher_order,
|
||||||
|
"data": data,
|
||||||
|
}
|
||||||
|
|
||||||
|
print(f"Writing JSON...")
|
||||||
|
with open(out_path, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(out, f, separators=(",", ":"))
|
||||||
|
|
||||||
|
size_mb = out_path.stat().st_size / 1024 / 1024
|
||||||
|
print(f"Done. {n} entries, {size_mb:.1f} MB, {time.time()-t0:.0f}s total")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user