biodiversity19 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +34 -13
  2. data/VERSION +1 -1
  3. data/bin/parserver +5 -4
  4. metadata +1 -1
data/README.rdoc CHANGED
@@ -23,11 +23,31 @@ If you do not use ruby and need a fast access to the parser functionality you c
23
23
 
24
24
  parserver
25
25
 
26
- Then you can access it via 4334 port using a socket client library of your programming language. If you want to check if socket server works for you try:
27
-
26
+ options:
27
+
28
+ parserver --output=canonical
29
+
30
+ to return a canonical form of the name string
31
+
32
+ parserver --output=canonical_with_rank
33
+
34
+ the same as above, but infracpecies' rank is shown if available
35
+
36
+ praserver --port 5555
37
+
38
+ run socket server on a different port
39
+
40
+ Then you can access it via 4334 port using a socket client library of your programming language. You can find socket client script example in the examples directory of the gem.
41
+
42
+ If you want to check if socket server works for you:
43
+
44
+ #run server in one terminal
45
+ parserver
46
+
47
+ #in another terminal window type
28
48
  telnet localhost 4334
29
-
30
- If you enter a line with a scientific name server will send you back parsed information in json format.
49
+
50
+ If you enter a line with a scientific name server will send you back parsed information in json format.
31
51
 
32
52
  To stop telnet client type any of 'end','exit','q', '.' (without quotes) instead of scientific name
33
53
 
@@ -37,33 +57,34 @@ To stop telnet client type any of 'end','exit','q', '.' (without quotes) instead
37
57
  Escape character is '^]'.
38
58
  Acacia abyssinica Hochst. ex Benth. ssp. calophylla Brenan
39
59
  {"scientificName":{"canonical":"Acacia abyssinica calophylla","parsed":true,"parser_run":1,"verbatim":"Acacia abyssinica Hochst. ex Benth. ssp. calophylla Brenan\r\n","positions":{"0":["genus",6],"18":["author_word",25],"29":["author_word",35],"7":["species",17],"41":["infraspecies",51],"52":["author_word",58]},"hybrid":false,"normalized":"Acacia abyssinica Hochst. ex Benth. ssp. calophylla Brenan","details":[{"species":{"basionymAuthorTeam":{"exAuthorTeam":{"author":["Benth."],"authorTeam":"Benth."},"author":["Hochst."],"authorTeam":"Hochst."},"string":"abyssinica","authorship":"Hochst. ex Benth."},"infraspecies":[{"basionymAuthorTeam":{"author":["Brenan"],"authorTeam":"Brenan"},"string":"calophylla","rank":"ssp.","authorship":"Brenan"}],"genus":{"string":"Acacia"}}]}}
40
-
60
+
61
+
41
62
  === As a library
42
63
 
43
64
  You can use it as a library
44
65
 
45
66
  require 'biodiversity'
46
-
67
+
47
68
  parser = ScientificNameParser.new
48
-
69
+
49
70
  # to parse a scientific name into a ruby hash
50
71
  parser.parse("Plantago major")
51
-
72
+
52
73
  #to get json representation
53
74
  parser.parse("Plantago").to_json
54
75
  #or
55
76
  parser.parse("Plantago")
56
77
  parser.all_json
57
-
78
+
58
79
  # to clean name up
59
- parser.parse(" Plantago major ")[:scientificName][:normalized]
60
-
80
+ parser.parse(" Plantago major ")[:scientificName][:normalized]
81
+
61
82
  # to get only cleaned up latin part of the name
62
83
  parser.parse("Pseudocercospora dendrobii (H.C. Burnett) U. Braun & Crous 2003")[:scientificName][:canonical]
63
-
84
+
64
85
  # to get detailed information about elements of the name
65
86
  parser.parse("Pseudocercospora dendrobii (H.C. Burnett 1883) U. Braun & Crous 2003")[:scientificName][:details]
66
-
87
+
67
88
  # to resolve lsid and get back RDF file
68
89
  LsidResolver.resolve("urn:lsid:ubio.org:classificationbank:2232671")
69
90
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/bin/parserver CHANGED
@@ -11,6 +11,7 @@ OPTIONS = {
11
11
  :port => DEFAULT_PORT
12
12
  }
13
13
 
14
+ options = {}
14
15
  ARGV.options do |opts|
15
16
  script_name = File.basename($0)
16
17
  opts.banner = "Usage: ruby #{script_name} [options]"
@@ -22,13 +23,13 @@ ARGV.options do |opts|
22
23
  json - parsed results in json
23
24
  canonical - canonical version
24
25
  canonical_with_rank - canonical with rank",
25
- "Default: json") { |OPTIONS[:output]| }
26
+ "Default: json") { |output| options[:output] = output }
26
27
 
27
28
  opts.separator ""
28
29
 
29
30
  opts.on("-p", "--port=port", String,
30
31
  "Specifies the port number",
31
- "Default: #{DEFAULT_PORT}") { |OPTIONS[:port]| }
32
+ "Default: #{DEFAULT_PORT}") { |port| options[:port] = port }
32
33
 
33
34
  opts.separator ""
34
35
 
@@ -38,8 +39,8 @@ ARGV.options do |opts|
38
39
  opts.parse!
39
40
  end
40
41
 
41
- OPTIONS[:output] = "json" unless ['canonical', 'canonical_with_rank'].include?(OPTIONS[:output])
42
- OPTIONS[:port] = (OPTIONS[:port].to_i > 0 ? OPTIONS[:port].to_i : DEFAULT_PORT)
42
+ OPTIONS[:output] = options[:output] if ['canonical', 'canonical_with_rank'].include?(options[:output])
43
+ OPTIONS[:port] = options[:port].to_i if options[:port].to_i > 0
43
44
 
44
45
  def parser_error(name_string)
45
46
  {:scientificName => {:parsed => false, :verbatim => name_string, :error => 'Parser error'}}
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: biodiversity19
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dmitry Mozzherin