Class: RSemantic::Document
- Inherits:
-
Object
- Object
- RSemantic::Document
- Defined in:
- lib/rsemantic/document.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#corpora ⇒ Object
readonly
Returns the value of attribute corpora.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(text, attributes = {}) ⇒ Document
constructor
A new instance of Document.
- #keywords(num = 5) ⇒ Object
- #related ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text, attributes = {}) ⇒ Document
Returns a new instance of Document.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rsemantic/document.rb', line 6 def initialize(text, attributes = {}) if text.respond_to?(:read) @text = text.read else @text = text end @attributes = attributes @corpora = [] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/rsemantic/document.rb', line 4 def attributes @attributes end |
#corpora ⇒ Object (readonly)
Returns the value of attribute corpora.
5 6 7 |
# File 'lib/rsemantic/document.rb', line 5 def corpora @corpora end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/rsemantic/document.rb', line 3 def text @text end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/rsemantic/document.rb', line 21 def [](key) @attributes[key] end |
#keywords(num = 5) ⇒ Object
35 36 37 |
# File 'lib/rsemantic/document.rb', line 35 def keywords(num = 5) end |
#related ⇒ Object
TODO:
document that it has to be part of at least one corpus
26 27 28 29 30 31 32 33 |
# File 'lib/rsemantic/document.rb', line 26 def results = {} @corpora.each do |corpus| results[corpus] = corpus.(self) end results end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/rsemantic/document.rb', line 17 def to_s "#<%s @attributes=%s>" % [self.class.name, @attributes.inspect] end |