russian-reversal 1.0.5 → 1.0.6
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/lib/russian-reversal.rb +15 -12
- data/spec/reverse.rb +1 -0
- metadata +4 -4
data/lib/russian-reversal.rb
CHANGED
@@ -6,7 +6,7 @@ require 'nokogiri'
|
|
6
6
|
|
7
7
|
module RussianReversal
|
8
8
|
REGEXP_NONWORD = /[^a-zA-Z -]/
|
9
|
-
VERBS_IGNORED = [ 'be', '
|
9
|
+
VERBS_IGNORED = [ 'be', 'become', 'can', 'do', 'get', 'go', 'have', 'put', 'say', ]
|
10
10
|
NOUNS_IGNORED = [ 'it', 'him', 'her', 'them', 'me', 'you', 'us', 'this', 'that', 'these', 'those', ]
|
11
11
|
|
12
12
|
def self.strip( s )
|
@@ -14,20 +14,23 @@ module RussianReversal
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.infinitive_of( verb )
|
17
|
+
return if verb =~ REGEXP_NONWORD
|
18
|
+
|
17
19
|
doc = Nokogiri::HTML( open( "http://www.oxfordadvancedlearnersdictionary.com/dictionary/#{verb}" ) )
|
18
20
|
doc.search('div#relatedentries > ul > li').each do |e|
|
19
21
|
pos_element = e.at('span.pos')
|
20
|
-
if pos_element
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
next if pos_element.nil?
|
23
|
+
|
24
|
+
pos = pos_element.text.gsub( REGEXP_NONWORD, '' )
|
25
|
+
return if pos == 'modal verb' || pos == 'auxiliary verb'
|
26
|
+
|
27
|
+
next if pos != 'verb'
|
28
|
+
|
29
|
+
v = e.at('span').children.first.text.strip
|
30
|
+
if VERBS_IGNORED.include?( v )
|
31
|
+
return
|
32
|
+
else
|
33
|
+
return v
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
data/spec/reverse.rb
CHANGED
@@ -23,6 +23,7 @@ describe 'RussianReversal' do
|
|
23
23
|
RussianReversal.reverse( "He was a criminal." ).should.be.nil
|
24
24
|
RussianReversal.reverse( "He might be a criminal." ).should.be.nil
|
25
25
|
RussianReversal.reverse( "He ought to be good." ).should.be.nil
|
26
|
+
RussianReversal.reverse( "yeah, and it's horrible to install onigurama versions" ).should.be.nil
|
26
27
|
end
|
27
28
|
|
28
29
|
it "doesn't activate on pronouns or demonstratives" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: russian-reversal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pistos
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-19 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|