Skip to content

Incremental search, spell checker and Optimal String Alignment distance implementation in C++

License

Notifications You must be signed in to change notification settings

victor-istomin/incrementalSpellCheck

Repository files navigation

Incremental search and spell checker in C++

This is C++ header-only implementation of incremental search within a list of captions (menu, articles, etc) with misprint corrections support.

Demo

./test -i

Contents

Usage

#include "incrementalSearch.hpp"
void f()
{
    std::vector<std::string> listOfTopics = {...};
    IncrementalSearch search { listOfTopics };
    
    const std::string& closestMatchedTopic = search.search('misprint');     
}

// or:
#include "spellCheck.hpp"
void g()
{
    const char* textCorpus[] = {"one two, three", "Four.Five", "verylongword"};
    SpellCheck speller { textCorpus };
    
    const size_t maxCount = 2;
    auto corrections = speller.getCorrections("tree", maxCount);                  // "three"
    auto incrementalCorrections = speller.getCorrections("_ery", maxCount, true); // "_ery" -> "very.*" -> "verylongword"
}

void h()
{
     SpellCheck::getSmartDistance("abcde", "abc"); // == 2
     SpellCheck::getSmartDistance(CString("abcde"), std::string("abcd"));

     SpellCheck::getSmartDistance("abcde", "abc", true/*incremental*/); // == 0, "abc" -> "abc.*" -> "abcde"
}

Supported compilers

C++ 14 with at least partial expression SFINAE is needed. Testsed on:

  • Visual Studio 2015 update 3
  • gcc 7.2

See test.cpp for more detailed examples.

About

Incremental search, spell checker and Optimal String Alignment distance implementation in C++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published