class RosetteAPI
This class allows you to access all Rosette API endpoints.
Constants
- ADDRESS_SIMILARITY_ENDPOINT
Rosette API address-similarity endpoint
- BINDING_VERSION
Version of Ruby binding
- CATEGORIES_ENDPOINT
Rosette API categories endpoint
- ENTITIES_ENDPOINT
Rosette API entities endpoint
- INFO
Rosette API info endpoint
- LANGUAGE_ENDPOINT
Rosette API language endpoint
- MORPHOLOGY_ENDPOINT
Rosette API morphology endpoint
- NAME_DEDUPLICATION_ENDPOINT
Name Deduplication endpoint
- NAME_SIMILARITY_ENDPOINT
Rosette API name-similarity endpoint
- NAME_TRANSLATION_ENDPOINT
Rosette API name-translation endpoint
- PING
Rosette API ping endpoint
- RELATIONSHIPS_ENDPOINT
Rosette API relationships endpoint
- SEMANTIC_VECTORS
Semantic Vectors endpoint (replaces /text-embedding)
- SENTENCES_ENDPOINT
Rosette API sentences endpoint
- SENTIMENT_ENDPOINT
Rosette API sentiment endpoint
- SIMILAR_TERMS_ENDPOINT
Similar Terms endpoint
- SYNTACTIC_DEPENDENCIES_ENDPOINT
Syntactic Dependencies endpoint
- TEXT_EMBEDDING
Text Embedding endpoint (deprecated)
- TOKENS_ENDPOINT
Rosette API tokens endpoint
- TOPICS_ENDPOINT
Topics endpoint
- TRANSLITERATION_ENDPOINT
Transliteration endpoint
Attributes
Alternate Rosette API URL
custom Rosette API headers
URL query parameter(s)
Rosette API key
Public Class Methods
# File rosette_api.rb, line 68 def initialize(user_key, alternate_url = 'https://api.rosette.com/rest/v1') @log = Logger.new($stdout) @user_key = user_key @alternate_url = alternate_url @url_parameters = nil @alternate_url = alternate_url.to_s.slice(0..-2) if @alternate_url.to_s.end_with?('/') uri = URI.parse alternate_url @http_client = Net::HTTP.new uri.host, uri.port @http_client.use_ssl = uri.scheme == 'https' end
Public Instance Methods
Compares two addresses and returns a match score from 0 to 1.
Attributes¶ ↑
-
params
-AddressSimilarityParameters
helps to build the request body inRequestBuilder
.
Returns the confidence score of matching 2 addresses.
# File rosette_api.rb, line 341 def get_address_similarity(params) check_params params, 'Expects a AddressSimilarityParameters type as an argument', AddressSimilarityParameters params = params.load_params RequestBuilder.new(@user_key, @alternate_url + ADDRESS_SIMILARITY_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts Tier 1 contextual categories from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns the contextual categories identified in the input.
# File rosette_api.rb, line 226 def get_categories(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + CATEGORIES_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts compound-components from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of components for each compound word of the input for supported languages.
# File rosette_api.rb, line 129 def get_compound_components(params) check_params params params = params.load_params endpoint = "#{MORPHOLOGY_ENDPOINT}/compound-components" RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts entities from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns each entity extracted from the input.
# File rosette_api.rb, line 207 def get_entities(params) check_params params params = params.load_params endpoint = ENTITIES_ENDPOINT RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts Han-readings from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of Han-readings which provide pronunciation information for Han script, in both Chinese and Japanese input text.
# File rosette_api.rb, line 149 def get_han_readings(params) check_params params params = params.load_params endpoint = "#{MORPHOLOGY_ENDPOINT}/han-readings" RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Identifies in which language(s) the input is written.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of candidate languages in order of descending confidence.
# File rosette_api.rb, line 89 def get_language(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + LANGUAGE_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts lemmas from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of lemmas for each token of the input for supported languages.
# File rosette_api.rb, line 168 def get_lemmas(params) check_params params params = params.load_params endpoint = "#{MORPHOLOGY_ENDPOINT}/lemmas" RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts parts-of-speech, lemmas (dictionary form), compound components, and Han-readings for each token in the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns the lemmas, compound components, Han-readings, and parts-of-speech tags of the input for supported languages.
# File rosette_api.rb, line 109 def get_morphology_complete(params) check_params params params = params.load_params endpoint = "#{MORPHOLOGY_ENDPOINT}/complete" RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
De-duplicates a list of names.
Attributes¶ ↑
-
params
-NameDeduplicationParameters
helps to build the request body inRequestBuilder
.
Returns the list of deduplicated names.
# File rosette_api.rb, line 280 def get_name_deduplication(params) check_params params, 'Expects a NameDeduplicationParameters type as an argument', NameDeduplicationParameters params = params.load_params RequestBuilder.new(@user_key, @alternate_url + NAME_DEDUPLICATION_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Compares two entity names (person, location, or organization) and returns a match score from 0 to 1.
Attributes¶ ↑
-
params
-NameSimilarityParameters
helps to build the request body inRequestBuilder
.
Returns the confidence score of matching 2 names.
# File rosette_api.rb, line 321 def get_name_similarity(params) check_params params, 'Expects a NameSimilarityParameters type as an argument', NameSimilarityParameters params = params.load_params RequestBuilder.new(@user_key, @alternate_url + NAME_SIMILARITY_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Translates a given name to a supported specified language.
Attributes¶ ↑
-
params
-NameTranslationParameters
helps to build the request body inRequestBuilder
.
Returns the translation of a name.
# File rosette_api.rb, line 300 def get_name_translation(params) check_params params, 'Expects a NameTranslationParameters type as an argument', NameTranslationParameters params = params.load_params RequestBuilder.new(@user_key, @alternate_url + NAME_TRANSLATION_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts parts-of-speech from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of part-of-speech (POS) tags for each of the words of the input, depending on the context of how it is used.
# File rosette_api.rb, line 188 def get_parts_of_speech(params) check_params params params = params.load_params endpoint = "#{MORPHOLOGY_ENDPOINT}/parts-of-speech" RequestBuilder.new(@user_key, @alternate_url + endpoint, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Extracts relationships from the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns each relationship extracted from the input.
# File rosette_api.rb, line 244 def get_relationships(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + RELATIONSHIPS_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Returns the vectors associated with the text
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns the text embedding representation of the input.
# File rosette_api.rb, line 419 def get_semantic_vectors(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + SEMANTIC_VECTORS, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Divides the input into sentences.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of linguistic sentences of the input.
# File rosette_api.rb, line 379 def get_sentences(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + SENTENCES_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Analyzes the positive and negative sentiment expressed by the input.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns sentiment analysis results.
# File rosette_api.rb, line 262 def get_sentiment(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + SENTIMENT_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Returns the terms similar to the input
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns a mapping of languageCode to similar terms
# File rosette_api.rb, line 494 def get_similar_terms(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + SIMILAR_TERMS_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Returns the syntactic structure of the text
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of linguistic sentences of the input.
# File rosette_api.rb, line 436 def get_syntax_dependencies(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + SYNTACTIC_DEPENDENCIES_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Returns the vectors associated with the text
Deprecated. Please use ‘get_semantic_vectors` instead
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns the text embedding representation of the input.
# File rosette_api.rb, line 400 def get_text_embedding(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + TEXT_EMBEDDING, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Divides the input into tokens.
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of tokens of the input.
# File rosette_api.rb, line 361 def get_tokens(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + TOKENS_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Divides the input into topics (key phrases and concepts).
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns list of topics of the input.
# File rosette_api.rb, line 476 def get_topics(params) check_params params params = params.load_params RequestBuilder.new(@user_key, @alternate_url + TOPICS_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Returns the transliteration of the content
Attributes¶ ↑
-
params
-DocumentParameters
helps to build the request body inRequestBuilder
.
Returns the transliteration of the input.
# File rosette_api.rb, line 456 def get_transliteration(params) check_params params, 'Expects a DocumentParameters type as an argument', DocumentParameters params = params.load_params RequestBuilder.new(@user_key, @alternate_url + TRANSLITERATION_ENDPOINT, @http_client, BINDING_VERSION, params, @url_parameters) .send_post_request end
Gets information about the Rosette API, returns name, build number and build time.
# File rosette_api.rb, line 506 def info RequestBuilder.new(@user_key, @alternate_url + INFO, @http_client, BINDING_VERSION, @url_parameters) .send_get_request end
Pings the Rosette API for a response indicting that the service is available.
# File rosette_api.rb, line 514 def ping RequestBuilder.new(@user_key, @alternate_url + PING, @http_client, BINDING_VERSION, @url_parameters) .send_get_request end
Gets the User-Agent string
# File rosette_api.rb, line 521 def user_agent RequestBuilder.new(@user_key, @alternate_url + PING, @http_client, BINDING_VERSION, @url_parameters).user_agent end