stanford_corenlp_xml_adapter 0.6.0 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8427fa06dc8162c52eb201ffd3f4c4a323a488e
4
- data.tar.gz: c5b810a37514b5a38edfda4bfa5a25257b9888e0
3
+ metadata.gz: e550911f0774a1b4b630f926ad15c86d24f8e95d
4
+ data.tar.gz: 6cf0bfebb9415a1424a80269536b9cd4bd77d640
5
5
  SHA512:
6
- metadata.gz: 408f7fb837a21eeab9c2e827c02e0f1d67ed2cd93f770f09608b0795a849230bbcd3c62dfa42412ea7a4f60cc3bb1207b07460cf7105a5f1a13d9e818989a94d
7
- data.tar.gz: b077cd4a3bbd7188bff45b75f04ad842755cbbe6de46a708cce5b9466e9479480b7da65fa252d7214a57318509a33282188520442be2bed74bf5ae698cb44bcc
6
+ metadata.gz: f217242382efac2820c0c0642665ca3b878487fc608509d1547173a10d03c88d411cfd12c11b897cfe9028bbf830e288337536d46605fa6fffa25746204b3eee
7
+ data.tar.gz: fd9b7ed307e6c8e4ab6cec52bc4f256c35037b69abd67f9105d8538d9f54d6d2ca3e6352fafd6034f260f72d7ef2e99123fc0b033a5af16ad03d4648b9f7b06a
@@ -1,66 +1,67 @@
1
1
  module DependencyParse
2
- def basic_dependencies doc, sentence_index
3
- dependencies_for_type doc, sentence_index, 'basic-dependencies'
2
+ def basic_dependencies(doc, sentence_index)
3
+ dependencies_for_type doc, sentence_index, "basic-dependencies"
4
4
  end
5
5
 
6
- def collapsed_dependencies doc, sentence_index
7
- dependencies_for_type doc, sentence_index, 'collapsed-dependencies'
6
+ def collapsed_dependencies(doc, sentence_index)
7
+ dependencies_for_type doc, sentence_index, "collapsed-dependencies"
8
8
  end
9
9
 
10
- def collapsed_ccprocessed_dependencies doc, sentence_index
11
- dependencies_for_type doc, sentence_index, 'collapsed-ccprocessed-dependencies'
10
+ def collapsed_ccprocessed_dependencies(doc, sentence_index)
11
+ dependencies_for_type doc, sentence_index, "collapsed-ccprocessed-dependencies"
12
12
  end
13
13
 
14
- def enhanced_dependencies doc, sentence_index
15
- dependencies_for_type doc, sentence_index, 'enhanced-dependencies'
14
+ def enhanced_dependencies(doc, sentence_index)
15
+ dependencies_for_type doc, sentence_index, "enhanced-dependencies"
16
16
  end
17
17
 
18
- def enhanced_plus_plus_dependencies doc, sentence_index
19
- dependencies_for_type doc, sentence_index, 'enhanced-plus-plus-dependencies'
18
+ def enhanced_plus_plus_dependencies(doc, sentence_index)
19
+ dependencies_for_type doc, sentence_index, "enhanced-plus-plus-dependencies"
20
20
  end
21
21
 
22
- def dependencies_for_type doc, sentence_index, type
22
+ def dependencies_for_type(doc, sentence_index, type)
23
23
  sentence = doc.sentences[sentence_index]
24
24
  sentence_tokens = sentence.tokens
25
25
  dependency_parse_nok_to_blob(
26
26
  sentence.xpath(".//dependencies[@type=\"#{type}\"]"),
27
- sentence_tokens.map{|t| t.pos.text},
28
- sentence_tokens.map{|t| t.ner.text},
27
+ sentence_tokens.map { |t| t.pos.text },
28
+ sentence_tokens.map { |t| t.ner.text },
29
29
  )
30
30
  end
31
31
 
32
- def dependency_parse_nok_to_blob dep_parse_input, pos_tags_input, ner_tags_input
32
+ def dependency_parse_nok_to_blob(dep_parse_input, pos_tags_input, ner_tags_input)
33
33
  dep_parse_input
34
- .children
35
- .select{|dep| dep.name == 'dep'}
36
- .each_with_index
37
- .map{|dep| dependency_nok_to_blob(dep, pos_tags_input, ner_tags_input)}
34
+ .children
35
+ .select { |dep| dep.name == "dep" }
36
+ .each_with_index
37
+ .map { |dep| dependency_nok_to_blob(dep, pos_tags_input, ner_tags_input) }
38
38
  end
39
39
 
40
- def dependency_nok_to_blob dep_parse_input, pos_tags_input, ner_tags_input
40
+ def dependency_nok_to_blob(dep_parse_input, pos_tags_input, ner_tags_input)
41
41
  {
42
- type: dep_parse_input.attributes['type'].value,
42
+ type: dep_parse_input.attributes["type"].value,
43
+ extra: dep_parse_input.attributes["extra"] ? dep_parse_input.attributes["extra"].value : nil,
43
44
  governor: dependency_slice_nok_to_blob(
44
- 'governor', dep_parse_input, pos_tags_input, ner_tags_input
45
+ "governor", dep_parse_input, pos_tags_input, ner_tags_input
45
46
  ),
46
47
  dependent: dependency_slice_nok_to_blob(
47
- 'dependent', dep_parse_input, pos_tags_input, ner_tags_input
48
- )
48
+ "dependent", dep_parse_input, pos_tags_input, ner_tags_input
49
+ ),
49
50
  }
50
51
  end
51
52
 
52
- def dependency_slice_nok_to_blob name, dep_parse_input, pos_tags_input, ner_tags_input
53
+ def dependency_slice_nok_to_blob(name, dep_parse_input, pos_tags_input, ner_tags_input)
53
54
  dep = dep_parse_input.children
54
- .select{|dep| dep.name == name}
55
+ .select { |dep| dep.name == name }
55
56
  .first
56
- idx = dep.attributes['idx'].value.to_i
57
+ idx = dep.attributes["idx"].value.to_i
57
58
  pos = idx > 0 ? pos_tags_input[idx - 1] : nil
58
- ner = idx > 0 && ner_tags_input[idx - 1] != 'O' ? ner_tags_input[idx - 1] : nil
59
+ ner = idx > 0 && ner_tags_input[idx - 1] != "O" ? ner_tags_input[idx - 1] : nil
59
60
  {
60
61
  idx: idx,
61
62
  value: dep.text,
62
63
  pos: pos,
63
- ner: ner
64
+ ner: ner,
64
65
  }
65
66
  end
66
- end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module StanfordCorenlpXmlAdapter
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford_corenlp_xml_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - joshweir
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-23 00:00:00.000000000 Z
11
+ date: 2019-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler