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, collisions, #eend, #includes?, index, #make_relative, overlaps, #overlaps, #overlaps?, #pull, #push, #range, #range_in, #segment_length, sort, split

Instance Method Details

#entity(params = nil) ⇒ Object



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

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
# File 'lib/rbbt/segment/named_entity.rb', line 25

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

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

#reportObject



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

def report
  "String: \#{ self }\nOffset: \#{ offset.inspect }\nType: \#{entity_type.inspect}\nCode: \#{code.inspect}\nScore: \#{score.inspect}\n  EOF\nend\n"