spacycloud 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/spacycloud.rb +50 -0
  3. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9de3b0ca01e77b71e7190d45e1b61f759f40bcadbd004018b9e624f2edac11d5
4
+ data.tar.gz: 60e545c7653571f88043ff0b06090ef07b4bfca5b17ee4e74e629d2ce1c13dbb
5
+ SHA512:
6
+ metadata.gz: 2f335871f83823e2aa666be56affe221600085aff5dca59f20c7194c97d0e4ac8d44ce57917f1662e47400d07f37e7b916577119f48880a7a732df58a90e0223
7
+ data.tar.gz: f732ac0a98243a79f197dc66d4ed28ebed0de7e941289308da22ea4ecde25f0bb1068684b616eaf4e24ab0c00cd487d8710350b88b5b5dd4979173251c2b9b28
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'rest-client'
5
+
6
+ module SpacyCloud
7
+ BASE_URL = 'https://api.spacycloud.io'
8
+ API_VERSION = 'v1'
9
+
10
+ # Client requests the API.
11
+ class Client
12
+ def initialize(model, token)
13
+ @headers = {
14
+ 'Authorization' => "Token #{token}"
15
+ }
16
+ @root_url = "#{BASE_URL}/#{API_VERSION}/#{model}"
17
+ end
18
+
19
+ def entities(user_input)
20
+ api_post('entities', user_input)
21
+ end
22
+
23
+ def dependencies(user_input)
24
+ api_post('dependencies', user_input)
25
+ end
26
+
27
+ def sentence_dependencies(user_input)
28
+ api_post('sentence-dependencies', user_input)
29
+ end
30
+
31
+ def lib_versions
32
+ api_get('version')
33
+ end
34
+
35
+ private
36
+
37
+ def api_post(endpoint, user_input)
38
+ payload = {
39
+ 'text' => user_input
40
+ }
41
+ response = RestClient.post("#{@root_url}/#{endpoint}", payload.to_json, @headers)
42
+ JSON.parse(response.body)
43
+ end
44
+
45
+ def api_get(endpoint)
46
+ response = RestClient.get("#{@root_url}/#{endpoint}", @headers)
47
+ JSON.parse(response.body)
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spacycloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Julien Salinas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'spaCy Cloud serves all the spaCy pre-trained models, and your own custom
14
+ models, through a RESTful API ready for production.\n\nThis is the Python client
15
+ for the API.\n\nMore details here: https://spacycloud.io\n\nDocumentation: https://docs.spacycloud.io\n\nGithub:
16
+ https://github.com/spacycloud/spacycloud-python'
17
+ email: all@juliensalinas.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - spacycloud.rb
23
+ homepage: https://github.com/spacycloud/spacycloud-ruby
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.1.4
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Python client for the spaCy Cloud API
46
+ test_files: []