Class: SimpleInlineTextAnnotation::EntityTypeCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_inline_text_annotation/entity_type_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ EntityTypeCollection

Returns a new instance of EntityTypeCollection.



5
6
7
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 5

def initialize(source)
  @source = source
end

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 32

def any?
  entity_types.any?
end

#get(label) ⇒ Object

get returns the entity type id for a given label. Example:

get("Person") => "https://example.com/Person"

If the label is not found, it returns nil. Example:

get("NonExistentLabel") => nil


16
17
18
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 16

def get(label)
  entity_types[label]
end

#to_configObject

to_config returns a Array of hashes of each entity type. Example:

[
  {id: "https://example.com/Person", label: "Person"},
  {id: "https://example.com/Organization", label: "Organization"}
]


26
27
28
29
30
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 26

def to_config
  entity_types.map do |label, id|
    { id: id, label: label }
  end
end