class NameParameter

This class represents an entity name in Rosette API.

Attributes

entity_type[RW]

Name’s entity type (PERSON, LOCATION, ORGANIZATION) (optional)

language[RW]

ISO 639-3 code of the name’s language (optional)

script[RW]

ISO 15924 code of the name’s script (optional)

text[RW]

Name to be analyzed

Public Instance Methods

load_param() click to toggle source

Converts this class to Hash with its keys in lower CamelCase.

Returns the new Hash.

# File name_parameter.rb, line 29
def load_param
  to_hash
    .select { |_key, value| value }
    .transform_keys { |key| key.to_s.split('_').map(&:capitalize).join.sub!(/\D/, &:downcase) }
end
to_hash() click to toggle source

Converts this class to Hash.

Returns the new Hash.

# File name_parameter.rb, line 38
def to_hash
  {
    entity_type: @entity_type,
    language: @language,
    script: @script,
    text: @text
  }
end

Protected Instance Methods

initialize(text, options = {}) click to toggle source
# File name_parameter.rb, line 14
def initialize(text, options = {}) # :notnew:
  options = {
    entity_type: nil,
    language: nil,
    script: nil
  }.update options
  @text = text
  @entity_type = options[:entity_type]
  @language = options[:language]
  @script = options[:script]
end