Nuspell
spellchecker
Classes | Typedefs | Enumerations | Functions | Variables
nuspell::v4 Namespace Reference

Library main namespace with version number attached. More...

Classes

struct  Aff_Data
 
class  Affix_Table
 
struct  Affixing_Result
 
struct  Affixing_Result< T1, void >
 
struct  Affixing_Result< void, void >
 
struct  Affixing_Result_Base
 
class  Break_Table
 
struct  Compound_Pattern
 
class  Compound_Rule_Table
 
struct  Compounding_Result
 
class  Condition
 
struct  Condition_Exception
 
struct  Dict_Base
 
class  Dict_Finder_For_CLI_Tool
 Don't use this except from Nuspell CLI tool. More...
 
class  Dictionary
 The only important public class. More...
 
class  Dictionary_Loading_Error
 The only important public exception. More...
 
struct  Directory
 
class  Encoding
 
class  Encoding_Converter
 
struct  Extractor_First_of_Word_Pair
 
struct  Extractor_Of_Appending_From_Affix
 
class  Finder
 
struct  Globber
 
class  Hash_Multiset
 
struct  identity
 
class  List_Basic_Strings
 
class  Phonetic_Table
 
struct  Prefix
 
class  Prefix_Multiset
 
class  Prefix_Table
 
class  Replacement_Table
 
class  Reversed_String_View
 
class  Setlocale_To_C_In_Scope
 
struct  Similarity_Group
 
class  Simple_Short_String
 
class  String_Pair
 
struct  String_Reverser
 
class  String_Set
 
class  Subrange
 
class  Substr_Replacer
 
struct  Suffix
 
class  Suffix_Table
 
struct  UTF16_Traits
 
struct  UTF32_Traits
 
struct  UTF8_Traits
 
struct  UTF_Traits
 
struct  UTF_Traits< char >
 
struct  UTF_Traits< char16_t >
 

Typedefs

using Word_List = Hash_Multiset< std::pair< std::wstring, Flag_Set >, std::wstring, Extractor_First_of_Word_Pair >
 
using Flag_Set = String_Set< char16_t >
 
template<class T , class Key_Extr = identity>
using Suffix_Multiset = Prefix_Multiset< T, Key_Extr, String_Reverser< typename Prefix_Multiset< T, Key_Extr >::Char_Type > >
 
using Short_WString = Simple_Short_String< wchar_t >
 
using List_Strings = List_Basic_Strings< char >
 
using List_WStrings = List_Basic_Strings< wchar_t >
 

Enumerations

enum  Flag_Type { SINGLE_CHAR, DOUBLE_CHAR, NUMBER, UTF8 }
 
enum  Affixing_Mode { FULL_WORD, AT_COMPOUND_BEGIN, AT_COMPOUND_END, AT_COMPOUND_MIDDLE }
 
enum  Utf_Error_Handling { ALWAYS_VALID, REPLACE, SKIP }
 
enum  Casing : char {
  SMALL, INIT_CAPITAL, ALL_CAPITAL, CAMEL,
  PASCAL
}
 

Functions

auto append_default_dir_paths (std::vector< string > &paths) -> void
 Append the paths of the default directories to be searched for dictionaries. More...
 
auto append_libreoffice_dir_paths (std::vector< std::string > &paths) -> void
 Append the paths of the LibreOffice's directories to be searched for dictionaries. More...
 
auto search_dir_for_dicts (const string &dir_path, vector< pair< string, string >> &dict_list) -> void
 Search a directory for dictionaries. More...
 
auto search_dirs_for_dicts (const std::vector< string > &dir_paths, std::vector< std::pair< string, string >> &dict_list) -> void
 Search the directories for dictionaries. More...
 
auto search_default_dirs_for_dicts (std::vector< std::pair< std::string, std::string >> &dict_list) -> void
 Search the default directories for dictionaries. More...
 
auto find_dictionary (const std::vector< std::pair< std::string, std::string >> &dict_list, const std::string &dict_name) -> std::vector< std::pair< std::string, std::string >>::const_iterator
 Find dictionary path given the name. More...
 
NUSPELL_EXPORT auto append_default_dir_paths (std::vector< std::string > &paths) -> void
 
NUSPELL_EXPORT auto search_dir_for_dicts (const std::string &dir_path, std::vector< std::pair< std::string, std::string >> &dict_list) -> void
 
