Class: LinkParser::Sentence
- Extended by:
- Forwardable
- Defined in:
- lib/linkparser/sentence.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
the definitions in this sentence.
-
#linkages ⇒ Object
the linkages of this sentence.
-
#names ⇒ Object
the words in this sentence.
Instance Method Summary collapse
-
#initialize ⇒ Sentence
constructor
initializes a new Sentence object.
- #object ⇒ Object
- #sentence? ⇒ Boolean
- #subject ⇒ Object
- #to_str ⇒ Object
- #verb ⇒ Object
Constructor Details
#initialize ⇒ Sentence
initializes a new Sentence object
16 17 18 19 20 |
# File 'lib/linkparser/sentence.rb', line 16 def initialize @definitions = [] @linkages = [] @names = [] end |
Instance Attribute Details
#definitions ⇒ Object
the definitions in this sentence
23 24 25 |
# File 'lib/linkparser/sentence.rb', line 23 def definitions @definitions end |
#linkages ⇒ Object
the linkages of this sentence
26 27 28 |
# File 'lib/linkparser/sentence.rb', line 26 def linkages @linkages end |
#names ⇒ Object
the words in this sentence
29 30 31 |
# File 'lib/linkparser/sentence.rb', line 29 def names @names end |
Instance Method Details
#object ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/linkparser/sentence.rb', line 67 def object return nil if @linkages.empty? @linkages.find {|linkage| obj = linkage.connections.find {|conn| conn.name.match(/^O/) } return obj.rword if obj } return nil end |
#sentence? ⇒ Boolean
37 38 39 |
# File 'lib/linkparser/sentence.rb', line 37 def sentence? ! @linkages.empty? end |
#subject ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/linkparser/sentence.rb', line 56 def subject return nil if @linkages.empty? @linkages.find {|linkage| subj = linkage.connections.find {|conn| conn.name.match(/^S/) } return subj.lword if subj } return nil end |
#to_str ⇒ Object
33 34 35 |
# File 'lib/linkparser/sentence.rb', line 33 def to_str @names.join(" ") end |
#verb ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/linkparser/sentence.rb', line 41 def verb return nil if @linkages.empty? @linkages.find {|linkage| vrb = linkage.connections.find {|conn| conn.name.match(/^S/) } return vrb.rword if vrb vrb = linkage.connections.find {|conn| conn.name.match(/^O/) } return vrb.lword if vrb } return nil end |