Using Markov chain to detect gibberish in text.
Project description
gibberishpy
gibberishpy is a Python-based application designed to analyze and identify gibberish in a given string. The application leverages the principles of Markov Chains, a mathematical system that undergoes transitions from one state to other on a state space, to calculate both additive and multiplicative probabilities. gibberishpy allow users to build their own model with custom txt file.
Usage Examples
Build Model
from gibberishpy.scanner import GibberishScanner
if __name__ == "__main__":
scanner = GibberishScanner()
scanner.build_model(corpus_path="path/to/corpus.txt", n_gram_size=2)
scanner.save_model("transition_matrix_2d.tm", encoding="utf-8")
Scan Gibberish
from gibberishpy.scanner import GibberishScanner
if __name__ == "__main__":
scanner = GibberishScanner()
scanner.load_model(path="transition_matrix_2d.tm")
additive_cum_proba, multiplicative_cum_proba = scanner.scan("ldfjgnkdfjnd")
print(additive_cum_proba)
print(multiplicative_cum_proba)
# 0.00022810218978102192
# 0.0
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
gibberishpy-1.0.3.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for gibberishpy-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef4312fea849c8fd53696ed14cd122a5d8a2aca4ec8a44c299380c6bee99aacf |
|
MD5 | dc9b98cae48b4dee6f5f0d3d9e85f87f |
|
BLAKE2b-256 | e20d273eaba40394a353c8c23ffbe3d44c8b44d94f30eff87260738a610ccf7f |