Sha256: 289c2a814697e9d867688619886fc2303ec3a4b225f2eb2570d3e400f6d689fd

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 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, timeout: 9_000_000, open_timeout: 9_000_000, 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.6 lib/name-spotter/neti_neti_client.rb