Sha256: 711a6ade8db4e4df689a6570ca083d7701f876b8a271e71ddad2762e7ceaa9de
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'rbbt/text/segment' require 'rbbt/entity' module NamedEntity extend Entity include Segment self.annotation :type, :code, :score def report <<-EOF String: #{ self } Offset: #{ offset.inspect } Type: #{type.inspect} Code: #{code.inspect} Score: #{score.inspect} EOF end def html text = <<-EOF <span class='Entity'\ #{type.nil? ? "" : " attr-entity-type='#{Array === type ? type * " " : 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 def entity(params = nil) format, entity = code.split(":") entity, format = format, nil if entity.nil? if defined?(Entity) && 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rbbt-text-1.1.9 | lib/rbbt/text/segment/named_entity.rb |