languagedetection 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +295 -14
- data/example/example_detect.rb +1 -1
- data/lib/language_detection/version.rb +1 -1
- data/out/production/language_detection/language_detection/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db458a670ad5f22f0587b1cfdc99ebd20117f6d9
|
4
|
+
data.tar.gz: 803d6922c08d3f101dd1ed9ff255f1d259e469d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cfd72cbb420a4a4d65358a8580b8ff2b5569181dee6bed78e3ad96d7b33d71a6c8fe210c6181a31e8fe2023b0f2806995b86ea93b50cfce4bc22a2618b639cf
|
7
|
+
data.tar.gz: 24208fa2bfb42f7d7a3ef5ad5fc19c601b99c3b03aaf1dac1c9f12bd52aed0e0e8f1c48662060c5f5e2a919d2961fc623fe5e29e5f4ce20a348ea46ab9f21fff
|
data/README.md
CHANGED
@@ -1,41 +1,322 @@
|
|
1
|
-
|
1
|
+
[![Travis](https://travis-ci.org/pmoelgaard/language_detection.svg)](Travis)
|
2
2
|
|
3
|
-
|
3
|
+
# languagedetection
|
4
4
|
|
5
|
-
|
5
|
+
Ruby Library for the languagelayer API, a web service that email validation & verification, [https://mailboxlayer.com/](https://mailboxlayer.com/)
|
6
|
+
|
7
|
+
Offering a uniquely simple way to automate language detection using any programming language, accurate, efficient, and lightning fast.
|
8
|
+
|
9
|
+
---
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
Add this line to your application's Gemfile:
|
10
14
|
|
11
|
-
```
|
12
|
-
gem '
|
15
|
+
```
|
16
|
+
gem 'languagedetection'
|
17
|
+
|
13
18
|
```
|
14
19
|
|
15
20
|
And then execute:
|
16
21
|
|
17
|
-
|
22
|
+
```
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
```
|
18
26
|
|
19
27
|
Or install it yourself as:
|
20
28
|
|
21
|
-
|
29
|
+
```
|
30
|
+
$ gem install languagedetection
|
31
|
+
|
32
|
+
```
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
## Configuration
|
37
|
+
|
38
|
+
Before using the languagelayer API client you have to setup your account and obtain your API Access Key.
|
39
|
+
You can get it by signing up at [https://languagelayer.com/product](https://languagelayer.com/product).
|
40
|
+
|
41
|
+
---
|
42
|
+
|
43
|
+
## API Overview
|
44
|
+
All endpoints in the public API is available through this library.
|
45
|
+
|
46
|
+
- detect
|
47
|
+
- batch
|
48
|
+
- languages
|
49
|
+
|
50
|
+
---
|
22
51
|
|
23
52
|
## Usage
|
24
53
|
|
25
|
-
|
54
|
+
The general API is documented here: [https://languagelayer.com/documentation](https://languagelayer.com/documentation).
|
55
|
+
You can find parameters, result set definitions and status codes documented here as well.
|
56
|
+
|
57
|
+
In the examples directory you can find demos and samples of general usage of all the API functions.
|
58
|
+
|
59
|
+
### Setup
|
60
|
+
|
61
|
+
First we require the module
|
62
|
+
|
63
|
+
```
|
64
|
+
require 'languagedetection'
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
Second we instantiate the client
|
69
|
+
|
70
|
+
```
|
71
|
+
@client = LanguageLayer::Client.new( [access_key] )
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
#### Required Parameters
|
76
|
+
|
77
|
+
###### access_key
|
78
|
+
Your unique key that you can find on the dashboard of your account under the languagelayer account.
|
79
|
+
|
80
|
+
#### Optional Parameters
|
81
|
+
|
82
|
+
###### Secure (only available for Basic, Pro and Enterprise accounts)
|
83
|
+
Boolean value to indicate if the calls to the API should use a secure protocol or insecure (HTTP/HTTPS). Defaults to false (HTTP, insecure).
|
84
|
+
|
85
|
+
---
|
86
|
+
|
87
|
+
## Detect (simple case)
|
88
|
+
|
89
|
+
Takes a query string and detects the language.
|
90
|
+
|
91
|
+
###### Define Query
|
92
|
+
|
93
|
+
First we get a reference to the string that needs to be detected
|
94
|
+
|
95
|
+
```
|
96
|
+
query = 'Good afternoon, sir. How are you today?'
|
97
|
+
|
98
|
+
```
|
99
|
+
|
100
|
+
Second we define an options object.
|
101
|
+
All the options are documented here: [https://languagelayer.com/documentation](https://languagelayer.com/documentation)
|
102
|
+
|
103
|
+
```
|
104
|
+
options = LanguageLayer::DetectOptions.new()
|
105
|
+
|
106
|
+
```
|
107
|
+
|
108
|
+
###### Call Client
|
109
|
+
We then place the actual call to the API, passing in the email we wish to check and the options we defined above.
|
110
|
+
|
111
|
+
```
|
112
|
+
response = @client.detect( [query] [, options] )
|
113
|
+
|
114
|
+
```
|
115
|
+
|
116
|
+
###### Response
|
26
117
|
|
27
|
-
|
118
|
+
If we pass the email ```Good afternoon, sir. How are you today?``` as the query argument above, we get the following result:
|
28
119
|
|
29
|
-
|
120
|
+
```
|
121
|
+
{
|
122
|
+
"success": true,
|
123
|
+
"results":[
|
124
|
+
{
|
125
|
+
"language_code": "en",
|
126
|
+
"language_name": "English",
|
127
|
+
"probability": 12.141682269266,
|
128
|
+
"percentage": 100,
|
129
|
+
"reliable_result": true
|
130
|
+
}
|
131
|
+
]
|
132
|
+
}
|
133
|
+
|
134
|
+
```
|
135
|
+
## Batch Detection
|
136
|
+
Takes an array of strings and detects the language with a corresponding list of detections for each string.
|
137
|
+
|
138
|
+
###### Define Query
|
139
|
+
|
140
|
+
First we get a reference to the string that needs to be detected
|
141
|
+
|
142
|
+
```
|
143
|
+
query: [
|
144
|
+
'Good afternoon, how are you today?',
|
145
|
+
'Guten Tag mein Herr, wie geht es Ihnen?',
|
146
|
+
'Buenos días señor, cómo está hoy?'
|
147
|
+
],
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
Second we define an options object.
|
152
|
+
In this example we are passing the ```show_query``` option so each of elements in the result will contain the original query.
|
153
|
+
All the options are documented here: [https://languagelayer.com/documentation](https://languagelayer.com/documentation)
|
154
|
+
|
155
|
+
```
|
156
|
+
options = LanguageLayer::BatchOptions.new({
|
157
|
+
show_query: 1
|
158
|
+
})
|
159
|
+
|
160
|
+
```
|
161
|
+
|
162
|
+
###### Call Client
|
163
|
+
We then place the actual call to the API, passing in the email we wish to check and the options we defined above.
|
164
|
+
|
165
|
+
```
|
166
|
+
response = @client.batch( [query] [, options] )
|
167
|
+
|
168
|
+
```
|
169
|
+
|
170
|
+
###### Response
|
171
|
+
{
|
172
|
+
"success": true,
|
173
|
+
"results": [
|
174
|
+
[
|
175
|
+
{
|
176
|
+
"query": "Good afternoon, how are you today?",
|
177
|
+
"language_code": "en",
|
178
|
+
"language_name": "English",
|
179
|
+
"probability": 12.141682269266,
|
180
|
+
"percentage": 100,
|
181
|
+
"reliable_result": true
|
182
|
+
}
|
183
|
+
],
|
184
|
+
[
|
185
|
+
{
|
186
|
+
"query": "Guten Tag mein Herr, wie geht es Ihnen?",
|
187
|
+
"language_code": "de",
|
188
|
+
"language_name": "German",
|
189
|
+
"probability": 23.045066185021,
|
190
|
+
"percentage": 100,
|
191
|
+
"reliable_result": false
|
192
|
+
}
|
193
|
+
],
|
194
|
+
[
|
195
|
+
{
|
196
|
+
"query": "Buenos días señor, cómo está hoy?",
|
197
|
+
"language_code": "es",
|
198
|
+
"language_name": "Spanish",
|
199
|
+
"probability": 14.560273752505,
|
200
|
+
"percentage": 100,
|
201
|
+
"reliable_result": false
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"query": "Buenos días señor, cómo está hoy?",
|
205
|
+
"language_code": "pt",
|
206
|
+
"language_name": "Portuguese",
|
207
|
+
"probability": 13.98519485076,
|
208
|
+
"percentage": 96.05035652818,
|
209
|
+
"reliable_result": false
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"query": "Buenos días señor, cómo está hoy?",
|
213
|
+
"language_code": "gl",
|
214
|
+
"language_name": "Galician",
|
215
|
+
"probability": 13.585199932687,
|
216
|
+
"percentage": 93.30319033562,
|
217
|
+
"reliable_result": false
|
218
|
+
}
|
219
|
+
]
|
220
|
+
]
|
221
|
+
}
|
222
|
+
|
223
|
+
## Supported Languages
|
224
|
+
Returns the list of Supported Languages, similar to the list found here:
|
225
|
+
[https://languagelayer.com/languages](https://languagelayer.com/languages)
|
226
|
+
|
227
|
+
###### Define Query
|
228
|
+
|
229
|
+
For this endpoint, we dont pass any primary argument, just the control options, so we define an options object.
|
230
|
+
There are currently no options for the ```languages``` endpoint, so we could omit it, however we use it with an empty options object here to stay aligned with the standard for the library.
|
231
|
+
|
232
|
+
```
|
233
|
+
options = LanguageLayer::LanguagesOptions.new()
|
234
|
+
|
235
|
+
```
|
236
|
+
|
237
|
+
###### Call Client
|
238
|
+
We then place the actual call to the API, passing in the email we wish to check and the options we defined above.
|
30
239
|
|
31
|
-
|
240
|
+
```
|
241
|
+
response = @client.languages([options] )
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
###### Response
|
246
|
+
{
|
247
|
+
"success": true,
|
248
|
+
"languages": [
|
249
|
+
{
|
250
|
+
"language_code": "en",
|
251
|
+
"language_name": "English"
|
252
|
+
},
|
253
|
+
{
|
254
|
+
"language_code": "af",
|
255
|
+
"language_name": "Afrikaans"
|
256
|
+
},
|
257
|
+
{
|
258
|
+
"language_code": "ar",
|
259
|
+
"language_name": "Arabic"
|
260
|
+
},
|
261
|
+
...
|
262
|
+
]
|
263
|
+
}
|
264
|
+
|
265
|
+
---
|
266
|
+
|
267
|
+
## Example Application
|
268
|
+
|
269
|
+
In the [rootdir]/example directory there is a fully functional application which runs all requests against all the endpoints in the API, the examples above can be seen there as source code.
|
270
|
+
|
271
|
+
The example application uses a process.env variable to hold the access key.
|
272
|
+
|
273
|
+
---
|
274
|
+
|
275
|
+
## Tests
|
276
|
+
|
277
|
+
The tests are written using the rspec testing library.
|
278
|
+
**RSpec** [http://rspec.info/](http://rspec.info/)
|
279
|
+
|
280
|
+
In order to run the tests, the following environment variables needs to be set:
|
281
|
+
|
282
|
+
```
|
283
|
+
ACCESS_KEY = [access_key]
|
284
|
+
|
285
|
+
```
|
286
|
+
|
287
|
+
|
288
|
+
---
|
289
|
+
|
290
|
+
## Customer Support
|
291
|
+
|
292
|
+
Need any assistance? [Get in touch with Customer Support](mailto:support@apilayer.net?subject=%languagelayer%5D).
|
293
|
+
|
294
|
+
---
|
295
|
+
|
296
|
+
## Updates
|
297
|
+
Stay up to date by following [@apilayernet](https://twitter.com/apilayernet) on Twitter.
|
32
298
|
|
33
|
-
|
299
|
+
---
|
34
300
|
|
35
|
-
|
301
|
+
## Legal
|
36
302
|
|
303
|
+
All usage of the languagelayer website, API, and services is subject to the [pdflayer Terms & Conditions](https://pdflayer.com/terms) and all annexed legal documents and agreements.
|
304
|
+
|
305
|
+
---
|
306
|
+
|
307
|
+
## Author
|
308
|
+
Peter Andreas Moelgaard ([GitHub](https://github.com/pmoelgaard), [Twitter](https://twitter.com/petermoelgaard))
|
309
|
+
|
310
|
+
---
|
37
311
|
|
38
312
|
## License
|
313
|
+
Licensed under the The MIT License (MIT)
|
314
|
+
|
315
|
+
Copyright (©) 2016 Peter Andreas Moelgaard & apilayer
|
316
|
+
|
317
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
318
|
+
|
319
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
39
320
|
|
40
|
-
|
321
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
41
322
|
|
data/example/example_detect.rb
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
@client = LanguageLayer::Client.new(ENV['ACCESS_KEY'])
|
12
12
|
|
13
13
|
# Set the email to check, we take a random email
|
14
|
-
query = '
|
14
|
+
query = 'Good afternoon, sir. How are you today?'
|
15
15
|
|
16
16
|
# We declare the options
|
17
17
|
options = LanguageLayer::DetectOptions.new()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: languagedetection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Andreas Moelgaard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|