https://github.com/jolovicdev/harmonia
Pure Python spell checker inspired by pyspellchecker
https://github.com/jolovicdev/harmonia
python spellcheck spelling
Last synced: 11 months ago
JSON representation
Pure Python spell checker inspired by pyspellchecker
- Host: GitHub
- URL: https://github.com/jolovicdev/harmonia
- Owner: jolovicdev
- License: mit
- Created: 2025-01-26T04:51:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-01T23:08:07.000Z (12 months ago)
- Last Synced: 2025-03-01T23:35:47.002Z (12 months ago)
- Topics: python, spellcheck, spelling
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Harmonia Spell Checker



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
```bash
pip install harmoniapy
```
## 🖥️ CLI Usage
Check a file for spelling errors:
```bash
# 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
```python
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.