The only important public class.
More...
#include <dictionary.hxx>
|
auto | imbue (const std::locale &loc) -> void |
| Sets external (public API) encoding. More...
|
|
auto | imbue_utf8 () -> void |
| Sets external (public API) encoding to UTF-8. More...
|
|
auto | spell (std::string_view word) const -> bool |
| Checks if a given word is correct. More...
|
|
auto | suggest (std::string_view word, std::vector< std::string > &out) const -> void |
| Suggests correct words for a given incorrect word. More...
|
|
The only important public class.
◆ imbue()
auto nuspell::v4::Dictionary::imbue |
( |
const std::locale & |
loc | ) |
-> void |
Sets external (public API) encoding.
By external encoding we mean the encoding of the strings that you are going to pass to other functions like spell() and suggest(). This function should be used rarely, as the default external encoding is UTF-8.
This encoding should not be misunderstood with the internal encoding or with the encoding of the dictionary files (.dic and .aff). It can be different than any of them.
The locale must contain std::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.
- Deprecated:
- You should always feed dictionary with words encoded in UTF-8, and you should not use this function to set other encodings. The recommened way to get words out of text is via the algorithm known as Unicode text segmentation which only works on text encoded in Unicode anyway.
- Parameters
-
loc | locale object with valid codecvt<wchar_t, char, mbstate_t> |
◆ imbue_utf8()
auto nuspell::v4::Dictionary::imbue_utf8 |
( |
| ) |
-> void |
Sets external (public API) encoding to UTF-8.
Call this only if you used imbue() and want to revert it to UTF-8.
- Deprecated:
- see imbue()
◆ load_from_aff_dic()
auto nuspell::v4::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
-
aff | The iostream of the .aff file |
dic | The iostream of the .dic file |
- Returns
- Dictionary object
- Exceptions
-
◆ load_from_path()
auto nuspell::v4::Dictionary::load_from_path |
( |
const std::string & |
file_path_without_extension | ) |
-> Dictionary |
|
static |
Create a dictionary from files.
- Parameters
-
file_path_without_extension | path without extensions (without .dic or .aff) |
- Returns
- Dictionary object
- Exceptions
-
◆ spell()
auto nuspell::v4::Dictionary::spell |
( |
std::string_view |
word | ) |
const -> bool |
Checks if a given word is correct.
- Parameters
-
- Returns
- true if correct, false otherwise
◆ suggest()
auto nuspell::v4::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: