Sha256: de283804a619de08a2149697314b16b946cd2fe78807a6e0998da9a819345781

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

module RSemantic
  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

1 entries across 1 versions & 1 rubygems

Version Path
rsemantic-0.3.0 lib/rsemantic/document.rb