Skip to content

codev-aryan/TextEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 TextEngine

Lightning-fast autocomplete & spell-checking powered by advanced algorithms

C++ License PRs Welcome

FeaturesQuick StartUsageTechnical Details


✨ Features

🎯 Intelligent Autocomplete

Get smart word suggestions with prefix matching, ranked by usage frequency for a personalized experience.

🔍 Advanced Spell Checking

Powered by Levenshtein distance algorithm to find and suggest the closest matching words.

📊 Adaptive Learning

System learns from your usage patterns, automatically adjusting word frequencies over time.

💾 Persistent Storage

Add custom words and save your personalized dictionary across sessions.


🚀 Quick Start

Prerequisites

C++14 or higher
g++, clang++, or MSVC compiler

Build & Run

# 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

💡 Usage

Interactive Demo

📝 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

Dictionary Format

Create a dictionary.txt file with words and their frequencies:

algorithm 980
autocomplete 750
python 930

🏗️ Architecture

🌲 Trie Data Structure

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

📏 Levenshtein Edit Distance

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!


⚡ Performance

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


📁 Project Structure

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

🎯 Key Highlights

🔥 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


🤝 Contributing

Contributions, issues, and feature requests are welcome!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

This project is open source and available under the MIT License.


Built with ❤️ by codev-aryan

⭐ Star this repo if you find it helpful!

Report BugRequest Feature

About

Lightning-fast autocomplete & spell-checking powered by advanced algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages