Module: NamedEntity

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

Instance Method Summary collapse

Methods included from Segment

align, clean_sort, #end, #includes?, index, load_tsv, load_tsv_values, #make_relative, #offset=, overlaps, #pull, #push, #range, #range_in, #segment_length, set_tsv_fields, sort, split, tsv, tsv_values_for_segment

Instance Method Details

#entity(params = nil) ⇒ Object



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

def entity(params = nil)
  format, entity = code.split(":")
  entity, format = format, nil if entity.nil?
  
  if defined? Entity and Entity.formats.include? type or Entity.formats.include? format
    params ||= {}
    params[:format] = format if format and params[:format].nil?
    mod = (Entity.formats[type] || Entity.format[entity])
    mod.setup(entity, params)
  end

  entity
end

#htmlObject



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

def html
  text = "<span class='Entity'\\\n\#{type.nil? ? \"\" : \" attr-entity-type='\#{Array === type ? type * \" \" : 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



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

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