wlapi 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010, 2011 Andrei Beliankou
1
+ Copyright (c) 2010-2013 Andrei Beliankou
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -17,3 +17,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  THE SOFTWARE.
20
+
data/README.rdoc CHANGED
@@ -1,63 +1,59 @@
1
1
  = WLAPI
2
2
 
3
- * {RubyGems}[http://rubygems.org/gems/wlapi]
4
- * Developers {Homepage}[http://bu.chsta.be/]
5
- * {WLAPI Project Page}[http://bu.chsta.be/projects/wlapi/]
6
- * {Source Code}[https://github.com/arbox/wlapi]
7
- * {Bug Tracker}[https://github.com/arbox/wlapi/issues]
8
- * {Mailing List}[http://groups.google.com/group/wlapi]
3
+ {RubyGems}[http://rubygems.org/gems/wlapi] | {WLAPI Project Page}[http://bu.chsta.be/projects/wlapi/] |
4
+ {Source Code}[https://github.com/arbox/wlapi] | {Bug Tracker}[https://github.com/arbox/wlapi/issues] |
5
+ {Mailing List}[http://groups.google.com/group/wlapi]
6
+
7
+ {<img src="https://badge.fury.io/rb/wlapi.png" alt="Gem Version" />}[http://badge.fury.io/rb/wlapi]
8
+ {<img src="https://travis-ci.org/arbox/wlapi.png" alt="Build Status" />}[https://travis-ci.org/arbox/wlapi]
9
+ {<img src="https://codeclimate.com/github/arbox/wlapi.png" alt="Code Climate" />}[https://codeclimate.com/github/arbox/wlapi]
9
10
 
10
11
  == DESCRIPTION
11
- WLAPI is a programmatic API for web services provided by the project
12
- {Wortschatz}[http://wortschatz.uni-leipzig.de/],
13
- University of Leipzig. These services are a great source of linguistic knowledge
14
- for morphological, syntactic and semantic analysis of German both for traditional
15
- and Computational Linguistics (CL).
16
-
17
- Use this API to gain data on word frequencies, left and right neighbours,
18
- collocations and semantic similarity. Check it out if you are interested
19
- in Natural Language Processing (NLP) and Human Language Technology (HLT).
12
+ WLAPI is a programmatic API for web services provided by the project {Wortschatz}[http://wortschatz.uni-leipzig.de/], 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).
13
+
14
+ 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).
15
+
20
16
  === Implemented Features
21
17
  You can use the following search methods:
22
- * baseform;
23
- * cooccurrences;
24
- * cooccurrences_all;
25
- * crossword;
26
- * domain;
27
- * experimental_synonyms;
28
- * frequencies;
29
- * left_collocation_finder;
30
- * left_neighbours;
31
- * right_collocation_finder;
32
- * right_neighbours;
33
- * sentences;
34
- * similarity;
35
- * synonyms;
36
- * thesaurus;
37
- * wordforms.
38
-
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.
18
+ * <tt>#baseform</tt>;
19
+ * <tt>#cooccurrences</tt>;
20
+ * <tt>#cooccurrences_all</tt>;
21
+ * <tt>#crossword</tt>;
22
+ * <tt>#domain</tt>;
23
+ * <tt>#experimental_synonyms</tt>;
24
+ * <tt>#frequencies</tt>;
25
+ * <tt>#left_collocation_finder</tt>;
26
+ * <tt>#left_neighbours</tt>;
27
+ * <tt>#right_collocation_finder</tt>;
28
+ * <tt>#right_neighbours</tt>;
29
+ * <tt>#sentences</tt>;
30
+ * <tt>#similarity</tt>;
31
+ * <tt>#synonyms</tt>;
32
+ * <tt>#thesaurus</tt>;
33
+ * <tt>#wordforms</tt>;
34
+ * <tt>#ngrams</tt>;
35
+ * <tt>#ngram_references</tt>;
36
+
37
+ The services <tt>NGrams</tt> and <tt>NGramReferences</tt> are under development and will be available soon. Both methods throw an <tt>NotImplementedError</tt> for now.
38
+
39
+ The interface will be slightly changed in the version <tt>1.0</tt> to be more readable. For example, <tt>#cooccurrences_all</tt> will become <tt>#all_cooccurrences</tt>.
40
+
41
+ There are two additional services by Wortschatz Leipzig: MARS and Kookurrenzschnitt. They will not be implemented due to internal restrictions of the service provider.
45
42
 
46
43
  == INSTALLATION
47
- WLAPI is provided as a .gem package. Simply install it via
48
- {RubyGems}[http://rubygems.org/gems/wlapi].
44
+ WLAPI is provided as a .gem package. Simply install it via {RubyGems}[http://rubygems.org/gems/wlapi].
45
+
49
46
  To install WLAPI ussue the following command:
50
47
  $ gem install wlapi
51
48
 
52
- You might want to install versions prior to +0.8.0+, if you are bound on
53
- the old implementations of {savon}[http://savonrb.com/]:
49
+ The current version of WLAPI works with the second {Savon}[http://savonrb.com/version2/] generation. You might want to install versions prior to +0.8.0+, if you are bound on the old implementations of {savon}[http://savonrb.com/]:
54
50
  $ gem install wlapi -v 0.7.4
55
51
 
56
- If you want to do a system wide installation, do this as root
57
- (possibly using +sudo+).
52
+ If you want to do a system wide installation, do this as root (possibly using +sudo+).
58
53
 
59
- Alternatively use your Gemfile for dependency management.
54
+ Alternatively use your <tt>Gemfile</tt> for dependency management.
60
55
 
56
+ We are working on a <tt>.deb</tt> package, which will be released soon.
61
57
 
62
58
  == SYNOPSIS
63
59
 
@@ -102,6 +98,8 @@ If you want to intercept any and every exception thrown by WLAPI simply rescue
102
98
  If you have question, bug reports or any suggestions, please drop me an email :)
103
99
  Any help is deeply appreciated!
104
100
 
101
+ If you need some new functionality please contact me or provide a pull request. You code should be complete and tested. Please use <tt>local_*</tt> and <tt>remote_*</tt> naming convention for your tests.
102
+
105
103
  == CHANGELOG
106
104
  For details on future plan and working progress see CHANGELOG.
107
105
 
@@ -112,7 +110,6 @@ you might face some not implemented features.
112
110
  Please contact me with your suggestions, bug reports and feature requests.
113
111
  == LICENSE
114
112
 
115
- WLAPI is a copyrighted software by Andrei Beliankou, 2010, 2011
113
+ WLAPI is a copyrighted software by Andrei Beliankou, 2010-2013
116
114
 
117
- You may use, redistribute and change it under the terms
118
- provided in the LICENSE file.
115
+ You may use, redistribute and change it under the terms provided in the LICENSE file.
data/lib/wlapi/api.rb CHANGED
@@ -1,5 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
- # 2010-, Andrei Beliankou
1
+ # -*- encoding: utf-8 -*-
2
+ # 2010-2013, Andrei Beliankou
3
3
 
4
4
  # :title: Ruby based API for Wortschatz Leipzig web services
5
5
  # :main: README.rdoc
@@ -20,13 +20,28 @@ module WLAPI
20
20
  # See the project 'Wortschatz Leipzig' for more details.
21
21
  class API
22
22
 
23
+ # SOAP Services Endpoint.
24
+ ENDPOINT = 'http://wortschatz.uni-leipzig.de/axis/services'
25
+
26
+ # The list of accessible services, the MARSService is excluded due
27
+ # to its internal authorization.
28
+ SERVICES = [:Thesaurus, :Baseform, :Similarity, :Synonyms, :Sachgebiet, :Frequencies,
29
+ :Kookurrenzschnitt, :ExperimentalSynonyms, :RightCollocationFinder,
30
+ :LeftCollocationFinder, :Wordforms, :CooccurrencesAll, :LeftNeighbours,
31
+ :RightNeighbours, :Sentences, :Cooccurrences, :Kreuzwortraetsel,
32
+ :NGrams, :NGramReferences]
33
+
23
34
  # At the creation point clients for all services are being instantiated.
24
35
  # You can also set the login and the password (it defaults to 'anonymous').
25
36
  # api = WLAPI::API.new
26
37
  def initialize(login = 'anonymous', pass = 'anonymous')
27
38
 
28
39
  # This hash contains the URLs to the single services.
29
- endpoint = 'http://wortschatz.uni-leipzig.de/axis/services'
40
+ @services = {}
41
+
42
+ SERVICES.each { |service| @services[service] = "#{ENDPOINT}/#{service}"}
43
+
44
+ =begin
30
45
  @services = {
31
46
  :Thesaurus => "#{endpoint}/Thesaurus",
32
47
  :Baseform => "#{endpoint}/Baseform",
@@ -49,7 +64,7 @@ module WLAPI
49
64
  :NGramReferences => "#{endpoint}/NGramReferences"
50
65
  # no MARSService
51
66
  }
52
-
67
+ =end
53
68
  # cl short for client.
54
69
  # Dynamically create all the clients and set access credentials.
55
70
  # It can be a very bad idea to instantiate all the clients at once,
@@ -57,15 +72,21 @@ module WLAPI
57
72
  # If only one service is used in the separate session => rewrite the class!
58
73
  @services.each do |key, val|
59
74
  cl_name = '@cl_' + key.to_s
60
- eval("#{cl_name} = Savon::Client.new { |wsdl| wsdl.endpoint = val}")
61
- eval("#{cl_name}.wsdl.namespace = val")
62
- eval("#{cl_name}.http.auth.basic(login, pass)")
75
+
76
+ options = {:wsdl => val + "?wsdl",
77
+ :namespaces => {'xmlns:dat' => 'http://datatypes.webservice.wortschatz.uni_leipzig.de',
78
+ 'xmlns:urn' => val},
79
+ :basic_auth => ['anonymous', 'anonymous'],
80
+ :log => $DEBUG
81
+ }
82
+ client = Savon.client(options)
83
+ eval("#{cl_name} = client")
63
84
  end
64
85
 
65
86
  # Savon creates very verbose logs, switching off.
66
- Savon.configure do |config|
67
- config.log = false unless $DEBUG
68
- end
87
+ # Savon.configure do |config|
88
+ # config.log = false unless $DEBUG
89
+ # end
69
90
  HTTPI.log = false unless $DEBUG
70
91
  end
71
92
 
@@ -245,9 +266,11 @@ module WLAPI
245
266
 
246
267
  #
247
268
  def ngrams(pattern, limit = 10)
269
+ raise(NotImplementedError, 'This method will be implemented in the next release.')
248
270
  end
249
271
  #
250
272
  def ngram_references(pattern, limit = 10)
273
+ raise(NotImplementedError, 'This method will be implemented in the next release.')
251
274
  end
252
275
 
253
276
  ## Three parameter methods.
@@ -368,49 +391,39 @@ module WLAPI
368
391
  # with keys and values for the soap query.
369
392
  def query(cl, *args)
370
393
  # WSDL is disabled since calling the server for wsdl can last too long.
371
-
372
- begin
373
- resp = cl.request(:urn, :execute) do |soap|
374
-
375
- # Every service has a different namespace.
376
- soap.namespaces['xmlns:urn'] = cl.wsdl.namespace
377
394
 
378
- soap.namespaces['xmlns:dat'] =
379
- "http://datatypes.webservice.wortschatz.uni_leipzig.de"
380
-
381
- v = []
382
- body = {
383
- 'urn:objRequestParameters' => {
384
- 'urn:corpus' => 'de',
385
- 'urn:parameters' => {
386
- 'urn:dataVectors' => v
387
- }
388
- }
395
+
396
+ v = []
397
+ body = {
398
+ 'urn:objRequestParameters' => {
399
+ 'urn:corpus' => 'de',
400
+ 'urn:parameters' => {
401
+ 'urn:dataVectors' => v
389
402
  }
390
-
391
- # Setting the first argument (usually 'Wort').
392
- v << {'dat:dataRow'=>[
393
- args[0][0],
394
- args[0][1]
395
- ]
396
- } if args[0]
397
- # Setting the second argument (usually 'Limit').
398
- v << {'dat:dataRow'=>[
399
- args[1][0],
400
- args[1][1]
401
- ]
402
- } if args[1]
403
- # Setting the third argument (no common value)
404
- v << {'dat:dataRow'=>[
405
- args[2][0],
403
+ }
404
+ }
405
+
406
+ # Setting the first argument (usually 'Wort').
407
+ v << {'dat:dataRow'=>[
408
+ args[0][0],
409
+ args[0][1]
410
+ ]
411
+ } if args[0]
412
+ # Setting the second argument (usually 'Limit').
413
+ v << {'dat:dataRow'=>[
414
+ args[1][0],
415
+ args[1][1]
416
+ ]
417
+ } if args[1]
418
+ # Setting the third argument (no common value)
419
+ v << {'dat:dataRow'=>[
420
+ args[2][0],
406
421
  args[2][1]
407
- ]
408
- } if args[2]
409
-
410
- soap.body = body
411
- warn(soap.to_xml) if $DEBUG
412
-
413
- end
422
+ ]
423
+ } if args[2]
424
+
425
+ begin
426
+ resp = cl.call(:execute, {:message => body})
414
427
  rescue => e
415
428
  fail(WLAPI::ExternalError, e)
416
429
  end
data/lib/wlapi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WLAPI
2
- VERSION = '0.8.4'
2
+ VERSION = '0.8.5'
3
3
  end
@@ -0,0 +1,95 @@
1
+ require 'test/unit'
2
+ require 'test_helper'
3
+ require 'wlapi'
4
+
5
+ class TestInterface < Test::Unit::TestCase
6
+ include TestHelper
7
+
8
+ ONE_PAR = [:frequencies,
9
+ :baseform,
10
+ :domain]
11
+
12
+ TWO_PAR = [:wordforms,
13
+ :thesaurus,
14
+ :synonyms,
15
+ :sentences,
16
+ :left_neighbours,
17
+ :right_neighbours,
18
+ :similarity,
19
+ :experimental_synonyms,
20
+ :ngrams,
21
+ :ngram_references]
22
+
23
+ THREE_PAR = [:right_collocation_finder,
24
+ :left_collocation_finder,
25
+ :cooccurrences,
26
+ :cooccurrences_all,
27
+ :intersection,
28
+ :crossword]
29
+
30
+ METHODS = ONE_PAR + TWO_PAR + THREE_PAR
31
+
32
+ def setup
33
+ @api = WLAPI::API.new
34
+ @word = 'Stuhl'
35
+ end
36
+
37
+ def teardown
38
+ end
39
+
40
+ # Test constants.
41
+ def test_constants
42
+ assert(WLAPI::VERSION.is_a?(String))
43
+ assert_equal(false, WLAPI::VERSION.empty?)
44
+ end
45
+
46
+ def test_availability_of_pulic_methods
47
+ METHODS.each { |m| assert_respond_to(@api, m) }
48
+ end
49
+
50
+ def test_for_absent_arguments
51
+ assert_raise(ArgumentError) do
52
+ METHODS.each { |m| @api.send(m) }
53
+ end
54
+ end
55
+
56
+ def test_for_redundant_arguments
57
+
58
+ assert_raise(ArgumentError) do
59
+ ONE_PAR.each { |m| @api.send(m, 'a', 2) }
60
+ end
61
+
62
+ assert_raise(ArgumentError) do
63
+ TWO_PAR.each { |m| @api.send(m, 'a', 2, 3) }
64
+ end
65
+
66
+
67
+ assert_raise(ArgumentError) do
68
+ THREE_PAR.each { |m| @api.send(m, 'a', 'a', 3, 4) }
69
+ end
70
+ end
71
+
72
+ def test_argument_semantics
73
+ assert_raise(WLAPI::UserError) do
74
+ ONE_PAR.each { |m| @api.send(m, 1) }
75
+ end
76
+
77
+ assert_raise(WLAPI::UserError) do
78
+ TWO_PAR.each { |m| @api.send(m, 'Haus', [:a]) }
79
+ end
80
+
81
+ assert_raise(WLAPI::UserError) do
82
+ THREE_PAR.each { |m| @api.send(m, 3, 3.5, 'a') }
83
+ end
84
+ end
85
+
86
+ def test_missing_methods
87
+ assert_raise(NotImplementedError) do
88
+ @api.ngrams('Haus')
89
+ end
90
+
91
+ assert_raise(NotImplementedError) do
92
+ @api.ngram_references('Haus')
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,154 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test/unit'
3
+ require 'test_helper.rb'
4
+ require 'wlapi'
5
+
6
+ class TestApi < Test::Unit::TestCase
7
+ include TestHelper
8
+
9
+ def setup
10
+ @api = WLAPI::API.new
11
+ end
12
+
13
+ def teardown
14
+ end
15
+
16
+ # One parameter.
17
+ def test_frequencies
18
+ expectation = ['122072', '7']
19
+
20
+ response = execute(expectation, :frequencies, 'Haus')
21
+
22
+ assert_equal(2, response.size)
23
+ assert_match(/\d+/, response[0])
24
+ assert_match(/\d+/, response[1])
25
+ end
26
+
27
+ def test_baseform
28
+ expectation = ['Auto', 'N']
29
+
30
+ response = execute(expectation, :baseform, 'Autos')
31
+
32
+ assert_equal(2, response.size)
33
+ assert_match(/\w+/, response[0])
34
+ assert_match(/[AVN]/, response[1])
35
+ end
36
+
37
+ def test_domain
38
+ expectation = ["Sprachwissenschaft",
39
+ "Nachname",
40
+ "Stadt",
41
+ "Buchkunde/Buchhandel",
42
+ "Motive",
43
+ "Literarische/Motive/Stoffe/Gestalten",
44
+ "Buchkunde/Buchhandel",
45
+ "Papierherstellung/Graphische/Technik",
46
+ "Buchkunde/Buchhandel",
47
+ "Bücher",
48
+ "Ort in D"]
49
+ execute(expectation, :domain, 'Buch')
50
+ end
51
+
52
+ # two parameters
53
+ def test_wordforms
54
+ expectation = ["Buch",
55
+ "Bücher",
56
+ "Büchern",
57
+ "Buches",
58
+ "Buchs",
59
+ "Bucher"]
60
+ execute(expectation, :wordforms, 'Buch')
61
+ end
62
+
63
+ def test_thesaurus
64
+ expectation = ["Buch", "Titel", "Werk", "Zeitung", "Band",
65
+ "Literatur", "Zeitschrift", "Bruch", "Lektüre",
66
+ "Schrift"]
67
+ execute(expectation, :thesaurus, 'Buch')
68
+ end
69
+
70
+ def test_synonyms
71
+ expectation = ["Laib", "Brotlaib", "Laib", "Schnitte", "Stulle"]
72
+ execute(expectation, :synonyms, 'Brot')
73
+ end
74
+
75
+ def test_sentences
76
+ expectation = ["40829928", "Bei den Grünen war ich wohl im Urteil der politisch korrekten Klasse bei den Richtigen, auch wenn ich in ihren Augen das Falsche sagte."]
77
+ execute(expectation, :sentences, 'Klasse', 1)
78
+ end
79
+
80
+ def test_left_neighbours
81
+ expectation = ["elektrischen", "Stuhl", "626", "seinem", "Stuhl", "592"]
82
+ execute(expectation, :left_neighbours, 'Stuhl', 2)
83
+ end
84
+
85
+ def test_right_neighbours
86
+ expectation = ["Stuhl", "räumen", "189", "Stuhl", "hin und her", "130"]
87
+ execute(expectation, :right_neighbours, 'Stuhl', 2)
88
+ end
89
+
90
+ def test_similarity
91
+ expectation = ["Stuhl", "Sessel", "26",
92
+ "Stuhl", "Lehnstuhl", "24",
93
+ "Stuhl", "Sofa", "21"]
94
+ execute(expectation, :similarity, 'Stuhl', 3)
95
+ end
96
+
97
+ def test_experimental_synonyms
98
+ expectation = ["Einrichtungsgegenstand", "v",
99
+ "Bett", "v",
100
+ "Lampe", "v",
101
+ "Tisch", "v",
102
+ "Schrank", "v",
103
+ "Teppich", "v",
104
+ "Gebrauchsmöbel", "v",
105
+ "Möbelstück", "v",
106
+ "Bank", "v",
107
+ "Bord", "v"]
108
+ execute(expectation, :experimental_synonyms, 'Stuhl')
109
+ end
110
+
111
+ # three parameters
112
+ def test_right_collocation_finder
113
+ expectation = ["Stuhl", "aufmöbeln", "V",
114
+ "Stuhl", "aufreihen", "V",
115
+ "Stuhl", "aufspringen", "V"]
116
+ execute(expectation, :right_collocation_finder, 'Stuhl', 'V', 3)
117
+ end
118
+
119
+ def test_left_collocation_finder
120
+ expectation = ["Hl", "A", "Stuhl",
121
+ "abwaschbar", "A", "Stuhl",
122
+ "alle", "A", "Stuhl"]
123
+ execute(expectation, :left_collocation_finder, 'Stuhl', 'A', 3)
124
+ end
125
+
126
+ def test_cooccurrences
127
+ expectation = ["Haus", "das", "11747"]
128
+ execute(expectation, :cooccurrences, 'Haus', 10000)
129
+ end
130
+
131
+ def test_cooccurrences_all
132
+ begin
133
+ execute(['Expected'], :cooccurrences_all, 'Haus', 10000)
134
+ rescue WLAPI::ExternalError => e
135
+ assert_match(/You're not allowed to access this service./, e.message)
136
+ end
137
+ # Not possible to test without access credential.
138
+ end
139
+
140
+ def test_intersection
141
+ begin
142
+ execute(['Expected'], :intersection, 'Haus', 'Brot', 1)
143
+ rescue WLAPI::ExternalError => e
144
+ assert_match(/You're not allowed to access this service./, e.message)
145
+ end
146
+ # Not possible to test without access credentials.
147
+ end
148
+
149
+ def test_crossword
150
+ expectation = ['word'] * 24
151
+ response = execute(expectation, :crossword, '%uto', 4, 200)
152
+ assert(response.length == 24)
153
+ end
154
+ end
@@ -0,0 +1,28 @@
1
+ module TestHelper
2
+ def execute(expectation, method, *args)
3
+ begin
4
+ result = @api.send(method, *args)
5
+ rescue => error
6
+ if error.message =~ /(Server shutdown in progress)|(404)/i
7
+ result = expectation
8
+ else
9
+ raise
10
+ end
11
+ end
12
+
13
+ check_response(result)
14
+ assert_equal(expectation, result)
15
+
16
+ result
17
+ end
18
+
19
+ def check_input(*args)
20
+ end
21
+
22
+
23
+ def check_response(response)
24
+ assert_not_nil(response)
25
+ assert_instance_of(Array, response)
26
+ assert(response.any?)
27
+ end
28
+ 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: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 4
10
- version: 0.8.4
9
+ - 5
10
+ version: 0.8.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrei Beliankou
@@ -15,27 +15,25 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-08 00:00:00 Z
18
+ date: 2013-07-14 00:00:00 +02:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: savon
22
- prerelease: false
23
22
  requirement: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
26
- - - ">="
25
+ - - ~>
27
26
  - !ruby/object:Gem::Version
28
- hash: 63
27
+ hash: 1
29
28
  segments:
30
- - 0
31
- - 8
32
- - 0
33
- version: 0.8.0
34
- type: :runtime
29
+ - 2
30
+ - 1
31
+ version: "2.1"
32
+ name: savon
35
33
  version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rdoc
38
34
  prerelease: false
35
+ type: :runtime
36
+ - !ruby/object:Gem::Dependency
39
37
  requirement: &id002 !ruby/object:Gem::Requirement
40
38
  none: false
41
39
  requirements:
@@ -47,11 +45,11 @@ dependencies:
47
45
  - 9
48
46
  - 1
49
47
  version: 3.9.1
50
- type: :development
48
+ name: rdoc
51
49
  version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: bundler
54
50
  prerelease: false
51
+ type: :development
52
+ - !ruby/object:Gem::Dependency
55
53
  requirement: &id003 !ruby/object:Gem::Requirement
56
54
  none: false
57
55
  requirements:
@@ -61,11 +59,11 @@ dependencies:
61
59
  segments:
62
60
  - 0
63
61
  version: "0"
64
- type: :development
62
+ name: bundler
65
63
  version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: yard
68
64
  prerelease: false
65
+ type: :development
66
+ - !ruby/object:Gem::Dependency
69
67
  requirement: &id004 !ruby/object:Gem::Requirement
70
68
  none: false
71
69
  requirements:
@@ -75,11 +73,11 @@ dependencies:
75
73
  segments:
76
74
  - 0
77
75
  version: "0"
78
- type: :development
76
+ name: yard
79
77
  version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: rake
82
78
  prerelease: false
79
+ type: :development
80
+ - !ruby/object:Gem::Dependency
83
81
  requirement: &id005 !ruby/object:Gem::Requirement
84
82
  none: false
85
83
  requirements:
@@ -89,10 +87,12 @@ dependencies:
89
87
  segments:
90
88
  - 0
91
89
  version: "0"
92
- type: :development
90
+ name: rake
93
91
  version_requirements: *id005
92
+ prerelease: false
93
+ type: :development
94
94
  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).
95
- email: a.belenkow@uni-trier.de
95
+ email: arbox@bu.chsta.be
96
96
  executables: []
97
97
 
98
98
  extensions: []
@@ -102,17 +102,20 @@ extra_rdoc_files:
102
102
  - LICENSE.rdoc
103
103
  - CHANGELOG.rdoc
104
104
  files:
105
+ - lib/wlapi.rb
106
+ - lib/wlapi/api.rb
105
107
  - lib/wlapi/error.rb
106
108
  - lib/wlapi/version.rb
107
- - lib/wlapi/api.rb
108
- - lib/wlapi.rb
109
109
  - README.rdoc
110
110
  - LICENSE.rdoc
111
111
  - CHANGELOG.rdoc
112
112
  - .yardopts
113
- - test/test_api.rb
114
113
  - test/data/soap_request.txt
115
- homepage: http://www.uni-trier.de/index.php?id=34451
114
+ - test/local_test_interface.rb
115
+ - test/remote_test_functional.rb
116
+ - test/test_helper.rb
117
+ has_rdoc: true
118
+ homepage: http://bu.chsta.be/projects/wlapi/
116
119
  licenses: []
117
120
 
118
121
  post_install_message:
@@ -144,10 +147,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
147
  requirements: []
145
148
 
146
149
  rubyforge_project:
147
- rubygems_version: 1.8.10
150
+ rubygems_version: 1.6.2
148
151
  signing_key:
149
152
  specification_version: 3
150
153
  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.
151
154
  test_files:
152
- - test/test_api.rb
153
155
  - test/data/soap_request.txt
156
+ - test/local_test_interface.rb
157
+ - test/remote_test_functional.rb
158
+ - test/test_helper.rb
data/test/test_api.rb DELETED
@@ -1,280 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'test/unit'
3
- require 'wlapi'
4
-
5
-
6
- class TestApi < Test::Unit::TestCase
7
-
8
- ONE_PAR = [:frequencies,
9
- :baseform,
10
- :domain
11
- ]
12
-
13
- TWO_PAR = [:wordforms,
14
- :thesaurus,
15
- :synonyms,
16
- :sentences,
17
- :left_neighbours,
18
- :right_neighbours,
19
- :similarity,
20
- :experimental_synonyms,
21
- :ngrams,
22
- :ngram_references
23
- ]
24
-
25
- THREE_PAR = [:right_collocation_finder,
26
- :left_collocation_finder,
27
- :cooccurrences,
28
- :cooccurrences_all,
29
- :intersection,
30
- :crossword
31
- ]
32
-
33
- METHODS = ONE_PAR + TWO_PAR + THREE_PAR
34
-
35
- def setup
36
- @api = WLAPI::API.new
37
- @word = 'Stuhl'
38
- end
39
-
40
- def teardown
41
- end
42
-
43
- # Test constants.
44
- def test_constants
45
- assert(WLAPI::VERSION.is_a?(String))
46
- assert_equal(false, WLAPI::VERSION.empty?)
47
- end
48
-
49
- def test_availability_of_pulic_methods
50
- METHODS.each { |m| assert_respond_to(@api, m) }
51
- end
52
-
53
- def test_for_absent_arguments
54
- assert_raise(ArgumentError) do
55
- METHODS.each { |m| @api.send(m) }
56
- end
57
- end
58
-
59
- def test_for_redundant_arguments
60
-
61
- assert_raise(ArgumentError) do
62
- ONE_PAR.each { |m| @api.send(m, 'a', 2) }
63
- end
64
-
65
- assert_raise(ArgumentError) do
66
- TWO_PAR.each { |m| @api.send(m, 'a', 2, 3) }
67
- end
68
-
69
-
70
- assert_raise(ArgumentError) do
71
- THREE_PAR.each { |m| @api.send(m, 'a', 'a', 3, 4) }
72
- end
73
- end
74
-
75
- def test_argument_semantics
76
- assert_raise(WLAPI::UserError) do
77
- ONE_PAR.each { |m| @api.send(m, 1) }
78
- end
79
-
80
- assert_raise(WLAPI::UserError) do
81
- TWO_PAR.each { |m| @api.send(m, 'Haus', [:a]) }
82
- end
83
-
84
- assert_raise(WLAPI::UserError) do
85
- THREE_PAR.each { |m| @api.send(m, 3, 3.5, 'a') }
86
- end
87
- end
88
-
89
- # One parameter.
90
- def test_frequencies
91
- response = @api.frequencies('Haus')
92
- check_response(response)
93
-
94
- assert_equal(2, response.size)
95
- assert_match(/\d+/, response[0])
96
- assert_match(/\d+/, response[1])
97
- assert_equal(["122072", "7"], response)
98
- end
99
-
100
- def test_baseform
101
- response = @api.baseform('Autos')
102
- check_response(response)
103
-
104
- assert_equal(2, response.size)
105
- assert_match(/\w+/, response[0])
106
- assert_match(/[AVN]/, response[1])
107
- assert_equal(["Auto", "N"], response)
108
- end
109
-
110
- def test_domain
111
- response = @api.domain('Buch')
112
- check_response(response)
113
-
114
- expected_response = ["Sprachwissenschaft",
115
- "Nachname",
116
- "Stadt",
117
- "Buchkunde/Buchhandel",
118
- "Motive",
119
- "Literarische/Motive/Stoffe/Gestalten",
120
- "Buchkunde/Buchhandel",
121
- "Papierherstellung/Graphische/Technik",
122
- "Buchkunde/Buchhandel",
123
- "Bücher",
124
- "Ort in D"
125
- ]
126
- assert_equal(expected_response, response)
127
- # We cannot predict the minimal structure of the response.
128
- end
129
-
130
- # two parameters
131
- def test_wordforms
132
- response = @api.wordforms('Buch')
133
- check_response(response)
134
-
135
- expected_response = ["Buch",
136
- "Bücher",
137
- "Büchern",
138
- "Buches",
139
- "Buchs",
140
- "Bucher"
141
- ]
142
- assert_equal(expected_response, response)
143
- end
144
-
145
- def test_thesaurus
146
- response = @api.thesaurus('Buch')
147
- check_response(response)
148
-
149
- expected_response = ["Buch", "Titel", "Werk", "Zeitung", "Band",
150
- "Literatur", "Zeitschrift", "Bruch", "Lektüre",
151
- "Schrift"]
152
- assert_equal(expected_response, response)
153
- end
154
-
155
- def test_synonyms
156
- response = @api.synonyms('Brot')
157
- check_response(response)
158
-
159
- expected_response = ["Laib", "Brotlaib", "Laib", "Schnitte", "Stulle"]
160
- assert_equal(expected_response, response)
161
- end
162
-
163
- def test_sentences
164
- response = @api.sentences('Klasse', 1)
165
- check_response(response)
166
- expected_response = ["40829928",
167
- "Bei den Grünen war ich wohl im Urteil der politisch korrekten Klasse bei den Richtigen, auch wenn ich in ihren Augen das Falsche sagte."]
168
- assert_equal(expected_response, response)
169
- end
170
-
171
- def test_left_neighbours
172
- response = @api.left_neighbours('Stuhl', 2)
173
- check_response(response)
174
-
175
- expected_response = ["elektrischen", "Stuhl", "626",
176
- "seinem", "Stuhl", "592"]
177
- assert_equal(expected_response, response)
178
- end
179
-
180
- def test_right_neighbours
181
- response = @api.right_neighbours('Stuhl', 2)
182
- check_response(response)
183
-
184
- expected_response = ["Stuhl", "räumen", "189",
185
- "Stuhl", "hin und her", "130"]
186
- assert_equal(expected_response, response)
187
- end
188
-
189
- def test_similarity
190
- response = @api.similarity('Stuhl', 3)
191
- check_response(response)
192
-
193
- expected_response = ["Stuhl", "Sessel", "26",
194
- "Stuhl", "Lehnstuhl", "24",
195
- "Stuhl", "Sofa", "21"]
196
- assert_equal(expected_response, response)
197
- end
198
-
199
- def test_experimental_synonyms
200
- response = @api.experimental_synonyms('Stuhl')
201
- check_response(response)
202
-
203
- expected_response = ["Einrichtungsgegenstand", "v",
204
- "Bett", "v",
205
- "Lampe", "v",
206
- "Tisch", "v",
207
- "Schrank", "v",
208
- "Teppich", "v",
209
- "Gebrauchsmöbel", "v",
210
- "Möbelstück", "v",
211
- "Bank", "v",
212
- "Bord", "v"
213
- ]
214
- assert_equal(expected_response, response)
215
- end
216
-
217
- # three parameters
218
- def test_right_collocation_finder
219
- response = @api.right_collocation_finder('Stuhl', 'V', 3)
220
- check_response(response)
221
-
222
- expected_response = ["Stuhl", "aufmöbeln", "V",
223
- "Stuhl", "aufreihen", "V",
224
- "Stuhl", "aufspringen", "V"
225
- ]
226
- assert_equal(expected_response, response)
227
- end
228
-
229
- def test_left_collocation_finder
230
- response = @api.left_collocation_finder('Stuhl', 'A', 3)
231
- check_response(response)
232
- expected_response = ["Hl", "A", "Stuhl",
233
- "abwaschbar", "A", "Stuhl",
234
- "alle", "A", "Stuhl"
235
- ]
236
- assert_equal(expected_response, response)
237
- end
238
-
239
- def test_cooccurrences
240
- response = @api.cooccurrences('Haus', 10000)
241
- check_response(response)
242
- expected_response = ["Haus", "das", "11747"]
243
-
244
- assert_equal(expected_response, response)
245
- end
246
-
247
- def test_cooccurrences_all
248
- begin
249
- @api.cooccurrences_all('Haus', 10000)
250
- rescue WLAPI::ExternalError => e
251
- assert_match(/You're not allowed to access this service./, e.message)
252
- end
253
- # Not possible to test without access credential.
254
- end
255
-
256
- def test_intersection
257
- begin
258
- @api.intersection('Haus', 'Brot', 1)
259
- rescue WLAPI::ExternalError => e
260
- assert_match(/You're not allowed to access this service./, e.message)
261
- end
262
- # Not possible to test without access credentials.
263
- end
264
-
265
- def test_crossword
266
- response = @api.crossword('%uto', 4, 200)
267
- assert(response.length == 24)
268
- end
269
-
270
- ################## HELPER METHODS ###############################################
271
- def check_input(*args)
272
- end
273
-
274
-
275
- def check_response(response)
276
- assert_not_nil(response)
277
- assert_instance_of(Array, response)
278
- assert(response.any?)
279
- end
280
- end