class Hunspell::Dictionary

Overview

Represents a dictionary for a specific language.

Defined in:

hunspell/dictionary.cr

Constant Summary

AFF_EXT = "aff"

The affix file extension

DIC_EXT = "dic"

The dictionary file extension

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.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.


[View source]
def self.new(ptr : LibHunspell::HunhandlePtr) #

[View source]
def self.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.


[View source]

Class Method Detail

def self.open(name : String, &block : Dictionary -> ) #

[View source]

Instance Method Detail

def <<(word : String) #

[View source]
def add(word : String) #

Adds a word to the dictionary.

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


[View source]
def add_affix(word : Stirng, example : String) #

@deprecated Please use {#add_with_affix} instead.


[View source]
def 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


[View source]
def 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


[View source]
def 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.


[View source]
def close #

Closes the dictionary.

@return [nil]


[View source]
def closed? #

Determines if the dictionary is closed.

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


[View source]
def delete(word : String) #

[View source]
def encoding : String #

[View source]
def finalize #

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


[View source]
def remove(word : String) #

Removes a word from the dictionary.

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


[View source]
def stem(word : String) : Array(String) #

Finds the stems of a word.

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

@return [Array] The stems of the word.


[View source]
def suggest(word : String) : Array(String) #

Suggests alternate spellings of a word.

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

@return [Array] The suggestions for the word.


[View source]
def to_unsafe : LibHunspell::HunhandlePtr #

Converts the dictionary to a pointer.

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


[View source]
def valid?(word : String) #

[View source]