Debian Codegraph @

README.md

raw symbols SCIP
1 # About Nuspell
2
3 Nuspell is a fast and safe spelling checker software program. It is designed
4 for languages with rich morphology and complex word compounding.
5 Nuspell is written in modern C++ and it supports Hunspell dictionaries.
6
7 Main features of Nuspell spelling checker:
8
9 - Provides software library and command-line tool.
10 - Suggests high-quality spelling corrections.
11 - Backward compatibility with Hunspell dictionary file format.
12 - Up to 3.5 times faster than Hunspell.
13 - Full Unicode support backed by ICU.
14 - Twofold affix stripping (for agglutinative languages, like Azeri,
15 Basque, Estonian, Finnish, Hungarian, Turkish, etc.).
16 - Supports complex compounds (for example, Hungarian, German and Dutch).
17 - Supports advanced features, for example: special casing rules
18 (Turkish dotted i or German sharp s), conditional affixes, circumfixes,
19 fogemorphemes, forbidden words, pseudoroots and homonyms.
20 - Free and open source software. Licensed under GNU LGPL v3 or later.
21
22 # Building Nuspell
23
24 ## Dependencies
25
26 Build-only dependencies:
27
28 - C++ 17 compiler with support for `std::filesystem`, e.g. GCC >= v9
29 - CMake >= v3.18
30 - Catch2 >= v3.1.1 (optional, needed only when building the tests is enabled)
31 - Getopt (Needed only on Windows + MSVC and only when the CLI tool or
32 the tests are built. It is available in Vcpkg. Other platforms provide
33 it out of the box.)
34 - Pandoc (optional, needed only when building the man-pages is enabled)
35 - Doxygen (optional, needed only when building the API docs is enabled)
36
37 Run-time (and build-time) dependencies:
38
39 - ICU4C
40
41 Recommended tools for developers: qtcreator, ninja, clang-format, gdb, vim.
42
43 ## Building on GNU/Linux and Unixes
44
45 We first need to download the dependencies. Some may already be
46 preinstalled.
47
48 For Ubuntu and Debian:
49
50 ```bash
51 sudo apt install g++ cmake libicu-dev catch2 pandoc doxygen
52 ```
53
54 Then run the following commands inside the Nuspell directory:
55
56 ```bash
57 mkdir build
58 cd build
59 cmake ..
60 make
61 sudo make install
62 sudo ldconfig # needed only sometimes and only on Linux
63 ```
64
65
66 For faster build process run `make -j`, or use Ninja instead
67 of Make.
68
69 If you are making a Linux distribution package (dep, rpm) you need
70 some additional configurations on the CMake invocation. For example:
71
72 ```bash
73 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
74 ```
75
76 ## Building on OSX and macOS
77
78 1. Install Apple's Command-line tools.
79 2. Install Homebrew package manager.
80 3. Install dependencies with the next commands.
81
82 <!-- end list -->
83
84 ```bash
85 brew install cmake icu4c catch2 pandoc doxygen
86 export ICU_ROOT=$(brew --prefix icu4c)
87 ```
88
89 Then run the standard cmake and make. See above. The ICU\_ROOT variable
90 is needed because icu4c is keg-only package in Homebrew and CMake can
91 not find it by default. Alternatively, you can use `-DICU_ROOT=...` on
92 the cmake command line.
93
94 If you want to build with GCC instead of Clang, you need to pull GCC
95 with Homebrew and rebuild all the dependencies with it. See Homewbrew
96 manuals.
97
98 ## Building on Windows
99
100 ### Compiling with Visual C++
101
102 1. Install Visual Studio 2017 or newer. Alternatively, you can use
103 Visual Studio Build Tools.
104 2. Install Git for Windows and Cmake.
105 3. Install Vcpkg in some folder, e.g. in `c:\vcpkg`.
106 4. Install Pandoc. You can manually install or use `choco install pandoc`.
107 4. Install Doxygen. You can manually install or use
108 `choco install doxygen.install`.
109 5. Run the commands below. Vcpkg will work in manifest mode and it will
110 automatically install the dependencies.
111
112 <!-- end list -->
113
114 ```bat
115 mkdir build
116 cd build
117 cmake .. -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake -A x64
118 cmake --build .
119 ```
120
121 ### Compiling with Mingw64 and MSYS2
122
123 Download MSYS2, update everything and install the following packages:
124
125 ```bash
126 pacman -S base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-icu \
127 mingw-w64-x86_64-cmake mingw-w64-x86_64-catch mingw-w64-x86_64-doxygen
128 ```
129
130 Then from inside the Nuspell folder run:
131
132 ```bash
133 mkdir build
134 cd build
135 cmake .. -G "Unix Makefiles" -DBUILD_MAN=OFF
136 make
137 make install
138 ```
139
140 ### Building in Cygwin environment
141
142 Download the above mentioned dependencies with Cygwin package manager.
143 Then compile the same way as on Linux. Cygwin builds depend on
144 Cygwin1.dll.
145
146 ## Building on FreeBSD
147
148 Install the following required packages
149
150 ```bash
151 pkg cmake icu catch2 pandoc doxygen
152 ```
153
154 Then run the standard cmake and make as on Linux. See above.
155
156 # Using the software
157
158 ## Using the command-line tool
159
160 The main executable is located in `src/nuspell`.
161
162 After compiling and installing you can run the Nuspell spell checker
163 with a Nuspell, Hunspell or Myspell dictionary:
164
165 nuspell -d en_US text.txt
166
167 For more details run see the [man-page](docs/nuspell.1.md).
168
169 <!-- old hunspell v1 stuff
170 The src/tools directory contains ten executables after compiling.
171
172 - The main executable:
173 - nuspell: main program for spell checking and others (see manual)
174 - Example tools:
175 - analyze: example of spell checking, stemming and morphological
176 analysis
177 - chmorph: example of automatic morphological generation and
178 conversion
179 - example: example of spell checking and suggestion
180 - Tools for dictionary development:
181 - affixcompress: dictionary generation from large (millions of
182 words) vocabularies
183 - makealias: alias compression (Nuspell only, not back compatible
184 with MySpell)
185 - wordforms: word generation (Nuspell version of unmunch)
186 - ~~hunzip: decompressor of hzip format~~ (DEPRECATED)
187 - ~~hzip: compressor of hzip format~~ (DEPRECATED)
188 - munch (DEPRECATED, use affixcompress): dictionary generation
189 from vocabularies (it needs an affix file, too).
190 - unmunch (DEPRECATED, use wordforms): list all recognized words
191 of a MySpell dictionary
192 -->
193
194 ## Using the Library
195
196 Sample program:
197
198 ```cpp
199 #include <iostream>
200 #include <nuspell/dictionary.hxx>
201 #include <nuspell/finder.hxx>
202
203 using namespace std;
204
205 int main()
206 {
207 auto dirs = vector<filesystem::path>();
208 nuspell::append_default_dir_paths(dirs);
209 auto dict_path = nuspell::search_dirs_for_one_dict(dirs, "en_US");
210 if (empty(dict_path))
211 return 1; // Return error because we can not find the requested
212 // dictionary.
213
214 auto dict = nuspell::Dictionary();
215 try {
216 dict.load_aff_dic(dict_path);
217 }
218 catch (const nuspell::Dictionary_Loading_Error& e) {
219 cerr << e.what() << '\n';
220 return 1;
221 }
222 auto word = string();
223 auto sugs = vector<string>();
224 while (cin >> word) {
225 if (dict.spell(word)) {
226 cout << "Word \"" << word << "\" is ok.\n";
227 continue;
228 }
229
230 cout << "Word \"" << word << "\" is incorrect.\n";
231 dict.suggest(word, sugs);
232 if (sugs.empty())
233 continue;
234 cout << " Suggestions are: ";
235 for (auto& sug : sugs)
236 cout << sug << ' ';
237 cout << '\n';
238 }
239 }
240 ```
241
242 On the command line you can link like this:
243
244 ```bash
245 g++ example.cxx -std=c++17 -lnuspell -licuuc -licudata
246 # or better, use pkg-config
247 g++ example.cxx -std=c++17 $(pkg-config --cflags --libs nuspell)
248 ```
249
250 Within Cmake you can use `find_package()` to link. For example:
251
252 ```cmake
253 find_package(Nuspell)
254 add_executable(myprogram main.cpp)
255 target_link_libraries(myprogram Nuspell::nuspell)
256 ```
257
258 # Dictionaries
259
260 Myspell, Hunspell and Nuspell dictionaries:
261
262 <https://github.com/nuspell/nuspell/wiki/Dictionaries-and-Contacts>
263
264
265 # Advanced topics
266 ## Debugging Nuspell
267
268 First, always install the debugger:
269
270 ```bash
271 sudo apt install gdb
272 ```
273
274 For debugging we need to create a debug build and then we need to start
275 `gdb`.
276
277 ```bash
278 mkdir debug
279 cd debug
280 cmake .. -DCMAKE_BUILD_TYPE=Debug
281 make -j
282 gdb src/nuspell/nuspell
283 ```
284
285 We recommend debugging to be done
286 [with an IDE](https://github.com/nuspell/nuspell/wiki/IDE-Setup).
287
288 ## Testing
289
290 To run the tests, run the following command after building:
291
292 ctest
293
294 # See also
295
296 Full documentation in the [wiki](https://github.com/nuspell/nuspell/wiki).
297
298 API Documentation for developers will be generated from the source files
299 by configuring CMake with `-DBUILD_API_DOCS=ON` (ON by default) and building.
300
301 The result can be viewed by opening `BUILD_DIR/docs/html/index.html` during
302 development, or by opening `INSTALL_PREFIX/share/doc/nuspell/html/index.html`
303 after installing.