Skip to main content

A Frequency-Quantized HyperLogLog Autocorrection algorithm that also is dyslexia-friendly.

Project description

DyslexicLogLog (FQ-HLL)

An improved Frequency-Quantized HyperLogLog (FQ-HLL) Autocorrection Library

For theoretical value, there is nothing in my algorithm that uses any information about the English language or the QWERTY keyboard, to do any of the corrections. It is a NON-ML algorithm too.

Usage

The library defaults to searching within its own folder before searching in your local directory. Visit my GitHub Repo for more details, but there are two text files offered as base dictionaries: 20k_shun4midx.txt and database.txt, with around 20000 and 400 words respectively. The below code would only visit the local directory. If no dictionary is specified, 20k_shun4midx.txt would be used instead.

What is returned is in the form of a dictionary, mapping each query to either a single string for autocorrect or a list of three strings for top3.

# ======== SAMPLE USAGE ======== #
from dyslexicloglog import Autocorrector

if __name__ == "__main__":
    ac = Autocorrector()

    # File
    ans1 = ac.autocorrect("test_files/typo_file.txt", "test_files/class_suggestions.txt")
    print(ans1)

    ans2 = ac.top3("test_files/typo_file.txt", "test_files/class_suggestions.txt")

    # Optionally, you can not want it to output it into a file, then:
    # Individual strings
    ans3 = ac.autocorrect("hillo")
    ans4 = ac.top3("hillo")

    # Arrays
    ans5 = ac.autocorrect(["tsetign", "hillo", "goobye", "haedhpoesn"])
    ans6 = ac.top3(["tsetign", "hillo", "goobye", "haedhpoesn"])

    # You can even have a custom dictionary!
    dictionary = ["apple", "banana", "grape", "orange"]
    custom_ac = Autocorrector(dictionary)

    ans7 = custom_ac.autocorrect(["applle", "banana", "banan", "orenge", "grap", "pineapple"])
    ans8 = custom_ac.top3(["applle", "banana", "banan", "orenge", "grap", "pineapple"])

    print(ans7)
    print(ans8)

As a side note, compare.py and compare3.py, as files that are quite useful for comparing between intended outputs and actual outputs, can be used via

from dyslexicloglog import compare
compare_files(suggestions, typos, answers)

or if we are doing Top 3 words selected per row,

from dyslexicloglog import compare3
compare3_files(suggestions, typos, answers)

Results

More detail can be found in my GitHub Repo.

TL;DR it is way more accurate than traditional non-ML, non-language-specific algorithms such as BK-Tree and SymSpell and it also quite fast.

Notes

  • HLL naturally doesn't have Local Differential Privacy (LDP) yet, but has natural obfuscation.
  • This library does not collect personal data. However, still use it at your own discretion.

Dyslexia

Personally, I've always had an interest in autocorrect because I'm dyslexic and often unintentionally scramble or reverse letters when I read. Here are my thoughts about this algorithm based on my dyslexia.

  • Reasoning would be more detailed in the algo_description/description.pdf file in my GitHub Repo, but I find this algorithm's autocorrection suggestions are sometimes more intuitive (e.g. "klof" -> "folk") to my dyslexia than other Levenshtein distance-based autocorrection models.
  • As a side note, as a dyslexic person, I naturally process words similar to how the FQ-HLL algorithm processes words, and that was my intuition in terms of how to create this algorithm in the first place.

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

dyslexicloglog-1.1.3.tar.gz (84.1 kB view details)

Uploaded Source

Built Distribution

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

dyslexicloglog-1.1.3-py3-none-any.whl (88.2 kB view details)

Uploaded Python 3

File details

Details for the file dyslexicloglog-1.1.3.tar.gz.

File metadata

  • Download URL: dyslexicloglog-1.1.3.tar.gz
  • Upload date:
  • Size: 84.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for dyslexicloglog-1.1.3.tar.gz
Algorithm Hash digest
SHA256 652aef6c8709412507af40164ee317749d2aade968608d69fee411cdd6f6e76a
MD5 3b3e474f1fd40055f9f9d296629c047f
BLAKE2b-256 23b4061ff062105b18e28a70dd2755ce884b7c144c235954d63b5ec959657612

See more details on using hashes here.

File details

Details for the file dyslexicloglog-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: dyslexicloglog-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 88.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for dyslexicloglog-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2b8fbc50a2f3ee1c3b0c3c194fcb2068e527ea88416f112da89febc0522f131a
MD5 e1831ae4d7964f4f9e59287210a1f552
BLAKE2b-256 b3883dfe0f64e9eb19bf2701d48e10473e8bb5565129793611aa443d8accf8b1

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