class

Hunspell::Dictionary

Inherits Reference < Object

Represents a dictionary for a specific language.

Constants

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.

@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.

Source
new(ptr : LibHunspell::HunhandlePtr)
Source
open(name : String) : Dictionary

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.

Source

Class methods

open(name : String, &block : Dictionary -> )
Source

Instance methods

<<(word : String)
Source
add(word : String)

Adds a word to the dictionary.

@param [String] word The word to add to the dictionary.

Source
add_affix(word : Stirng, example : String)

@deprecated Please use {#add_with_affix} instead.

Source
add_dic(dic_path : String)

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

Source
add_with_affix(word : String, example : String)

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

Source
check?(word : String) : Bool

Checks if the word is validate.

@param [#to_s] word The word in question.

@return [Boolean] Specifies whether the word is valid.

Source
close

Closes the dictionary.

@return [nil]

Source
closed?

Determines if the dictionary is closed.

@return [Boolean] Specifies whether the dictionary was closed.

Source
delete(word : String)
Source
encoding
Source
finalize

Finalizes the underlying libhunspell handler pointer, if it already hasn't been deallocated by #close.

Source
remove(word : String)

Removes a word from the dictionary.

@param [#to_s] word The word to remove.

Source
stem(word : String) : Array(String)

Finds the stems of a word.

@param [#to_s] word The word in question.

@return [Array<String>] The stems of the word.

Source
suggest(word : String) : Array(String)

Suggests alternate spellings of a word.

@param [#to_s] word The word in question.

@return [Array<String>] The suggestions for the word.

Source
to_unsafe

Converts the dictionary to a pointer.

@return [LibHunspell::HunhandlePtr] The pointer for the dictionary.

Source
valid?(word : String)
Source