app/controllers/search_controller.rb
# if the first returned taxon has a score greater than 3, and
if the first returned taxon has a score greater than 3, and
if the first returned taxon has a score greater than 3 and
def pick_superior_result(all_results)
    minimum_score = 3
    superior_multiple = 4
    first_taxon = nil
    all_results.each do |r|
      break if first_taxon.nil? && r['score'] < minimum_score
      if first_taxon.nil? && r['resource_type'].include?('TaxonConcept') && r['score'] > minimum_score
        first_taxon = r
      elsif first_taxon && r['resource_type'].include?('TaxonConcept')
        if first_taxon['score'] > (r['score'] * superior_multiple)
          return first_taxon
        else
          first_taxon = nil
          break
        end
      end
    end
    first_taxon
  end
def pick_superior_result ( all_results ) minimum_score = 3 superior_multiple = 4 first_taxon = nil all_results . each do | r | break if first_taxon . nil? && r [ 'score' ] < minimum_score if first_taxon . nil? && r [ 'resource_type' ] . include? ( 'TaxonConcept' ) && r [ 'score' ] > minimum_score first_taxon = r elsif first_taxon && r [ 'resource_type' ] . include? ( 'TaxonConcept' ) if first_taxon [ 'score' ] > ( r [ 'score' ] * superior_multiple ) return first_taxon else first_taxon = nil break end end end first_taxon end
if the first returned taxon has a score greater than 3, and
if the first returned taxon has a score greater than 3 and
# the second taxon isn't far worse than the first, so break
all_results
<not_specific>