Class: Datagun::Api::KeywordsExtractor::Client
- Defined in:
- lib/datagun/api/keywords_extractor/client.rb
Overview
Client provides methods to interact with keywords_extractor endpoint
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#analyze(model_id:, text:) ⇒ JSON
Extract top keywords from passed text using your model.
-
#delete(model_id:) ⇒ JSON
Delete a model.
-
#initialize(default_logger: nil, version: Datagun.config.api_version) ⇒ Client
constructor
A new instance of Client.
-
#models ⇒ JSON
Return the list of keywords extractors models.
-
#save_model(name:, features: nil, file:) ⇒ JSON
Store your corpus file.
-
#status(model_id:) ⇒ JSON
Get status for a model_id.
Methods inherited from Base
Constructor Details
#initialize(default_logger: nil, version: Datagun.config.api_version) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 |
# File 'lib/datagun/api/keywords_extractor/client.rb', line 13 def initialize(default_logger: nil, version: Datagun.config.api_version) super(default_logger: default_logger, version: version) base_url = "#{@api_url}/api/#{@version}/keyword_extractor" @client = HttpWrapper.new(base_url: base_url) end |
Instance Method Details
#analyze(model_id:, text:) ⇒ JSON
Extract top keywords from passed text using your model
81 82 83 84 85 86 87 88 |
# File 'lib/datagun/api/keywords_extractor/client.rb', line 81 def analyze(model_id:, text:) client.endpoint = 'analyze' client.payload = { model_id: model_id, text: text } client.get.transform_keys(&:to_sym) end |
#delete(model_id:) ⇒ JSON
Delete a model
68 69 70 71 |
# File 'lib/datagun/api/keywords_extractor/client.rb', line 68 def delete(model_id:) client.endpoint = model_id client.delete.transform_keys(&:to_sym) end |
#models ⇒ JSON
Return the list of keywords extractors models
58 59 60 61 |
# File 'lib/datagun/api/keywords_extractor/client.rb', line 58 def models client.endpoint = 'models' client.get.map { |item| item.transform_keys(&:to_sym) } end |
#save_model(name:, features: nil, file:) ⇒ JSON
Store your corpus file
28 29 30 31 32 33 34 35 36 |
# File 'lib/datagun/api/keywords_extractor/client.rb', line 28 def save_model(name:, features: nil, file:) client.endpoint = 'save_model' client.payload = { model_name: name, file: file } client.payload[:max_features] = features unless features.nil? client.post.transform_keys(&:to_sym) end |
#status(model_id:) ⇒ JSON
Get status for a model_id
45 46 47 48 49 50 51 |
# File 'lib/datagun/api/keywords_extractor/client.rb', line 45 def status(model_id:) client.endpoint = 'status' client.payload = { model_id: model_id } client.get.transform_keys(&:to_sym) end |