Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
Annona squamosa and Brownea ariza should now work. #221
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrasca committed Dec 24, 2015
1 parent a176235 commit 4b40dd2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bauble/plugins/plants/ask_tpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,15 @@ class NoResult(Exception):
if self.stopped():
raise ShouldStopNow('after first query')
if len(candidates) > 1:
l = []
for item in candidates:
g, s = item['Genus'], item['Species']
seq = difflib.SequenceMatcher(a=self.binomial,
b='%s %s' % (g, s))
l.append((seq.ratio(), item))
item['_score_'] = seq.ratio()

score, found = sorted(l)[-1]
if score < self.threshold:
score = 0
found = sorted(candidates, cmp=lambda a, b: cmp(a['_score_'], b['_score_']) or cmp(b['Taxonomic status in TPL'], a['Taxonomic status in TPL']))[-1]
if found['_score_'] < self.threshold:
found['_score_'] = 0
elif candidates:
found = candidates.pop()
else:
Expand Down Expand Up @@ -129,9 +128,10 @@ class NoResult(Exception):


def citation(d):
return "%(Genus hybrid marker)s%(Genus)s "\
"%(Species hybrid marker)s%(Species)s "\
"%(Authorship)s (%(Family)s)" % d
return ("%(Genus hybrid marker)s%(Genus)s "
"%(Species hybrid marker)s%(Species)s "
#"%(Infraspecific rank)s %(Infraspecific epithet)s "
"%(Authorship)s (%(Family)s)" % d).replace(' ', ' ')


def what_to_do_with_it(found, accepted):
Expand Down

0 comments on commit 4b40dd2

Please sign in to comment.