Sha256: b91c8a640cd49cc8b4499f5ff2b46dd5ac0d2377a695dd166ffb8f86c3471a15
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
#!/usr/bin/env ruby require 'rubygems' gem 'dimus-biodiversity' rescue gem 'biodiversity' rescue nil $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) require 'biodiversity' require 'json' if ARGV.empty? puts "Usage:\n\nnnparse file_with_scientific_names [output_file]\n\ndefault output_file is parsed.json\n\n" exit end input = ARGV[0] output = ARGV[1] || 'parsed.json' ruby_min_version = RUBY_VERSION.split(".")[0..1].join('').to_i p = ScientificNameParser.new o = open(output, 'w') count = 0 puts 'Parsing...' IO.foreach(input) do |line| count += 1 puts("%s lines parsed" % count) if count % 10000 == 0 name = line.gsub(/^[\d]*\s*/, '').strip begin if ruby_min_version < 19 old_kcode = $KCODE $KCODE = 'NONE' end p.parse(name) parsed_data = p.parsed.all_json rescue {'parsed' => false, 'verbatim' => name, 'error' => 'Parser error'}.to_json if ruby_min_version < 19 $KCODE = old_kcode end rescue parsed_data = {'parsed' => false, 'verbatim' => name, 'error' => 'Parser error'}.to_json end o.write parsed_data + "\n" end
Version data entries
5 entries across 5 versions & 3 rubygems
Version | Path |
---|---|
dimus-biodiversity-0.5.13 | bin/nnparse |
dimus-biodiversity-0.5.14 | bin/nnparse |
biodiversity19-0.5.15 | bin/nnparse |
biodiversity-0.5.15 | bin/nnparse |
biodiversity-0.5.14 | bin/nnparse |