biodiversity19 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/Gemfile +4 -2
- data/Gemfile.lock +0 -2
- data/README.rdoc +5 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/biodiversity/parser.rb +7 -4
- data/spec/parser/scientific_name.spec.rb +9 -0
- metadata +19 -19
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use ruby-1.9.2-p290@biodiversity--create
|
1
|
+
rvm use ruby-1.9.2-p290@biodiversity --create
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -85,6 +85,11 @@ You can use it as a library
|
|
85
85
|
# to get detailed information about elements of the name
|
86
86
|
parser.parse("Pseudocercospora dendrobii (H.C. Burnett 1883) U. Braun & Crous 2003")[:scientificName][:details]
|
87
87
|
|
88
|
+
# to parse using several CPUs (4 seem to be optimal)
|
89
|
+
parser = ParallelParser.new # ParallelParser.new(4) will try to run 4 processes if hardware allows
|
90
|
+
array_of_names = ["Betula alba", "Homo sapiens"....]
|
91
|
+
parser.parse(array_of_names) # -> {"Betula alba" => "{scientificName...}", "Homo sapiens" => "{scientificName...}", ...}
|
92
|
+
|
88
93
|
# to resolve lsid and get back RDF file
|
89
94
|
LsidResolver.resolve("urn:lsid:ubio.org:classificationbank:2232671")
|
90
95
|
|
data/Rakefile
CHANGED
@@ -30,6 +30,7 @@ begin
|
|
30
30
|
gem.bindir = 'bin'
|
31
31
|
gem.executables = ['nnparse', 'parserver']
|
32
32
|
gem.add_dependency('treetop')
|
33
|
+
gem.add_dependency('parallel')
|
33
34
|
gem.add_dependency('json') if ruby_version < 19
|
34
35
|
gem.add_development_dependency "rspec"
|
35
36
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/lib/biodiversity/parser.rb
CHANGED
@@ -25,11 +25,14 @@ end
|
|
25
25
|
|
26
26
|
class ParallelParser
|
27
27
|
|
28
|
-
def initialize
|
29
|
-
require 'facter'
|
28
|
+
def initialize(processes_num = nil)
|
30
29
|
require 'parallel'
|
31
30
|
cpu_num
|
32
|
-
|
31
|
+
if processes_num.to_i > 0
|
32
|
+
@processes_num = [processes_num, cpu_num - 1].min
|
33
|
+
else
|
34
|
+
@processes_num = cpu_num > 3 ? cpu_num - 2 : 1
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
35
38
|
def parse(names_list)
|
@@ -38,7 +41,7 @@ class ParallelParser
|
|
38
41
|
end
|
39
42
|
|
40
43
|
def cpu_num
|
41
|
-
@cpu_num ||=
|
44
|
+
@cpu_num ||= Parallel.processor_count
|
42
45
|
end
|
43
46
|
|
44
47
|
private
|
@@ -61,4 +61,13 @@ describe ParallelParser do
|
|
61
61
|
res.keys.size.should == names.size
|
62
62
|
end
|
63
63
|
|
64
|
+
it "should parse several names in parallel with given num of processes" do
|
65
|
+
names = []
|
66
|
+
read_test_file { |n| names << (n[:name]) if n[:name] }
|
67
|
+
names.uniq!
|
68
|
+
pparser = ParallelParser.new(4)
|
69
|
+
res = pparser.parse(names)
|
70
|
+
names.size.should > 100
|
71
|
+
res.keys.size.should == names.size
|
72
|
+
end
|
64
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biodiversity19
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,8 +12,8 @@ cert_chain: []
|
|
12
12
|
date: 2011-11-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: treetop
|
16
|
+
requirement: &70293221558620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70293221558620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: parallel
|
27
|
+
requirement: &70293221558140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70293221558140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: jeweler
|
38
|
+
requirement: &70293221557660 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
|
-
type: :
|
44
|
+
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70293221557660
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: treetop
|
49
|
+
requirement: &70293221557180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70293221557180
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement: &
|
59
|
+
name: parallel
|
60
|
+
requirement: &70293221556700 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70293221556700
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70293221556220 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70293221556220
|
80
80
|
description: Tools for biodiversity informatics
|
81
81
|
email: dmozzherin@gmail.com
|
82
82
|
executables:
|