|
Get smart word suggestions with prefix matching, ranked by usage frequency for a personalized experience. |
Powered by Levenshtein distance algorithm to find and suggest the closest matching words. |
|
System learns from your usage patterns, automatically adjusting word frequencies over time. |
Add custom words and save your personalized dictionary across sessions. |
C++14 or higher
g++, clang++, or MSVC compiler# Clone the repository
git clone https://github.com/codev-aryan/TextEngine.git
cd TextEngine
# Compile
g++ -std=c++14 -O2 main.cpp trie.cpp editdistance.cpp -o textengine
# Run
./textengine📝 Autocomplete Example
Choice: 1
Enter prefix: alg
--- Results ---
Suggestions for 'alg':
1. algorithm (freq: 980) ⭐
Select a suggestion (1-1) or 0 to skip: 1
Selected: algorithm (new freq: 981)
Time: 45 μs ⚡
🔎 Spell Check Example
Choice: 2
Enter word: algoritm
✗ Not found
Did you mean:
1. algorithm
2. algorithmic
3. algorithmically
Select a suggestion (1-3) or 0 to add 'algoritm' to dictionary: 1
Selected: algorithm (new freq: 982)
Time: 3 ms
Create a dictionary.txt file with words and their frequencies:
algorithm 980
autocomplete 750
python 930
Efficient prefix-based word retrieval using a tree structure where each node represents a character.
root
/ | \
a b c
/ | \
l o a
/ | \
g o t
Calculates minimum operations (insert/delete/substitute) to transform one word to another.
Space Optimized: Uses only 2 rows instead of full matrix - O(min(m,n)) space complexity!
| Operation | Time Complexity | Space Complexity |
|---|---|---|
| Insert | O(m) | O(1) |
| Search | O(m) | O(1) |
| Autocomplete | O(p + n) | O(n) |
| Spell Check | O(k × m × n) | O(m) |
where m = word length, n = matching words, p = prefix length, k = max edit distance
textengine/
│
├── 📄 Trie.h # Trie class definition & interface
├── 📄 trie.cpp # Core Trie implementation
├── 📄 editdistance.cpp # Levenshtein distance algorithm
├── 📄 main.cpp # Interactive CLI application
└── 📄 dictionary.txt # Word frequency database
🔥 Frequency-Based Ranking - Words you use more often appear first in suggestions
🎨 Case Insensitive - Automatic lowercase conversion for consistent matching
⚙️ Customizable - Adjust edit distance threshold and autocomplete limits
💪 Memory Efficient - Smart pointer usage and optimized algorithms
Contributions, issues, and feature requests are welcome!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.