Class: Corenlp::Sentence

Inherits:
Object
  • Object
show all
Defined in:
lib/corenlp/sentence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Sentence

Returns a new instance of Sentence.



5
6
7
8
9
10
# File 'lib/corenlp/sentence.rb', line 5

def initialize(attrs = {})
  @index = attrs[:index]
  @tokens = []
  @token_dependencies = []
  @parse_tree_raw = ''
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



3
4
5
# File 'lib/corenlp/sentence.rb', line 3

def index
  @index
end

#parse_tree_rawObject

Returns the value of attribute parse_tree_raw.



3
4
5
# File 'lib/corenlp/sentence.rb', line 3

def parse_tree_raw
  @parse_tree_raw
end

#token_dependenciesObject

Returns the value of attribute token_dependencies.



3
4
5
# File 'lib/corenlp/sentence.rb', line 3

def token_dependencies
  @token_dependencies
end

#tokensObject

Returns the value of attribute tokens.



3
4
5
# File 'lib/corenlp/sentence.rb', line 3

def tokens
  @tokens
end

Instance Method Details

#get_dependency_token_by_index(index) ⇒ Object



24
25
26
# File 'lib/corenlp/sentence.rb', line 24

def get_dependency_token_by_index(index)
  tokens.detect{|t| t.index == index}
end

#governor_dependencies(token) ⇒ Object



12
13
14
# File 'lib/corenlp/sentence.rb', line 12

def governor_dependencies(token)
  token_dependencies.select{|td| td.governor == token}
end

#next_token(token) ⇒ Object



16
17
18
# File 'lib/corenlp/sentence.rb', line 16

def next_token(token)
  tokens.sort_by(&:index).detect{|t| t.index > token.index}
end

#previous_token(token) ⇒ Object



20
21
22
# File 'lib/corenlp/sentence.rb', line 20

def previous_token(token)
  tokens.sort_by(&:index).reverse.detect{|t| t.index < token.index}
end