Class: TextRazor::Entity

Inherits:
Object
  • Object
show all
Extended by:
Util
Defined in:
lib/textrazor/entity.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

standardize

Constructor Details

#initialize(params = {}) ⇒ Entity

Returns a new instance of Entity.



11
12
13
14
15
16
# File 'lib/textrazor/entity.rb', line 11

def initialize(params = {})
  @type = []
  params.each do |k, v|
    instance_variable_set(:"@#{k}", v) if v && self.respond_to?(:"#{k}")
  end
end

Instance Attribute Details

#confidence_scoreObject (readonly)

Returns the value of attribute confidence_score.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def confidence_score
  @confidence_score
end

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def data
  @data
end

#ending_posObject (readonly)

Returns the value of attribute ending_pos.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def ending_pos
  @ending_pos
end

#entity_english_idObject (readonly)

Returns the value of attribute entity_english_id.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def entity_english_id
  @entity_english_id
end

#entity_idObject (readonly)

Returns the value of attribute entity_id.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def entity_id
  @entity_id
end

#freebase_idObject (readonly)

Returns the value of attribute freebase_id.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def freebase_id
  @freebase_id
end

#freebase_typesObject (readonly)

Returns the value of attribute freebase_types.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def freebase_types
  @freebase_types
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def id
  @id
end

#matched_textObject (readonly)

Returns the value of attribute matched_text.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def matched_text
  @matched_text
end

#matching_tokensObject (readonly)

Returns the value of attribute matching_tokens.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def matching_tokens
  @matching_tokens
end

#relevance_scoreObject (readonly)

Returns the value of attribute relevance_score.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def relevance_score
  @relevance_score
end

#starting_posObject (readonly)

Returns the value of attribute starting_pos.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def starting_pos
  @starting_pos
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def type
  @type
end

Returns the value of attribute wiki_link.



7
8
9
# File 'lib/textrazor/entity.rb', line 7

def wiki_link
  @wiki_link
end

Class Method Details

.create_from_hash(params) ⇒ Object



18
19
20
21
# File 'lib/textrazor/entity.rb', line 18

def self.create_from_hash(params)
  params = Hash[params.map {|k, v| [standardize(k), v] }]
  new(params)
end