Class: Treebank::Sentence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sentence_node) ⇒ Sentence

Returns a new instance of Sentence.



8
9
10
11
12
# File 'lib/treebank/sentence.rb', line 8

def initialize(sentence_node)
  @node = sentence_node
  @last_id = @next_id = last_id
  @elliptic_nodes = {}
end

Instance Attribute Details

#elliptic_nodesObject (readonly)

Returns the value of attribute elliptic_nodes.



6
7
8
# File 'lib/treebank/sentence.rb', line 6

def elliptic_nodes
  @elliptic_nodes
end

Instance Method Details

#add_ellipsis(attrs, string) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/treebank/sentence.rb', line 14

def add_ellipsis(attrs, string)
  id = next_id
  all_attrs = {
    id: id,
    insertion_id: get_insertion_id,
    form: "[#{string}]"
  }.merge(attrs)

  new_node = new_word(all_attrs)
  @elliptic_nodes[string] = id

  @node.add_child(indent)
  @node.add_child(new_node)
  @node.add_child(new_line)
  new_node
end

#ctsifyObject



31
32
33
34
35
36
37
38
39
# File 'lib/treebank/sentence.rb', line 31

def ctsify
  doc_id  = @node['document_id']
  cts_urn = CtsMap.doc_id_to_cts_urn(doc_id)
  return unless cts_urn

  @node['document_id'] = cts_urn
  subdoc = @node['subdoc']
  @node['subdoc'] = subdoc.gsub(/\D/, ' ').split.join('.')
end