class Hunspell::Dictionary
- Hunspell::Dictionary
- Reference
- Object
Overview
Represents a dictionary for a specific language.
Defined in:
hunspell/dictionary.crConstant Summary
-
AFF_EXT =
"aff"
-
The affix file extension
-
DIC_EXT =
"dic"
-
The dictionary file extension
Constructors
-
.new(affix_path : String, dic_path : String, key : String | Nil = nil)
Creates a new dictionary.
- .new(ptr : LibHunspell::HunhandlePtr)
-
.open(name : String) : Dictionary
Opens a Hunspell dictionary.
Class Method Summary
Instance Method Summary
- #<<(word : String)
-
#add(word : String)
Adds a word to the dictionary.
-
#add_affix(word : Stirng, example : String)
@deprecated Please use {#add_with_affix} instead.
-
#add_dic(dic_path : String)
Load an extra dictionary file.
-
#add_with_affix(word : String, example : String)
Adds a word to the dictionary with affix flags.
-
#check?(word : String) : Bool
Checks if the word is validate.
-
#close
Closes the dictionary.
-
#closed?
Determines if the dictionary is closed.
- #delete(word : String)
- #encoding : String
-
#finalize
Finalizes the underlying
libhunspell
handler pointer, if it already hasn't been deallocated by#close
. -
#remove(word : String)
Removes a word from the dictionary.
-
#stem(word : String) : Array(String)
Finds the stems of a word.
-
#suggest(word : String) : Array(String)
Suggests alternate spellings of a word.
-
#to_unsafe : LibHunspell::HunhandlePtr
Converts the dictionary to a pointer.
- #valid?(word : String)
Constructor Detail
Creates a new dictionary.
@param [String] affix_path
The path to the .aff
file.
@param [String] dic_path
The path to the .dic
file.
@param [String] key The optional key for encrypted dictionary files.
@raise [RuntimeError]
Either the .aff
or .dic
files did not exist.
Opens a Hunspell dictionary.
@param [Symbol, String] name The name of the dictionary to open.
@yield [dict] The given block will be passed the Hunspell dictionary.
@yieldparam [Dictionary] dict The opened dictionary.
@return [Dictionary] If no block is given, the open dictionary will be returned.
@raise [ArgumentError] The dictionary files could not be found in any of the directories.
Class Method Detail
Instance Method Detail
Adds a word to the dictionary.
@param [String] word The word to add to the dictionary.
Load an extra dictionary file. The extra dictionaries use the affix file of the allocated Hunspell object.
Maximal number of extra dictionaries is limited in the source code (20)
@param [String] dic_path
The path to the extra .dic
file.
@raise [ArgumentError]
The extra .dic
file did not exist.
@since 0.6.0
Adds a word to the dictionary with affix flags.
@param [String] word The word to add to the dictionary.
@param [String] example Affix flags.
@since 0.4.0
Checks if the word is validate.
@param [#to_s] word The word in question.
@return [Boolean] Specifies whether the word is valid.
Determines if the dictionary is closed.
@return [Boolean] Specifies whether the dictionary was closed.
Finalizes the underlying libhunspell
handler pointer, if it already
hasn't been deallocated by #close
.
Removes a word from the dictionary.
@param [#to_s] word The word to remove.
Finds the stems of a word.
@param [#to_s] word The word in question.
@return [Array
Suggests alternate spellings of a word.
@param [#to_s] word The word in question.
@return [Array
Converts the dictionary to a pointer.
@return [LibHunspell::HunhandlePtr] The pointer for the dictionary.