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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rbbt/segment/named_entity.rb', line 32

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

#htmlObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/rbbt/segment/named_entity.rb', line 21

def html
  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>\#{ self }</span>\n  EOF\n  text.chomp\nend\n"

#reportObject



11
12
13
14
15
16
17
18
19
# File 'lib/rbbt/segment/named_entity.rb', line 11

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