Class: Corenlp::Sentence
- Inherits:
-
Object
- Object
- Corenlp::Sentence
- Defined in:
- lib/corenlp/sentence.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#parse_tree_raw ⇒ Object
Returns the value of attribute parse_tree_raw.
-
#token_dependencies ⇒ Object
Returns the value of attribute token_dependencies.
-
#tokens ⇒ Object
Returns the value of attribute tokens.
Instance Method Summary collapse
- #get_dependency_token_by_index(index) ⇒ Object
- #governor_dependencies(token) ⇒ Object
-
#initialize(attrs = {}) ⇒ Sentence
constructor
A new instance of Sentence.
- #next_token(token) ⇒ Object
- #previous_token(token) ⇒ Object
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
#index ⇒ Object
Returns the value of attribute index.
3 4 5 |
# File 'lib/corenlp/sentence.rb', line 3 def index @index end |
#parse_tree_raw ⇒ Object
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_dependencies ⇒ Object
Returns the value of attribute token_dependencies.
3 4 5 |
# File 'lib/corenlp/sentence.rb', line 3 def token_dependencies @token_dependencies end |
#tokens ⇒ Object
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 |