Sha256: 925e11135ae2fee30ee5bbd730ac41d3333b538d5e05f35b1d4038ecd3eb8ca3

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

require 'rbbt/ner/annotations'

module NamedEntity 
  attr_accessor :type, :code, :score, :segment_types
  include Segment

  def self.annotate(string, offset = nil, type = nil, code = nil, score = nil)
    string.extend NamedEntity
    string.offset = offset unless offset.nil?
    string.type  = type unless type.nil?
    string.code  = code unless code.nil?
    string.score = score unless score.nil?
    string
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbbt-text-0.5.0 lib/rbbt/ner/annotations/named_entity.rb