Skip to content

Instantly share code, notes, and snippets.

@dimus
Created January 6, 2012 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimus/1572502 to your computer and use it in GitHub Desktop.
Save dimus/1572502 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
require 'rest_client'
HOST = "localhost"
res = RestClient.get("http://#{HOST}:6384")
puts "GET request"
puts res
puts ""
text = 'नेति नेति - test for UTF-8 and ASCII characters... A new species of monitor lizard has been discovered by an international team of biologists in the Sierra Madres of the northern Philippines. The new specieshas been given a new scientific name -- Varanus bitatawa -- in recognition of its distinctiveness.
"We hope that by focusing on protection of this new V. bitatawa, conservation biologists and policy makers can work together to protect the remaining highly imperiled forests of northern Luzon," said Dr. Rafe Brown, leader of the team that discovered the new species and curator-in-charge of the Herpetology Division, University of Kansas Biodiversity Institute.
Adding another name: Betula alba. We want to be sure that in spite of multybyte characters offsets are shown correctly. Checking if it can expand V. provincialis into a name.'
res = RestClient.post("http://#{HOST}:6384", :data => text)
puts "POST request"
puts res
puts "Strings found according to the offsets: "
res = res.split("|")
res.each do |datum|
idx1, idx2 = datum.split(",")[-2..-1].map {|i| i.to_i}
puts text[idx1..idx2]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment