Skip to main content

Fast and accurate Python spell checker, a powerful alternative to pyspellchecker

Project description

Harmonia Spell Checker

Version Python License

A fast, accurate, and feature-rich Python spell checker - a powerful alternative to pyspellchecker with advanced features and optimized performance.

🚀 Features

  • High Performance: Optimized dictionary loading and word lookup algorithms
  • Accurate Suggestions: Advanced algorithms for spelling suggestions:
    • Levenshtein distance with optimized implementation
    • Phonetic matching with Soundex algorithm
    • Context-aware weighted suggestions
  • Flexible Word Handling:
    • Support for hyphenated words
    • Contractions and possessives detection
    • Automatically derived word forms
  • Robust Output Options:
    • Interactive command-line interface
    • Detailed HTML reports with hover suggestions
    • Markdown report generation
    • Customizable output formats
  • Developer-Friendly:
    • Clean, well-documented API
    • Highly customizable settings
    • Comprehensive error handling
    • Memory-efficient implementation

📦 Installation

pip install harmoniapy

🖥️ CLI Usage

Check a file for spelling errors:

# Basic usage
harmonia check myfile.txt

# Show suggestions for each error
harmonia check myfile.txt --suggest

# Generate HTML report with hover suggestions
harmonia check myfile.txt --suggest --html report.html

# Generate Markdown report
harmonia check myfile.txt --suggest --markdown report.md

# Ignore specific words
harmonia check myfile.txt --ignore ignored-words.txt

# Show version information
harmonia --version

💻 Python API Usage

from harmonia import Dictionary, check_file

# Initialize dictionary (loads automatically)
dictionary = Dictionary()

# Check file with suggestions
errors = check_file("myfile.txt", dictionary, suggest=True)

# Process errors
for error in errors:
    print(f"Error: {error['word']} at line {error['line']}")
    if error['suggestions']:
        print(f"Suggestions: {', '.join(error['suggestions'])}")

# Generate HTML report
from harmonia.formatters import generate_html_report
with open("myfile.txt") as f:
    text = f.read()
html_report = generate_html_report(text, errors)
with open("report.html", "w") as f:
    f.write(html_report)

📊 HTML Report

The HTML report shows the text with red underlines for misspelled words. Hover over any underlined word to see spelling suggestions.

🔄 Comparison with pyspellchecker

Feature Harmonia pyspellchecker
Suggestion algorithm Multi-algorithm hybrid Primarily edit distance
Phonetic matching ✅ Soundex ❌ Not included
Word frequency ✅ Wikipedia-based ✅ Basic frequency
HTML reports ✅ Interactive ❌ Not included
Misspellings DB ✅ Extensive ✅ Limited
Performance ✅ Highly optimized ⚠️ Standard
Custom dictionaries ✅ Supported ✅ Supported
Hyphenated words ✅ Advanced handling ⚠️ Basic support
Derived word forms ✅ Automatic ❌ Not included

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

harmoniapy-1.2.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

harmoniapy-1.2.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file harmoniapy-1.2.0.tar.gz.

File metadata

  • Download URL: harmoniapy-1.2.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for harmoniapy-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b7ebcb279107db9dd7db2ec26f7ec96598f6ef3f6a263aa800654957899ee789
MD5 b4b29351287f73584c51804456c3449c
BLAKE2b-256 f68e095651876134220963c7bf4e924ba977c9cc6340def4c663aafeecb190fb

See more details on using hashes here.

File details

Details for the file harmoniapy-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: harmoniapy-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for harmoniapy-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f95ccd0ecceb713796b3fc3cae69fbcd6b06bfd5904aab43be8c165d8afc7887
MD5 8676fb11987c6850a7d6667c340cdfdf
BLAKE2b-256 0cb533f820ee330357a2e5ff29cc8024c05f460b4cb1123c895ad2b2eaedc7f9

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