zidian 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.mkd +4 -0
- data/VERSION +1 -1
- data/lib/zidian.rb +2 -1
- data/test/test_zidian.rb +10 -0
- data/zidian.gemspec +2 -2
- metadata +4 -4
data/README.mkd
CHANGED
|
@@ -19,6 +19,10 @@ Examples of use
|
|
|
19
19
|
Zidian.find("文") # returns all the words that contain "文"
|
|
20
20
|
|
|
21
21
|
Zidian.find([653,34]) # returns the 2 words corresponding to the given ids
|
|
22
|
+
|
|
23
|
+
Zidian.find("wei2 cheng2") # returns the words corresponding to the given pinyin with tones
|
|
24
|
+
|
|
25
|
+
Zidian.find("wei cheng") # returns the words corresponding to the given pinyin without tones
|
|
22
26
|
|
|
23
27
|
Author: Bastien Vaucher
|
|
24
28
|
Version: 0.1.1
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/lib/zidian.rb
CHANGED
|
@@ -17,8 +17,9 @@ module Zidian
|
|
|
17
17
|
protected
|
|
18
18
|
|
|
19
19
|
def self.find_word(word) #:nodoc:
|
|
20
|
+
words = word.split.map{|w| "#{w}[1-4]?"}.join(" ")
|
|
20
21
|
# adding the -i option allows to search independently from the case, but it makes it very slow
|
|
21
|
-
`less #{File.dirname(__FILE__)}/cedict_ts.u8 | grep -n '[
|
|
22
|
+
`less #{File.dirname(__FILE__)}/cedict_ts.u8 | grep -n -E '(^|[^a-zA-Z])#{words}($|[^a-zA-Z])'`
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
def self.get_line(line_number) #:nodoc:
|
data/test/test_zidian.rb
CHANGED
|
@@ -29,6 +29,16 @@ class TestZidian < Test::Unit::TestCase
|
|
|
29
29
|
assert_equal("guai3", words.last.pinyin)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def test_find_word_from_pinyin
|
|
33
|
+
words = Zidian.find("wei cheng")
|
|
34
|
+
assert_equal("围城", words.first.simplified)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_find_word_from_pinyin_marked
|
|
38
|
+
words = Zidian.find("wei2 cheng2")
|
|
39
|
+
assert_equal("siege", words.first.english.first)
|
|
40
|
+
end
|
|
41
|
+
|
|
32
42
|
def test_raise_when_invalid_input_type
|
|
33
43
|
assert_raise(Zidian::InvalFindInputException) do
|
|
34
44
|
Zidian.find(:shanghai)
|
data/zidian.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{zidian}
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.2.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Bastien Vaucher"]
|
|
12
|
-
s.date = %q{2010-04-
|
|
12
|
+
s.date = %q{2010-04-10}
|
|
13
13
|
s.description = %q{Chinese dictionary using the CEDICT word list}
|
|
14
14
|
s.email = %q{bastien.vaucher@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
version: 0.
|
|
7
|
+
- 2
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.2.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Bastien Vaucher
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-04-
|
|
17
|
+
date: 2010-04-10 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies: []
|
|
20
20
|
|