NUSPELL_EXPORT auto search_dirs_for_dicts (const std::vector< std::string > &dir_paths, std::vector< std::pair< std::string, std::string >> &dict_list) -> void
 
template<class CharT >
constexpr auto literal_choose (const char *narrow, const wchar_t *wide)
 
template<>
constexpr auto literal_choose< char > (const char *narrow, const wchar_t *)
 
template<>
constexpr auto literal_choose< wchar_t > (const char *, const wchar_t *wide)
 
template<class Range >
 Subrange (const Range &r) -> Subrange< typename Range::const_iterator >
 
template<class Range >
 Subrange (Range &r) -> Subrange< typename Range::iterator >
 
template<class CharT >
auto swap (String_Set< CharT > &a, String_Set< CharT > &b)
 
template<class DataIter , class PatternIter , class FuncEq = std::equal_to<>>
auto match_simple_regex (DataIter data_first, DataIter data_last, PatternIter pat_first, PatternIter pat_last, FuncEq eq=FuncEq())
 
template<class DataRange , class PatternRange , class FuncEq = std::equal_to<>>
auto match_simple_regex (const DataRange &data, const PatternRange &pattern, FuncEq eq=FuncEq())
 
auto match_compund_rule (const std::vector< const Flag_Set * > &words_data, const std::u16string &pattern)
 
template<class CharT >
auto swap (List_Basic_Strings< CharT > &a, List_Basic_Strings< CharT > &b)
 
auto split (std::string_view s, char sep, std::vector< std::string > &out) -> std::vector< std::string > &
 
auto split_on_any_of (std::string_view s, const char *sep, std::vector< std::string > &out) -> std::vector< std::string > &
 
auto wide_to_utf8 (std::wstring_view in, std::string &out) -> void
 
auto wide_to_utf8 (std::wstring_view in) -> std::string
 
auto utf8_to_wide (std::string_view in, std::wstring &out) -> bool
 
auto utf8_to_wide (std::string_view in) -> std::wstring
 
auto utf8_to_16 (std::string_view in) -> std::u16string
 
bool utf8_to_16 (std::string_view in, std::u16string &out)
 
auto is_all_ascii (std::string_view s) -> bool
 
auto latin1_to_ucs2 (std::string_view s) -> std::u16string
 
auto latin1_to_ucs2 (std::string_view s, std::u16string &out) -> void
 
auto is_all_bmp (std::u16string_view s) -> bool
 
auto to_wide (std::string_view in, const std::locale &loc, std::wstring &out) -> bool
 
auto to_wide (std::string_view in, const std::locale &loc) -> std::wstring
 
auto to_narrow (std::wstring_view in, std::string &out, const std::locale &loc) -> bool
 
auto to_narrow (std::wstring_view in, const std::locale &loc) -> std::string
 
auto to_upper_ascii (std::string &s) -> void
 
auto to_upper (wstring_view in, const icu::Locale &loc) -> std::wstring
 
auto to_title (wstring_view in, const icu::Locale &loc) -> std::wstring
 
auto to_lower (wstring_view in, const icu::Locale &loc) -> std::wstring
 
auto to_upper (wstring_view in, const icu::Locale &loc, wstring &out) -> void
 
auto to_title (wstring_view in, const icu::Locale &loc, wstring &out) -> void
 
auto to_lower (wstring_view in, const icu::Locale &loc, wstring &out) -> void
 
auto to_lower_char_at (std::wstring &s, size_t i, const icu::Locale &loc) -> void
 
auto to_title_char_at (std::wstring &s, size_t i, const icu::Locale &loc) -> void
 
auto classify_casing (wstring_view s) -> Casing
 
auto has_uppercase_at_compound_word_boundary (wstring_view word, size_t i) -> bool
 
auto replace_char (wstring &s, wchar_t from, wchar_t to) -> void
 
auto erase_chars (wstring &s, wstring_view erase_chars) -> void
 
auto is_number (wstring_view s) -> bool
 
auto count_appereances_of (wstring_view haystack, wstring_view needles) -> size_t
 
NUSPELL_EXPORT auto to_upper (std::wstring_view in, const icu::Locale &loc) -> std::wstring
 
NUSPELL_EXPORT auto to_title (std::wstring_view in, const icu::Locale &loc) -> std::wstring
 
NUSPELL_EXPORT auto to_lower (std::wstring_view in, const icu::Locale &loc) -> std::wstring
 
auto to_upper (std::wstring_view in, const icu::Locale &loc, std::wstring &out) -> void
 
