nexosis_api 2.1.0 → 2.2.0
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.
- checksums.yaml +4 -4
- data/lib/nexosis_api/client/models.rb +3 -3
- data/lib/nexosis_api/client/vocabulary.rb +60 -0
- data/lib/nexosis_api/client.rb +4 -0
- data/lib/nexosis_api/dataset_data.rb +7 -0
- data/lib/nexosis_api/vocabulary_summary.rb +44 -0
- data/lib/nexosis_api/vocabulary_word.rb +22 -0
- data/nexosisapi.gemspec +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c463f70058910101a5ec3b3ed201cc91ed27791c
|
4
|
+
data.tar.gz: '09331c0b0cd6c388851e1782942487038e69f50a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa44a973d907bf7b9a55b4accb1b20669bcd0c8085ee9b92585240926d6d12517f6f14ff25d483097ac7215cc10153bafc319003301bfe23a211910d77f55f23
|
7
|
+
data.tar.gz: 0fe95f24b21264037f0e384af3fd9d8f1757b0e2235443c7041066cd167f1f49a2206a979d086ca4852d51e7a68c5dc2c203cf451239114e5a3b45fc2ef709ae
|
@@ -61,8 +61,8 @@ module NexosisApi
|
|
61
61
|
# @note For a classification model you may include the extra parameter 'includeClassScores' to
|
62
62
|
# get scores back for each class, not just the chosen class.
|
63
63
|
def predict(model_id, feature_data, extra_parameters = {})
|
64
|
-
raise ArgumentError, 'Running predictions requires that model_id be specified and it is currently empty.' if model_id.empty?
|
65
|
-
raise ArgumentError, 'Running predictions requires that feature_data be specified and it is currently empty.' if feature_data.empty?
|
64
|
+
raise ArgumentError, 'Running predictions requires that model_id be specified and it is currently empty.' if model_id.nil? || model_id.empty?
|
65
|
+
raise ArgumentError, 'Running predictions requires that feature_data be specified and it is currently empty.' if feature_data.nil? || feature_data.empty?
|
66
66
|
predict_url = "/models/#{model_id}/predict"
|
67
67
|
feature_data = [feature_data] unless feature_data.kind_of?(Array)
|
68
68
|
response = self.class.post(predict_url, headers: @headers, body: { 'data': feature_data, 'extraParameters': extra_parameters }.to_json)
|
@@ -81,7 +81,7 @@ module NexosisApi
|
|
81
81
|
# @raise [NexosisApi::HttpException]
|
82
82
|
# @raise [ArgumentError]
|
83
83
|
def remove_model(model_id)
|
84
|
-
raise ArgumentError, 'Deleting a model requires that model_id be specified and it is currently empty.' if model_id.empty?
|
84
|
+
raise ArgumentError, 'Deleting a model requires that model_id be specified and it is currently empty.' if model_id.nil? || model_id.empty?
|
85
85
|
delete_url = "/models/#{model_id}"
|
86
86
|
response = self.class.delete(delete_url, @options)
|
87
87
|
unless (response.success?)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module NexosisApi
|
2
|
+
# class to operate on vocabulary endpoint in Nexosis API
|
3
|
+
class Client
|
4
|
+
# Vocabluary-based API operations
|
5
|
+
# @see http://docs.nexosis.com/
|
6
|
+
# @since 2.2.0
|
7
|
+
module Vocabulary
|
8
|
+
# Gets summary information about the Vocabulary built from the Text columns in a session
|
9
|
+
# @param datasource_name [String] optionally limit to those
|
10
|
+
# vocabularies created for this data source name.
|
11
|
+
# @param created_from_session [String] optionally limit to those
|
12
|
+
# vocabularies created for the given session.
|
13
|
+
# @param page [Integer] the page number for paged results. Defaults to 0.
|
14
|
+
# @param page_size [Integer] the size of each page of paged results. Defaults to 50.
|
15
|
+
# @return [NexosisApi::PagedArray of NexosisApi::VocabularySummary] - all vocabularies available within the query parameters
|
16
|
+
# @raise [NexosisApi::HttpException]
|
17
|
+
def list_vocabularies(datasource_name = nil, created_from_session=nil, page = 0, page_size = 50)
|
18
|
+
vocab_url = '/vocabulary'
|
19
|
+
query = {
|
20
|
+
page: page,
|
21
|
+
pageSize: page_size
|
22
|
+
}
|
23
|
+
query.store('created_from_session', datasource_name) unless created_from_session.nil?
|
24
|
+
query.store('dataSourceName', datasource_name) unless datasource_name.nil?
|
25
|
+
response = self.class.get(vocab_url, headers: @headers, query: query)
|
26
|
+
raise HttpException.new("There was a problem listing vocabularies: #{response.code}.",
|
27
|
+
"listing vocabularies with data source name #{datasource_name}",
|
28
|
+
response) unless response.success?
|
29
|
+
NexosisApi::PagedArray.new(response.parsed_response,
|
30
|
+
response.parsed_response['items']
|
31
|
+
.map { |item| NexosisApi::VocabularySummary.new(item) })
|
32
|
+
end
|
33
|
+
|
34
|
+
# Gets a list of Vocabulary Words from a vocabulary
|
35
|
+
# @param vocabulary_id [String] required unique identifier for vocabulary to get
|
36
|
+
# @param type [String] whether to return 'word' types (default), 'stopWord' for only stop words, or nil for both.
|
37
|
+
# @param page [Integer] the page number for paged results. Defaults to 0.
|
38
|
+
# @param page_size [Integer] the size of each page of paged results. Defaults to 50.
|
39
|
+
# @return [NexosisApi::PagedArray of NexosisApi::VocabularyWord]
|
40
|
+
# @note words will be sorted in rank order
|
41
|
+
# @raise [NexosisApi::HttpException]
|
42
|
+
def get_vocabulary(vocabulary_id, type = 'word', page = 0, page_size = 50)
|
43
|
+
raise ArgumentError, 'vocabulary_id was not provided and is not optional' if vocabulary_id.nil?
|
44
|
+
vocab_url = "/vocabulary/#{vocabulary_id}"
|
45
|
+
query = {
|
46
|
+
page: page,
|
47
|
+
pageSize: page_size
|
48
|
+
}
|
49
|
+
query.store('type', type) unless type.nil?
|
50
|
+
response = self.class.get(vocab_url, headers: @headers, query: query)
|
51
|
+
raise HttpException.new("There was a problem getting a vocabulary: #{response.code}.",
|
52
|
+
"getting vocabulary #{vocabulary_id}",
|
53
|
+
response) unless response.success?
|
54
|
+
NexosisApi::PagedArray.new(response.parsed_response,
|
55
|
+
response.parsed_response['items']
|
56
|
+
.map { |item| NexosisApi::VocabularyWord.new(item) })
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/nexosis_api/client.rb
CHANGED
@@ -30,11 +30,14 @@ require 'nexosis_api/session'
|
|
30
30
|
require 'nexosis_api/time_interval'
|
31
31
|
require 'nexosis_api/view_definition'
|
32
32
|
require 'nexosis_api/view_data'
|
33
|
+
require 'nexosis_api/vocabulary_summary'
|
34
|
+
require 'nexosis_api/vocabulary_word'
|
33
35
|
require 'nexosis_api/client/contest'
|
34
36
|
require 'nexosis_api/client/sessions'
|
35
37
|
require 'nexosis_api/client/datasets'
|
36
38
|
require 'nexosis_api/client/imports'
|
37
39
|
require 'nexosis_api/client/views'
|
40
|
+
require 'nexosis_api/client/vocabulary'
|
38
41
|
require 'nexosis_api/client/models'
|
39
42
|
|
40
43
|
module NexosisApi
|
@@ -48,6 +51,7 @@ module NexosisApi
|
|
48
51
|
include Client::Views
|
49
52
|
include Client::Models
|
50
53
|
include Client::Contest
|
54
|
+
include Client::Vocabulary
|
51
55
|
|
52
56
|
def initialize(options = {})
|
53
57
|
raise ArgumentError, 'api_key was not defined' unless options[:api_key].nil? == false
|
@@ -7,6 +7,8 @@ module NexosisApi
|
|
7
7
|
@data = NexosisApi::PagedArray.new(data_hash, v)
|
8
8
|
elsif (k == 'links')
|
9
9
|
@links = v.reject(&:nil?).map { |l| NexosisApi::Link.new(l) }
|
10
|
+
elsif (k == 'isTimeSeries')
|
11
|
+
@is_timeseries = v
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -18,5 +20,10 @@ module NexosisApi
|
|
18
20
|
# The hash of data values from the dataset
|
19
21
|
# @return [NexosisApi::PagedArray of Hash] where each hash contains the dataset data
|
20
22
|
attr_accessor :data
|
23
|
+
|
24
|
+
# Whether or not this dataset was loaded with a date-based key with a timestamp role
|
25
|
+
# @return [Boolean]
|
26
|
+
# @since 2.1.1
|
27
|
+
attr_reader :is_timeseries
|
21
28
|
end
|
22
29
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module NexosisApi
|
2
|
+
# parsed results of a request for vocabulary
|
3
|
+
# @since 2.2.0
|
4
|
+
class VocabularySummary
|
5
|
+
def initialize(vocab_hash)
|
6
|
+
var_map = { 'id' => :@vocabulary_id,
|
7
|
+
'dataSourceName' => :@datasource_name,
|
8
|
+
'columnName' => :@column_name,
|
9
|
+
'dataSourceType' => :@datasource_type,
|
10
|
+
'createdOnDate' => :@created_on,
|
11
|
+
'createdBySessionId' => :@created_by_session }
|
12
|
+
vocab_hash.each { |k, v| instance_variable_set(var_map[k.to_s], v) unless var_map[k.to_s].nil? }
|
13
|
+
@links = vocab_hash['links'].reject(&:nil?).map { |l| NexosisApi::Link.new(l) }
|
14
|
+
end
|
15
|
+
|
16
|
+
# unique identifier for this vocabulary
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :vocabulary_id
|
19
|
+
|
20
|
+
# datasource which contained the text column the vocabulary was built from
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :datasource_name
|
23
|
+
|
24
|
+
# text-based column name from the datasource
|
25
|
+
# @return [String]
|
26
|
+
attr_reader :column_name
|
27
|
+
|
28
|
+
# determines if data source was dataSet, View, or other
|
29
|
+
# @return [String]
|
30
|
+
attr_reader :datasource_type
|
31
|
+
|
32
|
+
# The date on which the vocabulary was created
|
33
|
+
# @return [DateTime]
|
34
|
+
attr_reader :created_on
|
35
|
+
|
36
|
+
# The unique id of the session for which this vocabulary was built.
|
37
|
+
# @reutn [String]
|
38
|
+
attr_reader :created_by_session
|
39
|
+
|
40
|
+
# hypermedia related to this vocabulary
|
41
|
+
# @return [Arrays]
|
42
|
+
attr_reader :links
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module NexosisApi
|
2
|
+
# parse results of a single word entry in a vocabulary
|
3
|
+
# @since 2.2.0
|
4
|
+
class VocabularyWord
|
5
|
+
def initialize(word_hash)
|
6
|
+
word_hash.each { |k, v| instance_variable_set("@#{k}", v) }
|
7
|
+
end
|
8
|
+
|
9
|
+
# The actual word or word pair
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :text
|
12
|
+
|
13
|
+
# Either word or stopWord
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :type
|
16
|
+
|
17
|
+
# For words the rank or relative importance of the word in predictions. Nil for stop words.
|
18
|
+
# @return [Integer]
|
19
|
+
attr_reader :rank
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/nexosisapi.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
spec.required_ruby_version = '>= 2.0.0'
|
18
18
|
spec.summary = "Ruby client for working with the Nexosis API"
|
19
|
-
spec.version = '2.
|
19
|
+
spec.version = '2.2.0'
|
20
20
|
spec.metadata["yard.run"] = "yri"
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexosis_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexosis,Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/nexosis_api/client/models.rb
|
60
60
|
- lib/nexosis_api/client/sessions.rb
|
61
61
|
- lib/nexosis_api/client/views.rb
|
62
|
+
- lib/nexosis_api/client/vocabulary.rb
|
62
63
|
- lib/nexosis_api/column.rb
|
63
64
|
- lib/nexosis_api/column_options.rb
|
64
65
|
- lib/nexosis_api/column_role.rb
|
@@ -85,6 +86,8 @@ files:
|
|
85
86
|
- lib/nexosis_api/time_interval.rb
|
86
87
|
- lib/nexosis_api/view_data.rb
|
87
88
|
- lib/nexosis_api/view_definition.rb
|
89
|
+
- lib/nexosis_api/vocabulary_summary.rb
|
90
|
+
- lib/nexosis_api/vocabulary_word.rb
|
88
91
|
- nexosisapi.gemspec
|
89
92
|
homepage: https://github.com/nexosis/nexosisclient-rb
|
90
93
|
licenses:
|