Sha256: bffc724aaaba59404fde62b4ce77e30e92fd587d322e795b9f5c3363c1a3aa47

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

class NameSpotter
  class NetiNetiClient < Client
    def initialize(opts = { host: '0.0.0.0', port: 6384 })
      super 
    end

    def find(text)
      # the form does not get sent if text is nil or empty
      return [] if text.nil? || text.empty?
      response = RestClient.post("http://#{@host}:#{@port}", data: text, headers: {Connection: "Keep-Alive"})
      response.body.split("|").collect do |info|
        res = info.split(",")
        name = res[0...-2].join(",")
        offset_start = res[-2]
        name.force_encoding('utf-8')
        normalized_name = NameSpotter::ScientificName.normalize(name)
        NameSpotter::ScientificName.new(name, :scientific_name => normalized_name, :start_position => offset_start.to_i)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
name-spotter-0.1.3 lib/name-spotter/neti_neti_client.rb