Class: UnihanLang::ChineseProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/unihan_lang/chinese_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChineseProcessor

Returns a new instance of ChineseProcessor.



7
8
9
10
11
12
# File 'lib/unihan_lang/chinese_processor.rb', line 7

def initialize
  @zh_tw = Set.new
  @zh_cn = Set.new
  @common = Set.new
  load_chinese_characters
end

Instance Attribute Details

#commonObject (readonly)

Returns the value of attribute common.



5
6
7
# File 'lib/unihan_lang/chinese_processor.rb', line 5

def common
  @common
end

#zh_cnObject (readonly)

Returns the value of attribute zh_cn.



5
6
7
# File 'lib/unihan_lang/chinese_processor.rb', line 5

def zh_cn
  @zh_cn
end

#zh_twObject (readonly)

Returns the value of attribute zh_tw.



5
6
7
# File 'lib/unihan_lang/chinese_processor.rb', line 5

def zh_tw
  @zh_tw
end

Instance Method Details

#chinese?(char) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/unihan_lang/chinese_processor.rb', line 30

def chinese?(char)
  zh_tw?(char) || zh_cn?(char) || cjk?(char)
end

#chinese_character?(char) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/unihan_lang/chinese_processor.rb', line 34

def chinese_character?(char)
  chinese?(char)
end

#only_zh_cn?(char) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/unihan_lang/chinese_processor.rb', line 26

def only_zh_cn?(char)
  @zh_cn.include?(char)
end

#only_zh_tw?(char) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/unihan_lang/chinese_processor.rb', line 22

def only_zh_tw?(char)
  @zh_tw.include?(char) && !@common.include?(char)
end

#zh_cn?(char) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/unihan_lang/chinese_processor.rb', line 18

def zh_cn?(char)
  @zh_cn.include?(char) || @common.include?(char)
end

#zh_tw?(char) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/unihan_lang/chinese_processor.rb', line 14

def zh_tw?(char)
  @zh_tw.include?(char) || @common.include?(char)
end