Class: TextRazor::Client
- Inherits:
-
Object
- Object
- TextRazor::Client
- Defined in:
- lib/textrazor/client.rb
Constant Summary collapse
- EmptyApiKey =
Class.new(StandardError)
- EmptyText =
Class.new(StandardError)
- TextTooLong =
Class.new(StandardError)
- UnsupportedExtractor =
Class.new(StandardError)
- UnsupportedCleanupMode =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#request_options ⇒ Object
readonly
Returns the value of attribute request_options.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
- .categories(api_key, text, options = {}) ⇒ Object
- .coarse_topics(api_key, text, options = {}) ⇒ Object
- .entities(api_key, text, options = {}) ⇒ Object
- .phrases(api_key, text, options = {}) ⇒ Object
- .topics(api_key, text, options = {}) ⇒ Object
- .words(api_key, text, options = {}) ⇒ Object
Instance Method Summary collapse
- #analyse(text) ⇒ Object
-
#initialize(api_key, options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key, options = {}) ⇒ Client
Returns a new instance of Client.
26 27 28 29 |
# File 'lib/textrazor/client.rb', line 26 def initialize(api_key, = {}) assign_api_key(api_key) () end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
22 23 24 |
# File 'lib/textrazor/client.rb', line 22 def api_key @api_key end |
#request_options ⇒ Object (readonly)
Returns the value of attribute request_options.
22 23 24 |
# File 'lib/textrazor/client.rb', line 22 def @request_options end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
22 23 24 |
# File 'lib/textrazor/client.rb', line 22 def response @response end |
Class Method Details
.categories(api_key, text, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/textrazor/client.rb', line 46 def self.categories(api_key, text, = {}) new(api_key, .merge(classifiers: ['textrazor_iab'])). analyse(text). categories end |
.coarse_topics(api_key, text, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/textrazor/client.rb', line 52 def self.coarse_topics(api_key, text, = {}) new(api_key, .merge(extractors: ['topics'])). analyse(text). coarse_topics end |
.entities(api_key, text, options = {}) ⇒ Object
58 59 60 61 62 |
# File 'lib/textrazor/client.rb', line 58 def self.entities(api_key, text, = {}) new(api_key, .merge(extractors: ['entities'])). analyse(text). entities end |
.phrases(api_key, text, options = {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/textrazor/client.rb', line 70 def self.phrases(api_key, text, = {}) new(api_key, .merge(extractors: ['phrases', 'words'])). analyse(text). phrases end |
.topics(api_key, text, options = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/textrazor/client.rb', line 40 def self.topics(api_key, text, = {}) new(api_key, .merge(extractors: ['topics'])). analyse(text). topics end |
.words(api_key, text, options = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/textrazor/client.rb', line 64 def self.words(api_key, text, = {}) new(api_key, .merge(extractors: ['words'])). analyse(text). entities end |