wlapi 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
1
  == COMPLETED
2
+ === 0.8.4
3
+ Imlemented the <tt>API#crossword</tt> method for the prefix/suffix search.
2
4
  === 0.8.3
3
5
  Implemented a simple error handling strategy, it is possible to intercept
4
6
  the <tt>WLAPI::Error</tt> which covers all error types.
@@ -22,11 +24,15 @@ Initial release of the lib.
22
24
 
23
25
 
24
26
  == PLANNED
25
- === 0.8.4
26
- Test the lib against mri, rbx, jruby, win rubies.
27
+
28
+
27
29
  === 0.8.5
30
+ Test the lib against mri, rbx, jruby, win rubies.
28
31
  Introduce +nokogiri+ for parsing responses.
29
32
  === 0.8.6
33
+ Implement <ngrams> and <ngram_references>.
34
+
35
+ Refine semantic checks for two parameter methods.
30
36
  === 0.8.7
31
37
  === 0.8.8
32
38
  === 0.8.9
@@ -5,6 +5,7 @@
5
5
  * {WLAPI Project Page}[http://bu.chsta.be/projects/wlapi/]
6
6
  * {Source Code}[https://github.com/arbox/wlapi]
7
7
  * {Bug Tracker}[https://github.com/arbox/wlapi/issues]
8
+ * {Mailing List}[http://groups.google.com/group/wlapi]
8
9
 
9
10
  == DESCRIPTION
10
11
  WLAPI is a programmatic API for web services provided by the project
@@ -21,6 +22,7 @@ You can use the following search methods:
21
22
  * baseform;
22
23
  * cooccurrences;
23
24
  * cooccurrences_all;
25
+ * crossword;
24
26
  * domain;
25
27
  * experimental_synonyms;
26
28
  * frequencies;
@@ -34,7 +36,12 @@ You can use the following search methods:
34
36
  * thesaurus;
35
37
  * wordforms.
36
38
 
37
- There are three additional services by Wortschatz Leipzig: Kreuzworträtsel, MARS and Kookurrenzschnitt. They will not be implemented.
39
+ The services <tt>NGrams</tt> and <tt>NGramReferences</tt> are under
40
+ development and will be available soon.
41
+
42
+ There are two additional services by Wortschatz Leipzig: MARS and
43
+ Kookurrenzschnitt. They will not be implemented due to internal restrictions
44
+ of the service provider.
38
45
 
39
46
  == INSTALLATION
40
47
  WLAPI is provided as a .gem package. Simply install it via
@@ -84,11 +91,11 @@ Then it fetches a response from a remote server, it can result
84
91
  in a <tt>WLAPI::ExternalError</tt>. In most cases it will be a simple wrapper
85
92
  around other errors, e.g. <tt>Savon::SOAP::Fault</tt>.
86
93
 
87
- All of them are subcalsses of <tt>YANAPI::Error</tt> which is in turn a subclass
94
+ All of them are subcalsses of <tt>WLAPI::Error</tt> which is in turn a subclass
88
95
  of the standard +RuntimeError+.
89
96
 
90
- If you want to intercept any and every exception thrown by YANAPI simply rescue
91
- <tt>YANAPI::Error</tt>.
97
+ If you want to intercept any and every exception thrown by WLAPI simply rescue
98
+ <tt>WLAPI::Error</tt>.
92
99
 
93
100
 
94
101
  == SUPPORT
@@ -43,8 +43,11 @@ module WLAPI
43
43
  :LeftNeighbours => "#{endpoint}/LeftNeighbours",
44
44
  :RightNeighbours => "#{endpoint}/RightNeighbours",
45
45
  :Sentences => "#{endpoint}/Sentences",
46
- :Cooccurrences => "#{endpoint}/Cooccurrences"
47
- # no MARSService and Kreuzwortrraetsel
46
+ :Cooccurrences => "#{endpoint}/Cooccurrences",
47
+ :Kreuzwortraetsel => "#{endpoint}/Kreuzwortraetsel",
48
+ :NGrams => "#{endpoint}/NGrams",
49
+ :NGramReferences => "#{endpoint}/NGramReferences"
50
+ # no MARSService
48
51
  }
49
52
 
50
53
  # cl short for client.
@@ -116,7 +119,7 @@ module WLAPI
116
119
 
117
120
  get_answer(answer)
118
121
  end
119
-
122
+
120
123
  ## Two parameter methods.
121
124
  #############################################################################
122
125
 
@@ -239,6 +242,13 @@ module WLAPI
239
242
 
240
243
  get_answer(answer)
241
244
  end
245
+
246
+ #
247
+ def ngrams(pattern, limit = 10)
248
+ end
249
+ #
250
+ def ngram_references(pattern, limit = 10)
251
+ end
242
252
 
243
253
  ## Three parameter methods.
244
254
  #############################################################################
@@ -325,6 +335,31 @@ module WLAPI
325
335
 
326
336
  get_answer(answer)
327
337
  end
338
+
339
+ # Attempts to find suitable words given a pattern as word parameter,
340
+ # a word length and the number of words to find at max (limit),
341
+ # e.g. <tt>API#crossword('%uto', 4)</tt> would return find 24 results and
342
+ # return them as an array: <tt>[Auto, Auto, ...]</tt>:
343
+ # api.crossword('%uto') => ["Auto", "Auto", ...]
344
+ # SQL like syntax is used for pattern (<tt>%</tt> for an arbitrary string,
345
+ # <tt>_</tt> for a single character).
346
+ #
347
+ # Note: Umlaute will count as one character
348
+ #
349
+ #--
350
+ # Let's keep all public method names in English:
351
+ # kreuzwortraetsel => crossword.
352
+ def crossword(word, word_length, limit = 10)
353
+ check_params(word, word_length, limit)
354
+
355
+ arg1 = ['Wort', word ]
356
+ arg2 = ['Wortlaenge', word_length]
357
+ arg3 = ['Limit', limit]
358
+ answer = query(@cl_Kreuzwortraetsel, arg1, arg2, arg3)
359
+
360
+ get_answer(answer)
361
+ end
362
+
328
363
  private
329
364
 
330
365
  # Main query method, it invokes the soap engine.
@@ -1,3 +1,3 @@
1
1
  module WLAPI
2
- VERSION = '0.8.3'
2
+ VERSION = '0.8.4'
3
3
  end
@@ -5,9 +5,12 @@ require 'wlapi'
5
5
 
6
6
  class TestApi < Test::Unit::TestCase
7
7
 
8
- METHODS = [:baseform,
9
- :domain,
10
- :wordforms,
8
+ ONE_PAR = [:frequencies,
9
+ :baseform,
10
+ :domain
11
+ ]
12
+
13
+ TWO_PAR = [:wordforms,
11
14
  :thesaurus,
12
15
  :synonyms,
13
16
  :sentences,
@@ -15,35 +18,20 @@ class TestApi < Test::Unit::TestCase
15
18
  :right_neighbours,
16
19
  :similarity,
17
20
  :experimental_synonyms,
18
- :right_collocation_finder,
19
- :left_collocation_finder,
20
- :cooccurrences,
21
- :cooccurrences_all,
22
- :intersection,
23
- :frequencies
21
+ :ngrams,
22
+ :ngram_references
24
23
  ]
25
24
 
26
- ONE_PAR = [:frequencies,
27
- :baseform,
28
- :domain
29
- ]
30
-
31
25
  THREE_PAR = [:right_collocation_finder,
32
26
  :left_collocation_finder,
33
27
  :cooccurrences,
34
28
  :cooccurrences_all,
35
- :intersection
29
+ :intersection,
30
+ :crossword
36
31
  ]
37
32
 
38
- TWO_PAR = [:wordforms,
39
- :thesaurus,
40
- :synonyms,
41
- :sentences,
42
- :left_neighbours,
43
- :right_neighbours,
44
- :similarity,
45
- :experimental_synonyms
46
- ]
33
+ METHODS = ONE_PAR + TWO_PAR + THREE_PAR
34
+
47
35
  def setup
48
36
  @api = WLAPI::API.new
49
37
  @word = 'Stuhl'
@@ -88,15 +76,16 @@ class TestApi < Test::Unit::TestCase
88
76
  assert_raise(WLAPI::UserError) do
89
77
  ONE_PAR.each { |m| @api.send(m, 1) }
90
78
  end
91
- =begin
79
+
92
80
  assert_raise(WLAPI::UserError) do
93
- TWO_PAR.each { |m| @api.send(m, 'Haus', 1) }
81
+ TWO_PAR.each { |m| @api.send(m, 'Haus', [:a]) }
94
82
  end
95
- =end
83
+
96
84
  assert_raise(WLAPI::UserError) do
97
85
  THREE_PAR.each { |m| @api.send(m, 3, 3.5, 'a') }
98
86
  end
99
- end
87
+ end
88
+
100
89
  # One parameter.
101
90
  def test_frequencies
102
91
  response = @api.frequencies('Haus')
@@ -258,7 +247,7 @@ class TestApi < Test::Unit::TestCase
258
247
  def test_cooccurrences_all
259
248
  begin
260
249
  @api.cooccurrences_all('Haus', 10000)
261
- rescue RuntimeError => e
250
+ rescue WLAPI::ExternalError => e
262
251
  assert_match(/You're not allowed to access this service./, e.message)
263
252
  end
264
253
  # Not possible to test without access credential.
@@ -267,13 +256,17 @@ class TestApi < Test::Unit::TestCase
267
256
  def test_intersection
268
257
  begin
269
258
  @api.intersection('Haus', 'Brot', 1)
270
- rescue RuntimeError => e
259
+ rescue WLAPI::ExternalError => e
271
260
  assert_match(/You're not allowed to access this service./, e.message)
272
261
  end
273
262
  # Not possible to test without access credentials.
274
263
  end
275
-
276
-
264
+
265
+ def test_crossword
266
+ response = @api.crossword('%uto', 4, 200)
267
+ assert(response.length == 24)
268
+ end
269
+
277
270
  ################## HELPER METHODS ###############################################
278
271
  def check_input(*args)
279
272
  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: 57
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 3
10
- version: 0.8.3
9
+ - 4
10
+ version: 0.8.4
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-12-16 00:00:00 Z
18
+ date: 2012-01-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon