Class: Kotoshu::Languages::Arabic

Inherits:
Kotoshu::Language::Base show all
Defined in:
lib/kotoshu/languages/ar/language.rb

Overview

Arabic language implementation.

Registers the Arabic language with Kotoshu::Language::Registry under the ar and ar-SA codes. Uses the Kotoshu::Language::Normalizer::Arabic normalizer (NFC + presentation-form canonicalization + tashkeel stripping) so that the same word typed in different input methods produces the same normalized form for dictionary lookup.

Examples:

lang = Kotoshu::Languages::Arabic.new
lang.script_type  # => :arabic
lang.rtl?         # => true

Defined Under Namespace

Classes: Tokenizer

Instance Attribute Summary

Attributes inherited from Kotoshu::Language::Base

#code, #name, #region, #variant

Instance Method Summary collapse

Methods inherited from Kotoshu::Language::Base

#base_code, #base_language?, #compatible_with?, #encoding, #full_name, #info, instance, #matches_code?, #normalize, #normalize_word, #region_code, register, registered_codes, #tokenize, #valid_word?

Constructor Details

#initialize(code: "ar", name: "Arabic", variant: nil) ⇒ Arabic

Returns a new instance of Arabic.



21
22
23
# File 'lib/kotoshu/languages/ar/language.rb', line 21

def initialize(code: "ar", name: "Arabic", variant: nil)
  super
end

Instance Method Details

#default_dictionary_pathsObject



41
42
43
# File 'lib/kotoshu/languages/ar/language.rb', line 41

def default_dictionary_paths
  ["/usr/share/dict/arabic"]
end

#descriptionObject



25
26
27
# File 'lib/kotoshu/languages/ar/language.rb', line 25

def description
  name
end

#dictionary_classObject



37
38
39
# File 'lib/kotoshu/languages/ar/language.rb', line 37

def dictionary_class
  Dictionary::Custom
end

#normalizerObject



33
34
35
# File 'lib/kotoshu/languages/ar/language.rb', line 33

def normalizer
  @normalizer ||= Language::Normalizer::Arabic.new
end

#rtl?Boolean

Arabic is written right-to-left.

Returns:

  • (Boolean)


50
51
52
# File 'lib/kotoshu/languages/ar/language.rb', line 50

def rtl?
  true
end

#script_typeObject



45
46
47
# File 'lib/kotoshu/languages/ar/language.rb', line 45

def script_type
  :arabic
end

#tokenizerObject



29
30
31
# File 'lib/kotoshu/languages/ar/language.rb', line 29

def tokenizer
  @tokenizer ||= Tokenizer.new
end