cantonese 0.1.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.
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'cantonese/scraper/classified_scraper'
3
+
4
+ describe Cantonese::Scraper::ClassifiedScraper do
5
+ context "#crawl", :vcr => {:record => :new_episodes} do
6
+ it "should fetch list of classified words" do
7
+ classified = subject.crawl
8
+ expect(classified).to be_a(Array)
9
+
10
+ classified.each do |word|
11
+ expect(word[:radical_id]).to_not be_nil
12
+ expect(word[:text]).to_not be_nil
13
+ expect(word[:type]).to_not be_nil
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'cantonese/scraper/radical_scraper'
3
+
4
+ describe Cantonese::Scraper::RadicalScraper do
5
+ context "#crawl", :vcr => {:record => :new_episodes} do
6
+ it "should list of radicals" do
7
+ radicals = subject.crawl
8
+ expect(radicals).to be_a(Array)
9
+ radicals.each do |radical|
10
+ expect(radical[:name]).to_not be_nil
11
+ expect(radical[:stroke]).to_not be_nil
12
+ expect(radical[:id]).to_not be_nil
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+ require 'cantonese/scraper/word_scraper'
3
+
4
+ describe Cantonese::Scraper::WordScraper do
5
+ context "#crawl", :vcr => {:record => :new_episodes} do
6
+ it "should return detail of a word" do
7
+ word = subject.crawl("一")
8
+ expect(word).to be_a(Hash)
9
+
10
+ expect(word[:text]).to eq("一")
11
+
12
+ expect(word[:stroke]).to eq(1)
13
+ expect(word[:radical_id]).to eq(1)
14
+ expect(word[:classified]).to be_include("單讀音字")
15
+
16
+ expect(word[:big5]).to eq("A440")
17
+ expect(word[:chanjie]).to eq("一")
18
+ expect(word[:frequency]).to eq("2 / 166396")
19
+ expect(word[:combination]).to be_a(Array)
20
+ expect(word[:combination]).to be_include("山")
21
+
22
+ expect(word[:syllable]).to be_a(Array)
23
+ expect(word[:syllable][0][:initial]).to eq("j")
24
+ expect(word[:syllable][0][:final]).to eq("at")
25
+ expect(word[:syllable][0][:tone]).to eq("1")
26
+
27
+ expect(word[:syllable][0][:examples]).to be_a(Array)
28
+ expect(word[:syllable][0][:examples]).to be_include("一視同仁")
29
+ end
30
+
31
+ it "should return detail of a word with multiple sounds" do
32
+ word = subject.crawl("可")
33
+ expect(word).to be_a(Hash)
34
+
35
+ expect(word[:text]).to eq("可")
36
+
37
+ expect(word[:stroke]).to eq(5)
38
+ expect(word[:radical_id]).to eq(30)
39
+ expect(word[:classified]).to eq("破音字")
40
+
41
+ expect(word[:big5]).to eq("A569")
42
+ expect(word[:chanjie]).to eq("一弓口")
43
+ expect(word[:frequency]).to eq("36 / 40754")
44
+ expect(word[:combination]).to be_a(Array)
45
+ expect(word[:combination]).to be_include("不")
46
+
47
+ expect(word[:syllable]).to be_a(Array)
48
+ expect(word[:syllable][0][:initial]).to eq("h")
49
+ expect(word[:syllable][0][:final]).to eq("ak")
50
+ expect(word[:syllable][0][:tone]).to eq("1")
51
+ expect(word[:syllable][0][:examples]).to be_a(Array)
52
+ expect(word[:syllable][0][:examples]).to be_include("可汗")
53
+
54
+ expect(word[:syllable][1][:initial]).to eq("h")
55
+ expect(word[:syllable][1][:final]).to eq("o")
56
+ expect(word[:syllable][1][:tone]).to eq("2")
57
+ expect(word[:syllable][1][:examples]).to be_a(Array)
58
+ expect(word[:syllable][1][:examples]).to be_include("可歌可泣")
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH << "lib"
2
+
3
+ require 'vcr'
4
+ require 'pry'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'spec/fixtures/cassettes'
8
+ c.hook_into :webmock
9
+ c.configure_rspec_metadata!
10
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cantonese
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Francis Chong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - francis@ignition.hk
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - cantonese.gemspec
124
+ - lib/cantonese.rb
125
+ - lib/cantonese/scraper/classified_scraper.rb
126
+ - lib/cantonese/scraper/radical_scraper.rb
127
+ - lib/cantonese/scraper/word_scraper.rb
128
+ - lib/cantonese/version.rb
129
+ - spec/fixtures/cassettes/Cantonese_Scraper_ClassifiedScraper/_crawl/should_fetch_list_of_classified_words.yml
130
+ - spec/fixtures/cassettes/Cantonese_Scraper_RadicalScraper/_crawl/should_list_of_radicals.yml
131
+ - spec/fixtures/cassettes/Cantonese_Scraper_WordScraper/_crawl/should_return_detail_of_a_word.yml
132
+ - spec/fixtures/cassettes/Cantonese_Scraper_WordScraper/_crawl/should_return_detail_of_a_word_with_multiple_sounds.yml
133
+ - spec/scraper/classified_scraper_spec.rb
134
+ - spec/scraper/radical_scraper_spec.rb
135
+ - spec/scraper/word_scraper_spec.rb
136
+ - spec/spec_helper.rb
137
+ homepage: https://github.com/siuying/cantonese
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.2.0
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Set of scraper and processor to fetch Cantonese data.
161
+ test_files:
162
+ - spec/fixtures/cassettes/Cantonese_Scraper_ClassifiedScraper/_crawl/should_fetch_list_of_classified_words.yml
163
+ - spec/fixtures/cassettes/Cantonese_Scraper_RadicalScraper/_crawl/should_list_of_radicals.yml
164
+ - spec/fixtures/cassettes/Cantonese_Scraper_WordScraper/_crawl/should_return_detail_of_a_word.yml
165
+ - spec/fixtures/cassettes/Cantonese_Scraper_WordScraper/_crawl/should_return_detail_of_a_word_with_multiple_sounds.yml
166
+ - spec/scraper/classified_scraper_spec.rb
167
+ - spec/scraper/radical_scraper_spec.rb
168
+ - spec/scraper/word_scraper_spec.rb
169
+ - spec/spec_helper.rb