Class: LinkParser::Sentence

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/linkparser/sentence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSentence

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

#definitionsObject

the definitions in this sentence



23
24
25
# File 'lib/linkparser/sentence.rb', line 23

def definitions
  @definitions
end

#linkagesObject

the linkages of this sentence



26
27
28
# File 'lib/linkparser/sentence.rb', line 26

def linkages
  @linkages
end

#namesObject

the words in this sentence



29
30
31
# File 'lib/linkparser/sentence.rb', line 29

def names
  @names
end

Instance Method Details

#objectObject



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

Returns:

  • (Boolean)


37
38
39
# File 'lib/linkparser/sentence.rb', line 37

def sentence? 
	! @linkages.empty?
end

#subjectObject



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_strObject



33
34
35
# File 'lib/linkparser/sentence.rb', line 33

def to_str 
	@names.join(" ")
end

#verbObject



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