Nuspell
spellchecker
Public Member Functions | Static Public Member Functions | List of all members
nuspell::v2::Dictionary Class Reference

The only important public class. More...

#include <dictionary.hxx>

Inheritance diagram for nuspell::v2::Dictionary:
[legend]
Collaboration diagram for nuspell::v2::Dictionary:
[legend]

Public Member Functions

auto imbue (const std::locale &loc) -> void
 Imbues external locale object to set external encoding. More...
 
auto spell (const std::string &word) const -> bool
 Checks if a given word is correct. More...
 
auto suggest (const std::string &word, List_Strings &out) const -> void
 Suggests correct words for a given incorrect word. More...
 

Static Public Member Functions

static auto load_from_aff_dic (std::istream &aff, std::istream &dic) -> Dictionary
 Create a dictionary from opened files as iostreams. More...
 
static auto load_from_path (const std::string &file_path_without_extension) -> Dictionary
 Create a dictionary from files. More...
 

Detailed Description

The only important public class.

Member Function Documentation

◆ imbue()

auto Dictionary::imbue ( const std::locale &  loc) -> void

Imbues external locale object to set external encoding.

The locale must contain codecvt<wchar_t, char, mbstate_t> facet that can convert the strings from the external locale to UTF-32 on non-Windows platforms, and to UTF-16 on Windows. By external encoding it is meant the encoding of strings in the client code that uses this library.

You may safely use locales geenrated by Boost.Locale.

Parameters
loclocale object with valid codecvt<wchar_t, char, mbstate_t>

◆ load_from_aff_dic()

auto Dictionary::load_from_aff_dic ( std::istream &  aff,
std::istream &  dic 
) -> Dictionary
static

Create a dictionary from opened files as iostreams.

Prefer using load_from_path(). Use this if you have a specific use case, like when .aff and .dic are in-memory buffers istringstream.

Parameters
affThe iostream of the .aff file
dicThe iostream of the .dic file
Returns
Dictionary object

◆ load_from_path()

auto Dictionary::load_from_path ( const std::string &  file_path_without_extension) -> Dictionary
static

Create a dictionary from files.

Parameters
filepath without extensions
Returns
Dictionary object

◆ spell()

auto Dictionary::spell ( const std::string &  word) const -> bool

Checks if a given word is correct.

Parameters
word
Returns
true if correct, false otherwise

◆ suggest()

auto Dictionary::suggest ( const std::string &  word,
List_Strings out 
) const -> void

Suggests correct words for a given incorrect word.

Parameters
wordincorrect word
[out]outthis object will be populated with the suggestions

The documentation for this class was generated from the following files: