name-spotter 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/name-spotter/taxon_finder_client.rb +7 -10
- data/name-spotter.gemspec +1 -1
- data/spec/name-spotter_spec.rb +6 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
@@ -14,7 +14,7 @@ class NameSpotter
|
|
14
14
|
@current_string = ''
|
15
15
|
@current_string_state = ''
|
16
16
|
@word_list_matches = 0
|
17
|
-
@cursor =
|
17
|
+
@cursor = 8.times.inject([]) { |res| res << ['',-1] }
|
18
18
|
@current_index = nil
|
19
19
|
words = str.split(/\s/)
|
20
20
|
words.each do |word|
|
@@ -44,15 +44,13 @@ class NameSpotter
|
|
44
44
|
if output = socket.gets
|
45
45
|
response = parse_socket_response(output)
|
46
46
|
return if not response
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
unless response.return_string_2.blank?
|
53
|
-
verbatim_string, scientific_string, start_position = process_response(response.return_string_2)
|
47
|
+
|
48
|
+
[response.return_string, response.return_string_2].each do |str|
|
49
|
+
next if !str || str.split(" ").size > 6
|
50
|
+
verbatim_string, scientific_string, start_position = process_response(str)
|
54
51
|
add_name NameSpotter::ScientificName.new(verbatim_string, :start_position => start_position, :scientific_name => scientific_string)
|
55
52
|
end
|
53
|
+
@current_index = nil
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
@@ -85,8 +83,7 @@ class NameSpotter
|
|
85
83
|
if @current_index
|
86
84
|
start_position = @current_index
|
87
85
|
words, indices = @cursor.transpose
|
88
|
-
verbatim_string = words[indices.index(start_position)...-1].join(" ")
|
89
|
-
@current_index = nil
|
86
|
+
verbatim_string = words[indices.index(start_position)...-1].join(" ") rescue (require 'ruby-debug'; debugger)
|
90
87
|
else
|
91
88
|
verbatim_string, start_position = @cursor[-1]
|
92
89
|
end
|
data/name-spotter.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "name-spotter"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Anthony Goddard", "Chuck Ha", "Dmitry Mozzherin"]
|
data/spec/name-spotter_spec.rb
CHANGED
@@ -100,4 +100,10 @@ describe "NameSpotter" do
|
|
100
100
|
res.should == {:names=>[{:verbatim=>"Ophloihrix nidis", :scientificName=>"Ophloihrix nidis", :offsetStart=>26, :offsetEnd=>41}]}
|
101
101
|
end
|
102
102
|
|
103
|
+
it "should not parse ridiculously long infraspecies names by taxon finder" do
|
104
|
+
text = "If we encounter Plantago major it is ok, but if it is Plantago quercus quercus quercus quercus quercus quercus quercus quercus quercus quercus quercus quercus quercus quercus, something is probably not right. However we take Plantago quercus quercus quercus quercus quercus by some strange reason. Well, the reason is this kind of thing -- Pardosa moesta var. moesta f. moesta or something like that"
|
105
|
+
res = @tf.find(text)
|
106
|
+
res.should == {:names=>[{:verbatim=>"Plantago major", :scientificName=>"Plantago major", :offsetStart=>16, :offsetEnd=>29}, {:verbatim=>"Plantago quercus quercus quercus quercus quercus", :scientificName=>"Plantago quercus quercus quercus quercus quercus", :offsetStart=>225, :offsetEnd=>272}, {:verbatim=>"Pardosa moesta var. moesta f. moesta", :scientificName=>"Pardosa moesta var. moesta f. moesta", :offsetStart=>340, :offsetEnd=>375}]}
|
107
|
+
end
|
108
|
+
|
103
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: name-spotter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -269,7 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
269
269
|
version: '0'
|
270
270
|
segments:
|
271
271
|
- 0
|
272
|
-
hash:
|
272
|
+
hash: 1111528646489484932
|
273
273
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
274
|
none: false
|
275
275
|
requirements:
|