Skip to main content

Calibrate dictionary hit rates in computational decipherment. Detects when short decoded strings collide with dictionary entries by chance.

Project description

dictcollision

PyPI Python License

Your decipherment reports a 43% dictionary hit rate. Is that real?

dictcollision answers this question. When decoded strings are short (2–4 characters) and dictionaries are large (≥10K words), chance collisions produce matches at rates that approach genuine decipherment rates. This package predicts the collision rate and separates real signal from noise.

Install

pip install dictcollision

For plotting support:

pip install dictcollision[viz]

Quick start

One-line noise floor check

from dictcollision import noise_floor

predicted = noise_floor(decoded_tokens, dictionary)
print(f"Chance collisions alone: {predicted:.1%}")
print(f"Your observed rate:      43.0%")
print(f"Genuine signal:          {0.43 - predicted:.1%}")

Full four-category analysis

from dictcollision import classify

result = classify(decoded_tokens, dictionary)
print(f"Signal:          {result.signal:.1%}")
print(f"Shared hit:      {result.shared_hit:.1%}")
print(f"Anti-signal:     {result.anti_signal:.1%}")
print(f"Net signal:      {result.net_signal:.1%}")
print(f"Apparent rate:   {result.apparent_hit_rate:.1%}")

Rank candidate dictionaries

from dictcollision import recommend

ranked = recommend(
    decoded_tokens,
    {"latin_10k": latin_words, "german_50k": german_words},
    objective="excess",
)
for r in ranked:
    print(f"{r.name}: excess={r.excess:.3f}, snr={r.snr:.1f}")

The core equation

The predicted noise floor for dictionary $D$ against decoded text with character distribution $p$ is:

$$\hat{r} \;=\; \sum_{w \in D}\; \prod_{i=1}^{|w|} p(w_i)$$

For every word in the dictionary, multiply together the character frequencies of your decoded output. Sum. That number is how many of your tokens would match by accident.

How it works

The four-category framework classifies every decoded token type:

Category In dictionary? In real text? In null corpora?
Signal yes yes no
Shared hit yes yes yes
Anti-signal yes no yes
Shared miss no

Net signal = Signal − Anti-signal is the calibrated metric.

Null corpora are generated from the decoded text's character bigram distribution, preserving character-pair frequencies and token lengths while destroying word identity.

Paper

The methodology, experiments, and validation behind this package are described in:

Ruckman, M. (2026). The Dictionary Collision Effect in Computational Decipherment. Source, figures, and reproduction code: https://github.com/mruckman1/signal-isolation-paper

Citation

If you use this package in your research, please cite:

@article{ruckman2026dictcollision,
  title={The Dictionary Collision Effect in Computational Decipherment},
  author={Ruckman, Matthew},
  year={2026},
  url={https://github.com/mruckman1/signal-isolation-paper}
}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dictcollision-0.1.1.tar.gz (71.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dictcollision-0.1.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file dictcollision-0.1.1.tar.gz.

File metadata

  • Download URL: dictcollision-0.1.1.tar.gz
  • Upload date:
  • Size: 71.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for dictcollision-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a5c76eb57204c000da0f142b1822566f12fc4481e62b532fb5de2fb80023566f
MD5 bbee602d647c6a17e5675dbbf864a60a
BLAKE2b-256 bee93037ef84d656d6c5363d35985c6208abb08fc2b8ded84e27c1f26b48566d

See more details on using hashes here.

File details

Details for the file dictcollision-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dictcollision-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c691088742b73d1fba1063fde278ac20015222d5b4dc5565fdf8817add1f3b6
MD5 75cc89d34ced75574f7e79da71b0dc71
BLAKE2b-256 4893ebb7ac99beedb7e8183be08a74840f54bd17fc907e2512c57fcbe5e82f95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page