unihan2 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/unihan2.rb ADDED
@@ -0,0 +1,25 @@
1
+ class Unihan2
2
+ DATA_DIR = File.join(File.dirname(__FILE__), '../data')
3
+
4
+ def initialize
5
+ fn = File.join(DATA_DIR, 'Unihan_DictionaryLikeData.txt')
6
+ @strokes = {}
7
+ File.foreach(fn) do |line|
8
+ next if line.start_with? '#'
9
+ line.chomp!
10
+ cells = line.split("\t")
11
+ if cells[1] == 'kTotalStrokes'
12
+ c = [cells[0].sub(/^U\+(.*)$/, '\1').hex].pack('U')
13
+ i = cells[2].to_i
14
+ @strokes[c] = i
15
+ end
16
+ end
17
+ end
18
+
19
+ # return total strokes of the character char
20
+ # @param char [String] the character
21
+ # @return [Integer] the total strokes
22
+ def strokes(char)
23
+ @strokes[char]
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unihan2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Ray Chou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Unihan Database Utilities
14
+ email: zhoubx@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - data/Unihan_DictionaryLikeData.txt
20
+ - lib/unihan2.rb
21
+ homepage: https://github.com/RayCHOU/unihan2
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.8
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Chinese
45
+ test_files: []