Module: NamedEntity

Extended by:
Entity
Includes:
Segment, SegmentAnnotation
Defined in:
lib/rbbt/segment/named_entity.rb

Instance Method Summary collapse

Methods included from Segment

align, ascii, bad_chars, clean_sort, #eend, index, overlaps, #range, relocate, #segment_length, sort, split

Methods included from SegmentRanges

collisions, #includes?, #make_relative, #overlaps, #overlaps?, #pull, #push, #range_in

Instance Method Details

#entity(params = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rbbt/segment/named_entity.rb', line 40

def entity(params = nil)
  code = self.code || self.dup
  format, entity = code.split(":")
  entity, format = format, nil if entity.nil?

  if defined?(Entity) && Entity.formats.include?(entity_type) or Entity.formats.include?(format)
    params ||= {}
    params[:format] = format if format and params[:format].nil?
    mod = (Entity.formats[entity_type] || Entity.format[entity])
    mod.setup(entity, params)
  end

  entity
end

#entity_typeObject



11
12
13
# File 'lib/rbbt/segment/named_entity.rb', line 11

def entity_type
  annotation_values[:entity_type] || annotation_values[:type]
end

#htmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rbbt/segment/named_entity.rb', line 25

def html
  title = code.nil? ? entity_type : [entity_type, code].compact * " - "

  text = <<-EOF
<span class='Entity'\
#{entity_type.nil? ? "" : " attr-entity-type='#{Array === entity_type ? entity_type * " " : entity_type}'"}\
#{code.nil?  ? "" : " attr-entity-code='#{Array === code ? code * " " : code}'"}\
#{score.nil? ? "" : " attr-entity-score='#{Array === score ? score * " " : score}'"}\
#{segid.nil? ? "" : " attr-segid='#{segid}'"}\
#{title.nil? ? "" : " title='#{Array === title ? title * " " : title}'"}\
>#{ self }</span>
  EOF
  text.chomp
end

#reportObject



15
16
17
18
19
20
21
22
23
# File 'lib/rbbt/segment/named_entity.rb', line 15

def report
  <<-EOF
String: #{ self }
Offset: #{ offset.inspect }
Type: #{entity_type.inspect}
Code: #{code.inspect}
Score: #{score.inspect}
  EOF
end