auto to_title (std::wstring_view in, const icu::Locale &loc, std::wstring &out) -> void
 
auto to_lower (std::wstring_view in, const icu::Locale &loc, std::wstring &out) -> void
 
NUSPELL_EXPORT auto classify_casing (std::wstring_view s) -> Casing
 
auto has_uppercase_at_compound_word_boundary (std::wstring_view word, size_t i) -> bool
 
auto replace_char (std::wstring &s, wchar_t from, wchar_t to) -> void
 
auto erase_chars (std::wstring &s, std::wstring_view erase_chars) -> void
 
NUSPELL_EXPORT auto is_number (std::wstring_view s) -> bool
 
auto count_appereances_of (std::wstring_view haystack, std::wstring_view needles) -> size_t
 
auto begins_with (std::wstring_view haystack, std::wstring_view needle) -> bool
 
auto ends_with (std::wstring_view haystack, std::wstring_view needle) -> bool
 
template<class T >
auto begin_ptr (T &x)
 
template<class T >
auto end_ptr (T &x)
 

Variables

const auto PATHSEP = ':'
 
const auto DIRSEP = '/'
 

Detailed Description

Library main namespace with version number attached.

Function Documentation

◆ append_default_dir_paths()

auto nuspell::v4::append_default_dir_paths ( std::vector< string > &  paths) -> void

Append the paths of the default directories to be searched for dictionaries.

Parameters
pathsvector of directory paths to append to

◆ append_libreoffice_dir_paths()

NUSPELL_EXPORT auto nuspell::v4::append_libreoffice_dir_paths ( std::vector< std::string > &  paths) -> void

Append the paths of the LibreOffice's directories to be searched for dictionaries.

Warning
This function shall not be called from LibreOffice or modules that may end up being used by LibreOffice. It is mainly intended to be used by the CLI tool.
Parameters
pathsvector of directory paths to append to

◆ find_dictionary()

NUSPELL_EXPORT auto nuspell::v4::find_dictionary ( const std::vector< std::pair< std::string, std::string >> &  dict_list,
const std::string &  dict_name 
) -> std::vector< std::pair< std::string, std::string >>::const_iterator

Find dictionary path given the name.

Find the first dictionary whose name matches dict_name.

Parameters
dict_listvector of pairs with name and paths
dict_namedictionary name
Returns
iterator of dict_list that points to the found dictionary or end if not found.

◆ search_default_dirs_for_dicts()

NUSPELL_EXPORT auto nuspell::v4::search_default_dirs_for_dicts ( std::vector< std::pair< std::string, std::string >> &  dict_list) -> void

Search the default directories for dictionaries.

See also
append_default_dir_paths()
search_dirs_for_dicts()
Parameters
dict_listvector to append the found dictionaries to

◆ search_dir_for_dicts()

auto nuspell::v4::search_dir_for_dicts ( const string &  dir_path,
vector< pair< string, string >> &  dict_list 
) -> void

Search a directory for dictionaries.

This function searches the directory for files that represent a dictionary and for each one found it appends the pair of dictionary name and filepath to dictionary, both without the filename extension (.aff or .dic).

For example for the files /dict/dir/en_US.dic and /dict/dir/en_US.aff the following pair will be appended ("en_US", "/dict/dir/en_US").

Todo:
At some point this API should be made to be more strongly typed. Instead of using that pair of strings to represent the dictionary files, a new class should be created with three public functions, getters, that would return the name, the path to the .aff file (with filename extension to avoid confusions) and the path to the .dic file. The C++ 17 std::filesystem::path should probably be used. It is unspecified to the public what this class holds privately, but it should probably hold only one path to the aff file. For the directory paths, it is simple, just use the type std::filesystem::path. When this API is created, the same function names should be used, added as overloads. The old API should be marked as deprecated. This should be done when we start requiring GCC 9 which supports C++ 17 filesystem out of the box. GCC 8 has this too, but it is somewhat experimental and requires manually linking to additional static library.
Parameters
dir_pathpath to directory
dict_listvector to append the found dictionaries to

◆ search_dirs_for_dicts()

auto nuspell::v4::search_dirs_for_dicts ( const std::vector< string > &  dir_paths,
std::vector< std::pair< string, string >> &  dict_list 
) -> void

Search the directories for dictionaries.

See also
search_dir_for_dicts()
Parameters
dir_pathslist of paths to directories
dict_listvector to append the found dictionaries to