Sha256: 1a1fcf11f4883f407b6dd4f05636e0786acba6b0c10ba38619db86c5506e4100

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

module Semantic
  class Document
    attr_reader :text
    attr_reader :attributes
    attr_reader :corpora
    def initialize(text, attributes = {})
      if text.respond_to?(:read)
        @text = text.read
      else
        @text = text
      end

      @attributes = attributes
      @corpora    = []
    end

    def to_s
      "#<%s @attributes=%s>" % [self.class.name, @attributes.inspect]
    end

    def [](key)
      @attributes[key]
    end

    # @todo document that it has to be part of at least one corpus
    def related
      results = {}
      @corpora.each do |corpus|
        results[corpus] = corpus.find_related_document(self)
      end

      results
    end

    def keywords(num = 5)

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rsemantic-0.2.1 lib/semantic/document.rb
rsemantic-0.2.0 lib/semantic/document.rb
rsemantic-0.1.4 lib/semantic/document.rb