Module: NamedEntity
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
|
#html ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rbbt/segment/named_entity.rb', line 21
def html
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}'"}\
>#{ self }</span>
EOF
text.chomp
end
|
#report ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/rbbt/segment/named_entity.rb', line 11
def report
<<-EOF
String: #{ self }
Offset: #{ offset.inspect }
Type: #{entity_type.inspect}
Code: #{code.inspect}
Score: #{score.inspect}
EOF
end
|