Class: Kotoshu::Languages::Persian

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

Overview

Persian (Farsi) language implementation.

Registers the Persian language with Kotoshu::Language::Registry under the fa and fa-IR codes. Uses the Kotoshu::Language::Normalizer::Persian normalizer (Arabic normalization plus Arabic→Persian letter canonicalization).

Examples:

lang = Kotoshu::Languages::Persian.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: "fa", name: "Persian", variant: nil) ⇒ Persian

Returns a new instance of Persian.



20
21
22
# File 'lib/kotoshu/languages/fa/language.rb', line 20

def initialize(code: "fa", name: "Persian", variant: nil)
  super
end

Instance Method Details

#default_dictionary_pathsObject



40
41
42
# File 'lib/kotoshu/languages/fa/language.rb', line 40

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

#descriptionObject



24
25
26
# File 'lib/kotoshu/languages/fa/language.rb', line 24

def description
  name
end

#dictionary_classObject



36
37
38
# File 'lib/kotoshu/languages/fa/language.rb', line 36

def dictionary_class
  Dictionary::Custom
end

#normalizerObject



32
33
34
# File 'lib/kotoshu/languages/fa/language.rb', line 32

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

#rtl?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/kotoshu/languages/fa/language.rb', line 48

def rtl?
  true
end

#script_typeObject



44
45
46
# File 'lib/kotoshu/languages/fa/language.rb', line 44

def script_type
  :arabic
end

#tokenizerObject



28
29
30
# File 'lib/kotoshu/languages/fa/language.rb', line 28

def tokenizer
  @tokenizer ||= Tokenizer.new
end