nuspell: nuspell/dictionary.hxx Source File

nuspell 5.1.8 Nuspell spellchecking library

Loading...
Searching...
No Matches
dictionary.hxx
Go to the documentation of this file.
1/* Copyright 2016-2024 Dimitrij Mijoski
2 *
3 * This file is part of Nuspell.
4 *
5 * Nuspell is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * Nuspell is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with Nuspell. If not, see <http://www.gnu.org/licenses/>.
17 */
18
23
24#ifndef NUSPELL_DICTIONARY_HXX
25#define NUSPELL_DICTIONARY_HXX
26
27#include "suggester.hxx"
28
29#include <filesystem>
30
31namespace nuspell {
32NUSPELL_BEGIN_INLINE_NAMESPACE
33
37 class Dictionary_Loading_Error : public std::runtime_error {
38 public:
39 using std::runtime_error::runtime_error;
40};
41
45 class NUSPELL_EXPORT Dictionary : private Suggester {
46 [[deprecated]] Dictionary(std::istream& aff, std::istream& dic);
47
48 public:
49 Dictionary();
50 auto load_aff_dic(std::istream& aff, std::istream& dic) -> void;
51 auto load_aff_dic(const std::filesystem::path& aff_path) -> void;
52
57 auto load_aff_dic_internal(const std::filesystem::path& aff_path,
58 std::ostream& err_msg) -> void;
59
60 [[deprecated]] auto static load_from_aff_dic(std::istream& aff,
61 std::istream& dic)
62 -> Dictionary;
63 [[deprecated]] auto static load_from_path(
64 const std::string& file_path_without_extension) -> Dictionary;
65 auto spell(std::string_view word) const -> bool;
66 auto suggest(std::string_view word, std::vector<std::string>& out) const
67 -> void;
68};
69
70NUSPELL_END_INLINE_NAMESPACE
71} // namespace nuspell
72#endif // NUSPELL_DICTIONARY_HXX
nuspell::Dictionary_Loading_Error
The only important public exception.
Definition dictionary.hxx:37
nuspell::Dictionary::load_aff_dic
auto load_aff_dic(std::istream &aff, std::istream &dic) -> void
Load the dictionary from opened files as iostreams.
Definition dictionary.cxx:56
nuspell::Dictionary::spell
auto spell(std::string_view word) const -> bool
Checks if a given word is correct.
Definition dictionary.cxx:146
nuspell::Dictionary::load_from_path
static auto load_from_path(const std::string &file_path_without_extension) -> Dictionary
Create a dictionary from files.
Definition dictionary.cxx:133
nuspell::Dictionary::suggest
auto suggest(std::string_view word, std::vector< std::string > &out) const -> void
Suggests correct words for a given incorrect word.
Definition dictionary.cxx:162
nuspell::Dictionary::load_from_aff_dic
static auto load_from_aff_dic(std::istream &aff, std::istream &dic) -> Dictionary
Create a dictionary from opened files as iostreams.
Definition dictionary.cxx:115
nuspell
Library main namespace.
Definition aff_data.cxx:33