chinese_number 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46ea1d2202268f055e90c1217fc86eff132622bf
4
- data.tar.gz: 973db4e1a05ddc47a36c9cc68f6b03c8ca8a5286
3
+ metadata.gz: 9fbb6c1256556e75af180c6b8f789d95c9b8355e
4
+ data.tar.gz: feaf72289d42c70f875f9d0009f12dc2273b940f
5
5
  SHA512:
6
- metadata.gz: 72f416e8c01b10036d4a83ea5f844072a718c68cf8afc328ecdbc31c4d79f43dc7f2dd7f6d01e438c8665b3b6fc77e65fcc771b53e2e305c9a4331d866eb7389
7
- data.tar.gz: 680469fda7cf8ed8441c63f8e7cb02944ba9802e9cdce441d100e06db90a3d6489adf36a2ee066bb8b061e4c233f52daeb64816bc965deece9573a87e4f3986b
6
+ metadata.gz: 329760a6425c24d4c0b07cf94086ca7f02c052bb82dd485b9ff09018978191e5770b0ea76ffcee8ff1e8a194a303acc096a4f50270ec5c08d4f1a75928be1dc1
7
+ data.tar.gz: 6dcb28b20fb09ca5137fe3166a95eebfde904df89af152579ef816e293eb4f45aec80b10fd8a011603bafd97be1af9b7475ec55eae86611c86d7c0805f6ff363
data/README.md CHANGED
@@ -27,13 +27,18 @@ ChinseNumber.trans "一年有三百六十五天"
27
27
  可以用封装后的高级 api:
28
28
 
29
29
  ~~~ruby
30
+ require 'chinese_number'
31
+
30
32
  ChinseNumber.trans "我有十块钱"
31
33
  #=> "我有10块钱"
32
34
 
33
35
  ChinseNumber.trans "二〇一四年"
34
36
  #=> "2014年"
35
37
 
36
- ChineseNumber.extract '每分钟六十秒的速度前进二十四小时'
38
+ ChineseNumber.find "每分钟六十秒的速度前进二十四小时"
39
+ #=> [{'六十' => 60}, {'二十四' => 24}]
40
+
41
+ ChineseNumber.extract "每分钟六十秒的速度前进二十四小时"
37
42
  #=> [60, 24]
38
43
  ~~~
39
44
 
@@ -15,5 +15,11 @@ module ChineseNumber
15
15
  Parser.new.parse( word )
16
16
  end
17
17
  end
18
+
19
+ def find text
20
+ text.scan( Parser::TOKEN ).map do |word|
21
+ { word => Parser.new.parse( word ) }
22
+ end
23
+ end
18
24
  end
19
25
  end
@@ -1,3 +1,3 @@
1
1
  module ChineseNumber
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -11,5 +11,12 @@ describe ChineseNumber do
11
11
  ChineseNumber.extract('每分钟六十秒的速度前进二十四小时').should == [60, 24]
12
12
  end
13
13
 
14
+ it '可以寻找字符串内的中文数字' do
15
+ ChineseNumber.find('每分钟六十秒的速度前进二十四小时').should == [
16
+ { '六十' => 60 },
17
+ { '二十四' => 24 }
18
+ ]
19
+ end
20
+
14
21
  end
15
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chinese_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - qhwa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler