nuspell: nuspell::Dictionary Class Reference

nuspell 5.1.8 Nuspell spellchecking library

Loading...
Searching...
No Matches
nuspell::Dictionary Class Reference

The only important public class. More...

`#include <dictionary.hxx>`

## Public Member Functions
auto | load_aff_dic (std::istream &aff, std::istream &dic) -> void
| Load the dictionary from opened files as iostreams.
auto | load_aff_dic (const std::filesystem::path &aff_path) -> void
| Load the dictionary from file on filesystem.
auto | spell (std::string_view word) const -> bool
| Checks if a given word is correct.
auto | suggest (std::string_view word, std::vector< std::string > &out) const -> void
| Suggests correct words for a given incorrect word.

## 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.
static auto | load_from_path (const std::string &file_path_without_extension) -> Dictionary
| Create a dictionary from files.

## Detailed Description

The only important public class.

## Member Function Documentation

## ◆ load_aff_dic() [1/2]

auto nuspell::Dictionary::load_aff_dic | ( | const std::filesystem::path & | aff_path | ) | -> void

Load the dictionary from file on filesystem.

Precondition
  Before calling this the dictionary object must be empty e.g default-constructed or assigned with another empty object.

Parameters

  aff_path | path to .aff file. The path of .dic is inffered from this.

Exceptions

  Dictionary_Loading_Error | on error

## ◆ load_aff_dic() [2/2]

auto nuspell::Dictionary::load_aff_dic | ( | std::istream & | aff,
|  | std::istream & | dic ) -> void

Load the dictionary from opened files as iostreams.

Precondition
  Before calling this the dictionary object must be empty e.g default-constructed or assigned with another empty object.

Parameters

  aff | The iostream of the .aff file
  dic | The iostream of the .dic file

Exceptions

  Dictionary_Loading_Error | on error

## ◆ load_from_aff_dic()

auto nuspell::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.

Deprecated
  Use new non-static member function load_aff_dic(std::istream&,std::istream&).

Parameters

  aff | The iostream of the .aff file
  dic | The iostream of the .dic file

Returns
  Dictionary object

Exceptions

  Dictionary_Loading_Error | on error

## ◆ load_from_path()

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

Create a dictionary from files.

Deprecated
  Use new non-static member function load_aff_dic(const std::filesystem::path&). Note that the new function takes path WITH .aff extension.

Parameters

  file_path_without_extension | path without extensions (without .dic or .aff)

Returns
  Dictionary object

Exceptions

  Dictionary_Loading_Error | on error

## ◆ spell()

auto nuspell::Dictionary::spell | ( | std::string_view | word | ) | const -> bool

Checks if a given word is correct.

Parameters

  word | any word

Returns
  true if correct, false otherwise

## ◆ suggest()

auto nuspell::Dictionary::suggest | ( | std::string_view | word,
|  | std::vector< std::string > & | out ) const -> void

Suggests correct words for a given incorrect word.

Parameters

  [in] | word | incorrect word
  [out] | out | this object will be populated with the suggestions

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

- nuspell/dictionary.hxx
- nuspell/dictionary.cxx