oba-client 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.md CHANGED
@@ -29,4 +29,8 @@
29
29
 
30
30
  ## 1.1.1 / 2010-07-08
31
31
 
32
- * Rake or Hoe bug workaround.
32
+ * Rake or Hoe bug workaround.
33
+
34
+ ## 1.2.0 / 2010-07-08
35
+
36
+ * Parse statistics.
data/README.md CHANGED
@@ -31,6 +31,10 @@ See [the Annotator documentation](http://www.bioontology.org/wiki/index.php/Anno
31
31
  # :annotations => [Array of annotations of text],
32
32
  # :ontologies => [Array of ontologies used]}
33
33
  client2.execute("another text string, maybe longer this time.")
34
+ client2.execute("this is the second query for this client!")
35
+
36
+ # Or, parse some file you've already got lying about (pass as a string).
37
+ parsed = OBAClient::parse("<?xml ... ")
34
38
 
35
39
  ## LICENSE:
36
40
 
data/lib/oba_client.rb CHANGED
@@ -5,7 +5,7 @@ require "net/http"
5
5
  require "uri"
6
6
 
7
7
  class OBAClient
8
- VERSION = "1.1.1"
8
+ VERSION = "1.2.0"
9
9
 
10
10
  # A high HTTP read timeout, as the service sometimes takes awhile to respond.
11
11
  DEFAULT_TIMEOUT = 30
@@ -37,6 +37,10 @@ class OBAClient
37
37
  :withDefaultStopWords,
38
38
  :withSynonyms,
39
39
  ]
40
+
41
+ STATISTICS_BEANS_XPATH = "/success/data/annotatorResultBean/statistics/statisticsBean"
42
+ ANNOTATION_BEANS_XPATH = "/success/data/annotatorResultBean/annotations/annotationBean"
43
+ ONTOLOGY_BEANS_XPATH = "/success/data/annotatorResultBean/ontologies/ontologyUsedBean"
40
44
 
41
45
  # Instantiate the class with a set of reused options. Options used by the
42
46
  # method are:
@@ -115,7 +119,11 @@ class OBAClient
115
119
  ontologies = []
116
120
  doc = Nokogiri::XML.parse(xml)
117
121
 
118
- doc.xpath("//annotationBean").each do |ann|
122
+ doc.xpath(STATISTICS_BEANS_XPATH).each do |sb|
123
+ statistics[sb.xpath("mapping").text] = sb.xpath("nbAnnotation").text.to_i
124
+ end
125
+
126
+ doc.xpath(ANNOTATION_BEANS_XPATH).each do |ann|
119
127
  parsed = {
120
128
  :score => ann.xpath("score").text.to_i,
121
129
  :id => ann.xpath("concept/id").text.to_i,
@@ -144,7 +152,7 @@ class OBAClient
144
152
  annotations << parsed
145
153
  end
146
154
 
147
- doc.xpath("//ontologyUsedBean").each do |ontology|
155
+ doc.xpath(ONTOLOGY_BEANS_XPATH).each do |ontology|
148
156
  parsed = {}
149
157
  parsed[:localOntologyId] = ontology.xpath("localOntologyId").text.to_i
150
158
  parsed[:virtualOntologyId] = ontology.xpath("virtualOntologyId").text.to_i
@@ -67,7 +67,6 @@ class TestOBAClient < Test::Unit::TestCase
67
67
  assert parsed[:statistics].is_a?(Hash)
68
68
  assert parsed[:annotations].is_a?(Array)
69
69
  assert parsed[:ontologies].is_a?(Array)
70
- p parsed[:annotations].first
71
70
  end
72
71
  end
73
72
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oba-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
8
+ - 2
9
+ - 0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rob Tirrell