ltp-cloud-sdk 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52a58d2d0e522c051619ebe8a48e02f4b22fe34986806ef87c9fa248e4f201d2
4
- data.tar.gz: 42f453a8125127082d5d6daa5a41e0490fbbda1e330213c0dd62d08ecee9bf94
3
+ metadata.gz: 7e977105a20d172f3bd2017f16de6ebb0edfb3df11a0d1235182f202f2959008
4
+ data.tar.gz: 071a3c7d54a7fe2cd18b85cca0a74d1514177db0cc3357957353497cda38ffa4
5
5
  SHA512:
6
- metadata.gz: 6d8cbb2f59bc25d08f812a399ee0d575138544a439569d62bd1ec0a3268b1f56d485fb5049864bc15a3f1065c764be76900df996b999cc4f1155ca5cb79107de
7
- data.tar.gz: 50c4d09b3b6481266d923133dcd389ac81886336be45427d207e2160b134c80cf663a6743bd2b96d7e915b617e0ea1ee8c1f31eed39337a50a64ac0d0902948d
6
+ metadata.gz: 3d02bd9a722514f4903467c0c84fdb32b37b88222d537eceffdd20104762f6fabe4ca6aed37d2a96caafb31090dda6637a089d6372dca07359b8eea5ce79572f
7
+ data.tar.gz: 339897ecfeb82d3a98a3c046a4da8e960f2ce7a4261e11dc6f4e7b33108066e65998a0cc8813190146061c3471f555a5097e6e4446d59d7a57c8308ec3492643
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
 
13
13
  .idea
14
+ *.gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.0
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Ltp::Cloud::Sdk
1
+ # Ltp::Cloud::Sdk 语言云非官方ruby SDK
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ltp/cloud/sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ [语言云](https://www.ltp-cloud.com)
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,20 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ `rails`:
24
+
25
+ create `ltp_cloud_sdk` file in the `initializers` directory:
26
+
27
+ ```ruby
28
+ Ltp::Cloud::Sdk.configure do |config|
29
+ config.api_key = 'Your Key Here'
30
+ end
31
+ ```
32
+
33
+ ```ruby
34
+ Ltp::Cloud::Sdk.client.analysis('南京市长江大桥能不能长一点')
35
+ // ["南京市", "长江", "大桥", "能", "不", "能", "长", "一点"]
36
+ ```
26
37
 
27
38
  ## Development
28
39
 
@@ -24,8 +24,12 @@ module Ltp
24
24
  }.merge data
25
25
  end
26
26
 
27
- def request(service, payload)
28
- res = RestClient.get(uri(service), params: payload)
27
+ def request(service, payload, timeout)
28
+ res = RestClient::Request.execute(method: :get,
29
+ url: uri(service),
30
+ timeout: timeout,
31
+ headers: { params: payload }
32
+ )
29
33
  res.body
30
34
  end
31
35
 
@@ -33,9 +37,9 @@ module Ltp
33
37
  "#{END_POINT}#{service}"
34
38
  end
35
39
 
36
- def analysis(text)
37
- payload = request_payload({ text: URI::encode(text), pattern: 'ws' })
38
- res = request 'analysis', payload
40
+ def analysis(text, timeout = 5)
41
+ payload = request_payload({ text: CGI::escape(text), pattern: 'ws' })
42
+ res = request 'analysis', payload, timeout
39
43
  res.split(' ')
40
44
  end
41
45
  end
@@ -1,7 +1,7 @@
1
1
  module Ltp
2
2
  module Cloud
3
3
  module Sdk
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ltp-cloud-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhanglei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".idea/vcs.xml"
78
78
  - ".rspec"
79
+ - ".ruby-version"
79
80
  - ".travis.yml"
80
81
  - CODE_OF_CONDUCT.md
81
82
  - Gemfile
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  version: '0'
111
112
  requirements: []
112
113
  rubyforge_project:
113
- rubygems_version: 2.7.6
114
+ rubygems_version: 2.7.3
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: 非官方语言云SDK