cambridge_dict 0.2.3 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/cambridge_dict/version.rb +1 -1
- data/lib/cambridge_dict.rb +12 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b1a1cd7771bcdca2f9784cbcb7d68bb65d685e06b5387a9ac1c1090529339f0
|
4
|
+
data.tar.gz: fa35b9a0d9c7640b1a4f71c0e01ec0ab913a9781026e9ed4ecaecd2341aebefe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1fac189c809b80bb3938a29119efba3e834c4c9149caa4a8377ddee9eb1d6fbda8003bbd8c90434a85f7f632144113f7540774758374ff0a555a1925a19bf5
|
7
|
+
data.tar.gz: c338c5002025478c39951420698eee13cd2f4db41d28dd1cc9d90fafbb81c2cc04001935302c4d14033c0e1c3e56512c3b50a4695e15afdcb69eadc5557f157b
|
data/README.md
CHANGED
data/lib/cambridge_dict.rb
CHANGED
@@ -37,17 +37,23 @@ module CambridgeDict
|
|
37
37
|
encoded_word = PARSER.escape(word)
|
38
38
|
wiki_verbs = fetch_verbs("#{@wiki_base}/#{encoded_word}")
|
39
39
|
|
40
|
-
|
40
|
+
words = extract_word(doc)
|
41
41
|
|
42
|
-
return nil if
|
42
|
+
return nil if words.nil?
|
43
43
|
|
44
|
-
{
|
45
|
-
word:
|
44
|
+
resp = {
|
45
|
+
word: words&.last,
|
46
46
|
pos: extract_pos(doc),
|
47
47
|
verbs: wiki_verbs,
|
48
48
|
pronunciations: extract_pronunciation(doc),
|
49
49
|
definitions: extract_definitions(doc)
|
50
50
|
}
|
51
|
+
|
52
|
+
if words.size > 1
|
53
|
+
resp[:words] = words
|
54
|
+
end
|
55
|
+
|
56
|
+
resp
|
51
57
|
end
|
52
58
|
|
53
59
|
def lookup!(word, language: 'en')
|
@@ -86,7 +92,7 @@ module CambridgeDict
|
|
86
92
|
doc = Nokogiri::HTML(response.body)
|
87
93
|
verbs = []
|
88
94
|
|
89
|
-
rows = doc.css('tr > td > p')
|
95
|
+
rows = doc.css('table:not(.toccolours) tr > td > p')
|
90
96
|
|
91
97
|
lines = rows.map {|i| i.children.collect {|c| c.text } }.flatten.map(&:strip).reject(&:empty?)
|
92
98
|
|
@@ -99,7 +105,7 @@ module CambridgeDict
|
|
99
105
|
end
|
100
106
|
|
101
107
|
def extract_word(doc)
|
102
|
-
doc.at_css('.superentry .tb')&.text
|
108
|
+
doc.at_css('.superentry .tb')&.text&.split ", "
|
103
109
|
end
|
104
110
|
|
105
111
|
def extract_pos(doc)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cambridge_dict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben D'Angelo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|