dict 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/dict/dict.rb +1 -4
- data/lib/dict/version.rb +1 -1
- data/lib/dict/wiktionary.rb +9 -11
- data/spec/dict/lib_dict_cli_runner_spec.rb +11 -11
- data/spec/dict/lib_dict_spec.rb +8 -17
- data/spec/dict/vcr_cassettes/translations_slownik_cassette.yml +564 -2470
- data/spec/dict/vcr_cassettes/wiktionary_translations_field_cassette.yml +1439 -1398
- data/spec/dict/vcr_cassettes/wiktionary_translations_samochod_cassette.yml +527 -1831
- metadata +2 -29
- data/lib/dict/dictpl.rb +0 -22
- data/spec/dict/lib_dictpl_spec.rb +0 -55
- data/spec/dict/vcr_cassettes/dictpl_examples_krowa_cassette.yml +0 -1040
- data/spec/dict/vcr_cassettes/dictpl_samochod_cassette.yml +0 -1089
- data/spec/dict/vcr_cassettes/dictpl_translations_krowa_cassette.yml +0 -1040
- data/spec/dict/vcr_cassettes/examples_krowa_cassette.yml +0 -1040
- data/spec/dict/vcr_cassettes/examples_samochod_cassette.yml +0 -1089
- data/spec/dict/vcr_cassettes/paired_value_samochod_cassette.yml +0 -1089
- data/spec/dict/vcr_cassettes/translations_krowa_cassette.yml +0 -1040
- data/spec/dict/vcr_cassettes/translations_samochod_cassette.yml +0 -1089
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -151,23 +151,13 @@ files:
|
|
151
151
|
- lib/dict/cli/runner.rb
|
152
152
|
- lib/dict/dict.rb
|
153
153
|
- lib/dict/dictionary.rb
|
154
|
-
- lib/dict/dictpl.rb
|
155
154
|
- lib/dict/result.rb
|
156
155
|
- lib/dict/version.rb
|
157
156
|
- lib/dict/wiktionary.rb
|
158
157
|
- spec/dict/lib_dict_cli_runner_spec.rb
|
159
158
|
- spec/dict/lib_dict_spec.rb
|
160
|
-
- spec/dict/lib_dictpl_spec.rb
|
161
159
|
- spec/dict/lib_wiktionary_spec.rb
|
162
160
|
- spec/dict/spec_helper.rb
|
163
|
-
- spec/dict/vcr_cassettes/dictpl_examples_krowa_cassette.yml
|
164
|
-
- spec/dict/vcr_cassettes/dictpl_samochod_cassette.yml
|
165
|
-
- spec/dict/vcr_cassettes/dictpl_translations_krowa_cassette.yml
|
166
|
-
- spec/dict/vcr_cassettes/examples_krowa_cassette.yml
|
167
|
-
- spec/dict/vcr_cassettes/examples_samochod_cassette.yml
|
168
|
-
- spec/dict/vcr_cassettes/paired_value_samochod_cassette.yml
|
169
|
-
- spec/dict/vcr_cassettes/translations_krowa_cassette.yml
|
170
|
-
- spec/dict/vcr_cassettes/translations_samochod_cassette.yml
|
171
161
|
- spec/dict/vcr_cassettes/translations_slownik_cassette.yml
|
172
162
|
- spec/dict/vcr_cassettes/wiktionary_translations_field_cassette.yml
|
173
163
|
- spec/dict/vcr_cassettes/wiktionary_translations_samochod_cassette.yml
|
@@ -196,21 +186,4 @@ rubygems_version: 1.8.24
|
|
196
186
|
signing_key:
|
197
187
|
specification_version: 3
|
198
188
|
summary: Gem made for dictionary application
|
199
|
-
test_files:
|
200
|
-
- spec/dict/lib_dict_cli_runner_spec.rb
|
201
|
-
- spec/dict/lib_dict_spec.rb
|
202
|
-
- spec/dict/lib_dictpl_spec.rb
|
203
|
-
- spec/dict/lib_wiktionary_spec.rb
|
204
|
-
- spec/dict/spec_helper.rb
|
205
|
-
- spec/dict/vcr_cassettes/dictpl_examples_krowa_cassette.yml
|
206
|
-
- spec/dict/vcr_cassettes/dictpl_samochod_cassette.yml
|
207
|
-
- spec/dict/vcr_cassettes/dictpl_translations_krowa_cassette.yml
|
208
|
-
- spec/dict/vcr_cassettes/examples_krowa_cassette.yml
|
209
|
-
- spec/dict/vcr_cassettes/examples_samochod_cassette.yml
|
210
|
-
- spec/dict/vcr_cassettes/paired_value_samochod_cassette.yml
|
211
|
-
- spec/dict/vcr_cassettes/translations_krowa_cassette.yml
|
212
|
-
- spec/dict/vcr_cassettes/translations_samochod_cassette.yml
|
213
|
-
- spec/dict/vcr_cassettes/translations_slownik_cassette.yml
|
214
|
-
- spec/dict/vcr_cassettes/wiktionary_translations_field_cassette.yml
|
215
|
-
- spec/dict/vcr_cassettes/wiktionary_translations_samochod_cassette.yml
|
216
|
-
- spec/dict/vcr_setup.rb
|
189
|
+
test_files: []
|
data/lib/dict/dictpl.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'nokogiri'
|
4
|
-
require 'dict/dictionary'
|
5
|
-
|
6
|
-
DICT_URL = 'http://dict.pl/dict?word='
|
7
|
-
|
8
|
-
module Dict
|
9
|
-
class Dictpl < Dictionary
|
10
|
-
# returns hash with structure as showed below
|
11
|
-
# { 'TRANSLATION' => ['EXAMPLE', ...], ... }
|
12
|
-
def translate
|
13
|
-
context_words = []
|
14
|
-
Nokogiri::HTML(open(uri(DICT_URL, @word))).xpath('//td[@class="resWordCol"]/a').each do |node|
|
15
|
-
context_words << node.text
|
16
|
-
end
|
17
|
-
make_hash_results(context_words)
|
18
|
-
rescue OpenURI::HTTPError
|
19
|
-
raise Dictionary::ConnectError
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*
|
2
|
-
|
3
|
-
require_relative './vcr_setup'
|
4
|
-
require 'dict/dictpl'
|
5
|
-
|
6
|
-
describe Dict::Dictpl do
|
7
|
-
|
8
|
-
it "should raise no given word exception" do
|
9
|
-
expect { Dict::Dictpl.new }.to raise_error ArgumentError
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return array with translations for 'krowa'" do
|
13
|
-
VCR.use_cassette('dictpl_translations_krowa_cassette') do
|
14
|
-
d = Dict::Dictpl.new("krowa")
|
15
|
-
d.translate
|
16
|
-
d.translations.should be_a(Array)
|
17
|
-
d.translations.should == ["krowa", "krowa bliska wycielenia", "krowa mleczna", "krowa morska; Hydrodamalis gigas", "krowa morska; krowa morska Stellera; Hydrodamalis gigas (wymarły ssak morski)", "krowa nie zapłodniona", "krowa po pierwszym ocieleniu się", "krowa wysokomleczna", "cielna krowa", "dojna krowa", "mleczna krowa", "wata cukrowa", "mąka cukrowa", "święta krowa", "trzcina cukrowa", "lukier; polewa lukrowa", "święta krowa [przen]"]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return array with examples for 'krowa'" do
|
22
|
-
VCR.use_cassette('dictpl_examples_krowa_cassette') do
|
23
|
-
d = Dict::Dictpl.new("krowa")
|
24
|
-
d.translate
|
25
|
-
d.examples.should be_a(Array)
|
26
|
-
d.examples.should == [["cow"], ["freshen of cow"], ["milker", "milcher", "milk cow", "dairy cow", "milch cow"], ["Steller's sea cow"], ["Steller's sea cow"], ["barren cow"], ["cow heifer"], ["deep milking cow"], ["springer"], ["milch-cow"], ["milk cow"], ["candyfloss", "candy floss", "candy-floss", "cotton candy"], ["false grain"], ["sacred moose"], ["sugarcane"], ["icing"], ["sacred cow"]]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should return array with translations for 'samochód'" do
|
31
|
-
VCR.use_cassette('dictpl_samochod_cassette') do
|
32
|
-
d = Dict::Dictpl.new('samochód')
|
33
|
-
d.translate
|
34
|
-
d.translations.should be_a(Array)
|
35
|
-
d.translations.should == ["samochód", "samochód ciężarowy", "samochód ciężarowy; samochód skrzyniowy", "samochód cysterna (rodzaj pojazdu)", "samochód do przewozu wojska [wojsk]", "samochód dostawczy", "samochód dwudrzwiowy", "docierać samochód", "kasować samochód", "pojazd; samochód", "duży i tani samochód", "wypożyczony samochód", "uruchomić samochód", "krążownik szos; duży amerykański samochód", "zapalać samochód (zwłaszcza na pych)", "kabriolet; samochód bez dachu", "uruchomić samochód bez uzycia kluczyków (zwłaszcza, aby go ukraść)", "ciężarówka; samochód ciężarowy"]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should return array with examples for 'samochód'" do
|
40
|
-
VCR.use_cassette('dictpl_samochod_cassette') do
|
41
|
-
d = Dict::Dictpl.new('samochód')
|
42
|
-
d.translate
|
43
|
-
d.examples.should be_a(Array)
|
44
|
-
d.examples.should == [["car", "autocar", "automobile"], ["lorry"], ["truck"], ["gas tanker", "petrol tanker", "gasoline tanker"], ["troop-carrying vehicle"], ["van", "cargo plane"], ["two-door car"], ["break in"], ["write off"], ["automobile"], ["flivver"], ["u-drive"], ["put the car in gear"], ["yank-tank"], ["bump-start", "push-start"], ["no-top"], ["hot-wire"], ["lorry"]]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return a hash from array of paired values" do
|
49
|
-
VCR.use_cassette('dictpl_samochod_cassette') do
|
50
|
-
d = Dict::Dictpl.new('samochód')
|
51
|
-
d.make_hash_results(d.translate).should be_a(Hash)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|