taxamatch_rb 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/taxamatch_rb.rb +2 -2
- data/spec/taxamatch_rb_spec.rb +6 -1
- metadata +2 -2
data/lib/taxamatch_rb.rb
CHANGED
@@ -25,14 +25,14 @@ module Taxamatch
|
|
25
25
|
def taxamatch(str1, str2, return_boolean = true)
|
26
26
|
preparsed_1 = @parser.parse(str1)
|
27
27
|
preparsed_2 = @parser.parse(str2)
|
28
|
-
match = taxamatch_preparsed(preparsed_1, preparsed_2) rescue
|
28
|
+
match = taxamatch_preparsed(preparsed_1, preparsed_2) rescue false
|
29
29
|
return_boolean && match ? match['match'] : match
|
30
30
|
end
|
31
31
|
|
32
32
|
#takes two hashes of parsed scientific names, analyses them and returns back
|
33
33
|
#this function is useful when species strings are preparsed.
|
34
34
|
def taxamatch_preparsed(preparsed_1, preparsed_2)
|
35
|
-
result =
|
35
|
+
result = false
|
36
36
|
result = match_uninomial(preparsed_1, preparsed_2) if preparsed_1[:uninomial] && preparsed_2[:uninomial]
|
37
37
|
result = match_multinomial(preparsed_1, preparsed_2) if preparsed_1[:genus] && preparsed_2[:genus]
|
38
38
|
if result && result['match']
|
data/spec/taxamatch_rb_spec.rb
CHANGED
@@ -149,7 +149,7 @@ describe 'Taxamatch::Base' do
|
|
149
149
|
@tm.match_species(s1, s2).should == {'phonetic_match' => false, 'match' => false, 'edit_distance' => 3}
|
150
150
|
end
|
151
151
|
|
152
|
-
it 'should match
|
152
|
+
it 'should match matches' do
|
153
153
|
#No trobule case
|
154
154
|
gmatch = {'match' => true, 'phonetic_match' => true, 'edit_distance' => 1}
|
155
155
|
smatch = {'match' => true, 'phonetic_match' => true, 'edit_distance' => 1}
|
@@ -178,6 +178,11 @@ describe 'Taxamatch::Base' do
|
|
178
178
|
@tm.match_matches(gmatch, smatch).should == {'phonetic_match'=>true, 'edit_distance'=>4, 'match'=>true}
|
179
179
|
end
|
180
180
|
|
181
|
+
it 'should return only boolean values' do
|
182
|
+
@tm.taxamatch("AJLJljljlj", "sls").should_not be_nil
|
183
|
+
end
|
184
|
+
|
185
|
+
|
181
186
|
describe 'Taxamatch::Authmatch' do
|
182
187
|
before(:all) do
|
183
188
|
@am = Taxamatch::Authmatch
|