wlapi 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
1
  == COMPLETED
2
+ === 0.8.0
3
+ WLAPI depends on Savon <tt>>=0.8.0</tt>
4
+ with all interface changes have been implemented.
5
+
2
6
  === 0.7.4
3
7
  Small fixes in the project infrastructure and test refactoring.
4
8
  === 0.7.3
@@ -9,8 +13,12 @@ Initial release of the lib.
9
13
 
10
14
 
11
15
  == PLANNED
12
- === 0.8.0
13
- Reimplement the lib using the latest version of savon.
16
+ === 0.8.1
17
+ Refactore all test and implement server response stubs with +fakeweb+.
18
+ === 0.8.2
19
+ Introduce +nokogiri+ for parsing responses.
20
+ === 0.8.3
21
+ Implement an error handling strategy.
14
22
  === 0.9.0
15
23
  === 1.0.0
16
24
 
data/README CHANGED
@@ -5,25 +5,79 @@
5
5
  * {WLAPI Project Page}[http://wlapi.rubyforge.org/]
6
6
 
7
7
  == DESCRIPTION
8
+ WLAPI is a programmatic API for web services provided by the project
9
+ {Wortschatz}[http://wortschatz.uni-leipzig.de/],
10
+ University of Leipzig. These services are a great source of linguistic knowledge
11
+ for morphological, syntactic and semantic analysis of German both for traditional
12
+ and Computational Linguistics (CL).
8
13
 
9
- WLAPI is a simple API for Wortschatz Leipzig project.
14
+ Use this API to gain data on word frequencies, left and right neighbours,
15
+ collocations and semantic similarity. Check it out if you are interested
16
+ in Natural Language Processing (NLP) and Human Language Technology (HLT).
17
+ === Implemented Features
18
+ You can use the following search methods:
19
+ * baseform;
20
+ * cooccurrences;
21
+ * cooccurrences_all;
22
+ * domain;
23
+ * experimental_synonyms;
24
+ * frequencies;
25
+ * intersection;
26
+ * left_collocation_finder;
27
+ * left_neighbours;
28
+ * right_collocation_finder;
29
+ * right_neighbours;
30
+ * sentences;
31
+ * similarity;
32
+ * synonyms;
33
+ * thesaurus;
34
+ * wordforms.
10
35
 
11
36
  == INSTALLATION
37
+ WLAPI is provided as a .gem package. Simply install it via
38
+ {RubyGems}[http://rubygems.org/gems/wlapi].
39
+ To install WLAPI ussue the following command:
40
+ $ gem install wlapi
41
+
42
+ You might want to install versions prior to +0.8.0+, if you are bound on
43
+ the old implementations of {savon}[http://savonrb.com/]:
44
+ $ gem install wlapi -v 0.7.4
45
+
46
+ If you want to do a system wide installation, do this as root
47
+ (possibly using +sudo+).
48
+
49
+ Alternatively use your Gemfile for dependency management.
12
50
 
13
- WLAPI is provided as a .gem package. Simply install it via RubyGems.
14
51
 
15
52
  == SYNOPSIS
53
+
54
+ Basic usage is very simple:
16
55
  $ require 'wlapi'
17
56
  $ api = WLAPI::API.new
18
57
  $ api.synonyms('Haus', 15) # returns an array with string values (UTF8 encoded)
19
- $ api.domain('Auto') # returns an array with strings
58
+ $ api.domain('Auto') # => Array
20
59
 
21
- See documentation in the WLAPI::API class for details on particular methods.
60
+ If you are going to send mass requests, please contact the support team
61
+ of the project {Wortschatz}[http://wortschatz.uni-leipzig.de/], get your private
62
+ credentials and instantiate an authenticated client:
63
+ $ require 'wlapi'
64
+ $ api = WLAPI::API.new(username, password)
65
+
66
+ See documentation in the WLAPI::API class for details
67
+ on particular search methods.
22
68
 
23
69
  == SUPPORT
70
+ If you have question, bug reports or any suggestions, please drop me an email :)
71
+ Any help is deeply appreciated!
72
+
73
+ == CHANGELOG
74
+ For details on future plan and working progress see CHANGELOG.
24
75
 
25
- If you have question, bug reports or any suggestions, please drop me an email :) Any help is deeply appreciated!
76
+ == CAUTION
77
+ This library is <b>work in process</b>! Though the interface is mostly complete,
78
+ you might face some not implemented features.
26
79
 
80
+ Please contact me with your suggestions, bug reports and feature requests.
27
81
  == LICENSE
28
82
 
29
83
  WLAPI is a copyrighted software by Andrei Beliankou, 2010, 2011
@@ -4,14 +4,8 @@
4
4
  # :title: Ruby based API for Wortschatz Leipzig web services
5
5
  # :main: README
6
6
 
7
- begin
8
- gem('savon', '0.7.9')
9
- require 'savon'
10
- rescue NoMethodError, LoadError
11
- require 'rubygems'
12
- retry
13
- end
14
-
7
+ require 'savon'
8
+
15
9
  # REXML is fast enough for our task.
16
10
  require 'rexml/document'
17
11
  include REXML
@@ -33,22 +27,22 @@ module WLAPI
33
27
  # This hash contains the URLs to the single services.
34
28
  endpoint = 'http://wortschatz.uni-leipzig.de/axis/services'
35
29
  @services = {
36
- 'Thesaurus' => "#{endpoint}/Thesaurus",
37
- 'Baseform' => "#{endpoint}/Baseform",
38
- 'Similarity' => "#{endpoint}/Similarity",
39
- 'Synonyms' => "#{endpoint}/Synonyms",
40
- 'Sachgebiet' => "#{endpoint}/Sachgebiet",
41
- 'Frequencies' => "#{endpoint}/Frequencies",
42
- 'Kookurrenzschnitt' => "#{endpoint}/Kookkurrenzschnitt",
43
- 'ExperimentalSynonyms' => "#{endpoint}/ExperimentalSynonyms",
44
- 'RightCollocationFinder' => "#{endpoint}/RightCollocationFinder",
45
- 'LeftCollocationFinder' => "#{endpoint}/LeftCollocationFinder",
46
- 'Wordforms' => "#{endpoint}/Wordforms",
47
- 'CooccurrencesAll' => "#{endpoint}/CooccurrencesAll",
48
- 'LeftNeighbours' => "#{endpoint}/LeftNeighbours",
49
- 'RightNeighbours' => "#{endpoint}/RightNeighbours",
50
- 'Sentences' => "#{endpoint}/Sentences",
51
- 'Cooccurrences' => "#{endpoint}/Cooccurrences"
30
+ :Thesaurus => "#{endpoint}/Thesaurus",
31
+ :Baseform => "#{endpoint}/Baseform",
32
+ :Similarity => "#{endpoint}/Similarity",
33
+ :Synonyms => "#{endpoint}/Synonyms",
34
+ :Sachgebiet => "#{endpoint}/Sachgebiet",
35
+ :Frequencies => "#{endpoint}/Frequencies",
36
+ :Kookurrenzschnitt => "#{endpoint}/Kookkurrenzschnitt",
37
+ :ExperimentalSynonyms => "#{endpoint}/ExperimentalSynonyms",
38
+ :RightCollocationFinder => "#{endpoint}/RightCollocationFinder",
39
+ :LeftCollocationFinder => "#{endpoint}/LeftCollocationFinder",
40
+ :Wordforms => "#{endpoint}/Wordforms",
41
+ :CooccurrencesAll => "#{endpoint}/CooccurrencesAll",
42
+ :LeftNeighbours => "#{endpoint}/LeftNeighbours",
43
+ :RightNeighbours => "#{endpoint}/RightNeighbours",
44
+ :Sentences => "#{endpoint}/Sentences",
45
+ :Cooccurrences => "#{endpoint}/Cooccurrences"
52
46
  # no MARSService and Kreuzwortrraetsel
53
47
  }
54
48
 
@@ -58,13 +52,17 @@ module WLAPI
58
52
  # we should investigate the typical user behaviour.
59
53
  # If only one service is used in the separate session => rewrite the class!
60
54
  @services.each do |key, val|
61
- cl_name = '@cl_' + key
62
- eval("#{cl_name} = Savon::Client.new(val)")
63
- eval("#{cl_name}.request.basic_auth(login, pass)")
55
+ cl_name = '@cl_' + key.to_s
56
+ eval("#{cl_name} = Savon::Client.new { |wsdl| wsdl.endpoint = val}")
57
+ eval("#{cl_name}.wsdl.namespace = val")
58
+ eval("#{cl_name}.http.auth.basic(login, pass)")
64
59
  end
65
60
 
66
61
  # Savon creates very verbose logs, switching off.
67
- Savon::Request.log = false unless $DEBUG
62
+ Savon.configure do |config|
63
+ config.log = false unless $DEBUG
64
+ end
65
+ HTTPI.log = false unless $DEBUG
68
66
  end
69
67
 
70
68
  # Main methods to access different services.
@@ -72,11 +70,11 @@ module WLAPI
72
70
  # You can define the limit for the result set, it defaults to 10.
73
71
  # If you want to get all the results, you should provide a number,
74
72
  # which would be greater than the result set since we cannot
75
- # predict how many answers the server will give us. Just try it.
76
- ##############################################################################
73
+ # predict how many answers the server will give us.
74
+ #############################################################################
77
75
 
78
76
  ## One parameter methods.
79
- ##############################################################################
77
+ #############################################################################
80
78
 
81
79
  # Returns the frequency and frequency class of the input word.
82
80
  # Frequency class is computed in relation to the most frequent word
@@ -84,8 +82,9 @@ module WLAPI
84
82
  # api.frequencies("Autos") => ["40614", "9"]
85
83
  def frequencies(word)
86
84
  arg1 = ['Wort', word]
87
- answer = query(@cl_Frequencies, @services['Frequencies'], arg1)
88
- return get_answer(answer)
85
+ answer = query(@cl_Frequencies, arg1)
86
+
87
+ get_answer(answer)
89
88
  end
90
89
 
91
90
  # Gets the baseform (whatever it is :) not lemma).
@@ -94,8 +93,9 @@ module WLAPI
94
93
  # api.baseform("Auto") => ["Auto", "N"]
95
94
  def baseform(word)
96
95
  arg1 = ['Wort', word]
97
- answer = query(@cl_Baseform, @services['Baseform'], arg1)
98
- return get_answer(answer)
96
+ answer = query(@cl_Baseform, arg1)
97
+
98
+ get_answer(answer)
99
99
  end
100
100
 
101
101
  # Returns categories for a given input word as an array:
@@ -105,12 +105,13 @@ module WLAPI
105
105
  # let's call it domain, not sachgebiet
106
106
  def domain(word)
107
107
  arg1 = ['Wort', word]
108
- answer = query(@cl_Sachgebiet, @services['Sachgebiet'], arg1)
109
- return get_answer(answer)
108
+ answer = query(@cl_Sachgebiet, arg1)
109
+
110
+ get_answer(answer)
110
111
  end
111
112
 
112
113
  ## Two parameter methods.
113
- ##############################################################################
114
+ #############################################################################
114
115
 
115
116
  # Returns all other word forms of the same lemma for a given word form.
116
117
  # api.wordforms("Auto") => ["Auto", "Autos"]
@@ -118,8 +119,9 @@ module WLAPI
118
119
  # note, it is the only service which requires 'Word', not 'Wort'
119
120
  arg1 = ['Word', word]
120
121
  arg2 = ['Limit', limit]
121
- answer = query(@cl_Wordforms, @services['Wordforms'], arg1, arg2)
122
- return get_answer(answer)
122
+ answer = query(@cl_Wordforms, arg1, arg2)
123
+
124
+ get_answer(answer)
123
125
  end
124
126
 
125
127
  # As the Synonyms service returns synonyms of the given input word.
@@ -129,8 +131,9 @@ module WLAPI
129
131
  def thesaurus(word, limit = 10)
130
132
  arg1 = ['Wort', word]
131
133
  arg2 = ['Limit', limit]
132
- answer = query(@cl_Thesaurus, @services['Thesaurus'], arg1, arg2)
133
- return get_answer(answer)
134
+ answer = query(@cl_Thesaurus, arg1, arg2)
135
+
136
+ get_answer(answer)
134
137
  end
135
138
 
136
139
  # This method searches for synonyms.
@@ -139,14 +142,16 @@ module WLAPI
139
142
  def synonyms(word, limit = 10)
140
143
  arg1 = ['Wort', word]
141
144
  arg2 = ['Limit', limit]
142
- answer = query(@cl_Synonyms, @services['Synonyms'], arg1, arg2)
145
+ answer = query(@cl_Synonyms, arg1, arg2)
146
+
143
147
  # Synonym service provides multiple values, so we take only odd.
144
- return get_answer(answer, '[position() mod 2 = 1 ]')
148
+ get_answer(answer, '[position() mod 2 = 1 ]')
145
149
  end
146
150
 
147
151
  # Returns sample sentences containing the input word.
148
152
  # The return value is an array:
149
- # api.sentences("Auto") => ["40808144", "Zweitens der freche, frische Klang der Hupe
153
+ # api.sentences("Auto") => ["40808144", "Zweitens der freche,
154
+ # frische Klang der Hupe
150
155
  # und drittens die hinreißend gestylten 16-Zoll-Felgen,
151
156
  # die es leider nur für dieses Auto gibt.", ...]
152
157
  #--
@@ -154,8 +159,9 @@ module WLAPI
154
159
  def sentences(word, limit = 10)
155
160
  arg1 = ['Wort', word]
156
161
  arg2 = ['Limit', limit]
157
- answer = query(@cl_Sentences, @services['Sentences'], arg1, arg2)
158
- return get_answer(answer)
162
+ answer = query(@cl_Sentences, arg1, arg2)
163
+
164
+ get_answer(answer)
159
165
  end
160
166
 
161
167
  # For a given input word, returns statistically significant left neighbours
@@ -166,8 +172,9 @@ module WLAPI
166
172
  def left_neighbours(word, limit = 10)
167
173
  arg1 = ['Wort', word]
168
174
  arg2 = ['Limit', limit]
169
- answer = query(@cl_LeftNeighbours, @services['LeftNeighbours'], arg1, arg2)
170
- return get_answer(answer)
175
+ answer = query(@cl_LeftNeighbours, arg1, arg2)
176
+
177
+ get_answer(answer)
171
178
  end
172
179
 
173
180
  # For a given input word, returns statistically significant right neighbours
@@ -178,12 +185,14 @@ module WLAPI
178
185
  def right_neighbours(word, limit = 10)
179
186
  arg1 = ['Wort', word]
180
187
  arg2 = ['Limit', limit]
181
- answer = query(@cl_RightNeighbours, @services['RightNeighbours'], arg1, arg2)
182
- return get_answer(answer)
188
+ answer = query(@cl_RightNeighbours, arg1, arg2)
189
+
190
+ get_answer(answer)
183
191
  end
184
192
 
185
193
 
186
- # Returns automatically computed contextually similar words of the input word.
194
+ # Returns automatically computed contextually similar words
195
+ # of the input word.
187
196
  # Such similar words may be antonyms, hyperonyms, synonyms,
188
197
  # cohyponyms or other.
189
198
  # Note that due to the huge amount of data any query to this services
@@ -192,8 +201,9 @@ module WLAPI
192
201
  def similarity(word, limit = 10)
193
202
  arg1 = ['Wort', word]
194
203
  arg2 = ['Limit', limit]
195
- answer = query(@cl_Similarity, @services['Similarity'], arg1, arg2)
196
- return get_answer(answer)
204
+ answer = query(@cl_Similarity, arg1, arg2)
205
+
206
+ get_answer(answer)
197
207
  end
198
208
 
199
209
  # This service delivers an experimental synonyms request for internal tests.
@@ -202,12 +212,13 @@ module WLAPI
202
212
  def experimental_synonyms(word, limit = 10)
203
213
  arg1 = ['Wort', word]
204
214
  arg2 = ['Limit', limit]
205
- answer = query(@cl_ExperimentalSynonyms, @services['ExperimentalSynonyms'], arg1, arg2)
206
- return get_answer(answer)
215
+ answer = query(@cl_ExperimentalSynonyms, arg1, arg2)
216
+
217
+ get_answer(answer)
207
218
  end
208
219
 
209
220
  ## Three parameter methods.
210
- ##############################################################################
221
+ #############################################################################
211
222
 
212
223
  # Attempts to find linguistic collocations that occur to the right
213
224
  # of the given input word.
@@ -215,13 +226,15 @@ module WLAPI
215
226
  # which stand for adjective, verb, noun and stopword respectively.
216
227
  # The parameter restricts the type of words found.
217
228
  # It returns an array:
218
- # api.right_collocation_finder("Auto", "V", 10) => ["Auto", "abfackeln", "V", ...]
229
+ # api.right_collocation_finder("Auto", "V", 10) =>
230
+ # ["Auto", "abfackeln", "V", ...]
219
231
  def right_collocation_finder(word, pos, limit = 10)
220
232
  arg1 = ['Wort', word]
221
233
  arg2 = ['Wortart', pos]
222
234
  arg3 = ['Limit', limit]
223
- answer = query(@cl_RightCollocationFinder, @services['RightCollocationFinder'], arg1, arg2, arg3)
224
- return get_answer(answer)
235
+ answer = query(@cl_RightCollocationFinder, arg1, arg2, arg3)
236
+
237
+ get_answer(answer)
225
238
  end
226
239
 
227
240
  # Attempts to find linguistic collocations that occur to the left
@@ -230,14 +243,15 @@ module WLAPI
230
243
  # which stand for adjective, verb, noun and stopword respectively.
231
244
  # The parameter restricts the type of words found.
232
245
  # It returns an array:
233
- # api.left_collocation_finder("Stuhl", "A", 10) => ["apostolisch", "A", "Stuhl", ...]
246
+ # api.left_collocation_finder("Stuhl", "A", 10) =>
247
+ # ["apostolisch", "A", "Stuhl", ...]
234
248
  def left_collocation_finder(word, pos, limit = 10)
235
249
  arg1 = ['Wort', word]
236
250
  arg2 = ['Wortart', pos]
237
251
  arg3 = ['Limit', limit]
238
- answer = query(@cl_LeftCollocationFinder,
239
- @services['LeftCollocationFinder'], arg1, arg2, arg3)
240
- return get_answer(answer)
252
+ answer = query(@cl_LeftCollocationFinder, arg1, arg2, arg3)
253
+
254
+ get_answer(answer)
241
255
  end
242
256
 
243
257
  # Returns statistically significant co-occurrences of the input word.
@@ -277,83 +291,73 @@ module WLAPI
277
291
  private
278
292
 
279
293
  # Main query method, it invokes the soap engine.
280
- # This method combines all the data to one SOAP request and gets the answer.
281
- # It is not compatible with one and three parameter methods yet.
282
- # args contains an array [[key1, value1], [key2, value2], [key3, value3]]
283
- # with keys and values for the soap query
284
- def query(cl, namespace, *args)
285
-
286
- # Calling the action with ! (disables the wsdl query).
287
- # wsdl is disabled since calling the server for wsdl can last too long.
288
- resp = cl.execute! do |soap|
289
-
290
- # adding a namespace, wsdl is disabled
291
- soap.namespace = namespace
292
-
293
- soap.namespaces['xmlns:soapenv'] = "http://schemas.xmlsoap.org/soap/envelope/"
294
+ # It combines all the data to one SOAP request and gets the answer.
295
+ # <args> contains an array [[key1, value1], [key2, value2], [key3, value3]]
296
+ # with keys and values for the soap query.
297
+ def query(cl, *args)
298
+ # WSDL is disabled since calling the server for wsdl can last too long.
299
+ resp = cl.request(:urn, :execute) do |soap|
294
300
 
295
301
  # Every service has a different namespace.
296
- soap.namespaces['xmlns:urn'] = "urn:#{namespace.sub(/.+ces\//, '')}"
297
-
298
- soap.namespaces['xmlns:dat'] = "http://datatypes.webservice.wortschatz.uni_leipzig.de"
302
+ soap.namespaces['xmlns:urn'] = cl.wsdl.namespace
299
303
 
304
+ soap.namespaces['xmlns:dat'] =
305
+ "http://datatypes.webservice.wortschatz.uni_leipzig.de"
300
306
 
301
- body = "<urn:objRequestParameters>"
302
- body << "<urn:corpus>de</urn:corpus>"
303
- body << "<urn:parameters>"
307
+ v = []
308
+ body = {
309
+ 'urn:objRequestParameters' => {
310
+ 'urn:corpus' => 'de',
311
+ 'urn:parameters' => {
312
+ 'urn:dataVectors' => v
313
+ }
314
+ }
315
+ }
304
316
 
305
- # setting the first argument (usually 'Wort')
306
- if args[0]
307
- body << "<urn:dataVectors><dat:dataRow>#{args[0][0]}</dat:dataRow><dat:dataRow>#{args[0][1]}</dat:dataRow></urn:dataVectors>"
308
- end
317
+ # Setting the first argument (usually 'Wort').
318
+ v << {'dat:dataRow'=>[
319
+ args[0][0],
320
+ args[0][1]
321
+ ]
322
+ } if args[0]
323
+ # Setting the second argument (usually 'Limit').
324
+ v << {'dat:dataRow'=>[
325
+ args[1][0],
326
+ args[1][1]
327
+ ]
328
+ } if args[1]
329
+ # Setting the third argument (no common value)
330
+ v << {'dat:dataRow'=>[
331
+ args[2][0],
332
+ args[2][1]
333
+ ]
334
+ } if args[2]
309
335
 
310
- # setting the second argument (usually 'Limit')
311
- if args[1]
312
- body << "<urn:dataVectors><dat:dataRow>#{args[1][0]}</dat:dataRow><dat:dataRow>#{args[1][1]}</dat:dataRow></urn:dataVectors>"
313
- end
314
-
315
- # setting setting the third argument (no common value)
316
- if args[2]
317
- body << "<urn:dataVectors><dat:dataRow>#{args[2][0]}</dat:dataRow><dat:dataRow>#{args[2][1]}</dat:dataRow></urn:dataVectors>"
318
- end
319
- body << "</urn:parameters>"
320
- body << "</urn:objRequestParameters>"
321
-
322
336
  soap.body = body
323
-
324
-
325
-
326
- STDERR.puts soap.to_xml if $DEBUG
337
+ warn(soap.to_xml) if $DEBUG
327
338
 
328
339
  end
329
340
 
330
341
  doc = Document.new(resp.to_xml)
342
+ warn(doc) if $DEBUG
331
343
 
332
- STDERR.puts doc if $DEBUG
333
-
334
- return doc
335
-
344
+ doc
336
345
  end
337
346
 
338
347
  # This method extracts valuable data from the XML structure
339
348
  # of the soap response. It returns an array with extracted xml text nodes
340
349
  # or nil, if the service provided no answer.
341
- # The same collection is printed to stderr in the DEBUG mode.
342
- #--
343
- # TODO: what if the answer is empty?
344
350
  def get_answer(doc, mod='')
345
351
  result = []
346
352
  # The path seems to be weird, because the namespaces change incrementally
347
353
  # in the output, so I don't want to treat it here.
348
354
  # A modifier needed because synonyms service provides duplicate values.
349
- XPath.each(doc, "//result/*/*#{mod}") {|el| STDERR.puts el.text} if $DEBUG
350
- XPath.each(doc, "//result/*/*#{mod}") {|el| result << el.text}
351
-
352
- if result.empty?
353
- return nil
355
+ XPath.each(doc, "//result/*/*#{mod}") do |el|
356
+ warn(el.text) if $DEBUG
357
+ result << el.text
354
358
  end
355
-
356
- return result
359
+
360
+ result.any? ? result : nil
357
361
  end
358
362
 
359
363
  end # class
@@ -1,3 +1,3 @@
1
1
  module WLAPI
2
- VERSION = '0.7.4'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dat="http://datatypes.webservice.wortschatz.uni_leipzig.de" xmlns:urn="http://wortschatz.uni-leipzig.de/axis/services/Thesaurus" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><urn:execute><urn:objRequestParameters><urn:parameters><urn:dataVectors><dat:dataRow>Wort</dat:dataRow><dat:dataRow>Haus</dat:dataRow></urn:dataVectors><urn:dataVectors><dat:dataRow>Limit</dat:dataRow><dat:dataRow>10</dat:dataRow></urn:dataVectors></urn:parameters><urn:corpus>de</urn:corpus></urn:objRequestParameters></urn:execute></env:Body></env:Envelope>
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'test/unit'
3
+ require 'fakeweb'
3
4
  require 'wlapi'
4
5
 
5
6
 
@@ -15,9 +16,23 @@ class TestApi < Test::Unit::TestCase
15
16
 
16
17
  # test constants
17
18
  def test_constants
18
- assert(WLAPI::VERSION.is_a?(String) && ! WLAPI::VERSION.empty?)
19
- end
20
-
19
+ assert(WLAPI::VERSION.is_a?(String))
20
+ assert_equal(false, WLAPI::VERSION.empty?)
21
+ end
22
+ =begin
23
+ # It should generate a valid soap request for some input.
24
+ def test_soap_generation
25
+ file = 'test/data/soap_request.txt'
26
+ soap = File.read(file)
27
+
28
+ url = 'http://wortschatz.uni-leipzig.de/axis/services/Thesaurus'
29
+ FakeWeb.register_uri(:post, url, :response => http_resp)
30
+
31
+ actual_api_answer = query.get
32
+ assert_instance_of(String, actual_api_answer, 'Not String!')
33
+ assert_equal(expected_api_answer, actual_api_answer)
34
+ end
35
+ =end
21
36
  # one parameter
22
37
  def test_frequencies
23
38
  assert_respond_to(@api, :frequencies)
@@ -227,11 +242,4 @@ class TestApi < Test::Unit::TestCase
227
242
  @api.intersection(@word, @word, 10)
228
243
  end
229
244
  end
230
-
231
- # private methods
232
- def test_query
233
- end
234
-
235
- def test_get_answer
236
- end
237
245
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wlapi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 4
10
- version: 0.7.4
8
+ - 8
9
+ - 0
10
+ version: 0.8.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrei Beliankou
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-11 00:00:00 Z
18
+ date: 2011-08-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon
@@ -23,14 +23,12 @@ dependencies:
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - "="
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 17
28
+ hash: 3
29
29
  segments:
30
30
  - 0
31
- - 7
32
- - 9
33
- version: 0.7.9
31
+ version: "0"
34
32
  type: :runtime
35
33
  version_requirements: *id001
36
34
  - !ruby/object:Gem::Dependency
@@ -50,7 +48,7 @@ dependencies:
50
48
  type: :development
51
49
  version_requirements: *id002
52
50
  - !ruby/object:Gem::Dependency
53
- name: fakeweb
51
+ name: yard
54
52
  prerelease: false
55
53
  requirement: &id003 !ruby/object:Gem::Requirement
56
54
  none: false
@@ -63,7 +61,21 @@ dependencies:
63
61
  version: "0"
64
62
  type: :development
65
63
  version_requirements: *id003
66
- description: WLAPI is a programmatic API for web services provided by the project Wortschatz, University of Leipzig.
64
+ - !ruby/object:Gem::Dependency
65
+ name: fakeweb
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :development
77
+ version_requirements: *id004
78
+ description: WLAPI is a programmatic API for web services provided by the project Wortschatz, University of Leipzig. These services are a great source of linguistic knowledge for morphological, syntactic and semantic analysis of German both for traditional and Computational Linguistics (CL). Use this API to gain data on word frequencies, left and right neighbours, collocations and semantic similarity. Check it out if you are interested in Natural Language Processing (NLP) and Human Language Technology (HLT).
67
79
  email: a.belenkow@uni-trier.de
68
80
  executables: []
69
81
 
@@ -82,6 +94,7 @@ files:
82
94
  - CHANGELOG
83
95
  - .yardopts
84
96
  - test/test_api.rb
97
+ - test/data/soap_request.txt
85
98
  homepage: http://www.uni-trier.de/index.php?id=34451
86
99
  licenses: []
87
100
 
@@ -120,3 +133,4 @@ specification_version: 3
120
133
  summary: WLAPI is a programmatic API for web services provided by the project Wortschatz, University of Leipzig. Use different linguistic services such as synonym and collocation search.
121
134
  test_files:
122
135
  - test/test_api.rb
136
+ - test/data/soap_request.txt