stanford_corenlp_xml_adapter 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d69c2dce1695642753623b33a96043d6a016568a
4
- data.tar.gz: 46c31da9aac985cd9b44baa0caea8dbaef5f3606
3
+ metadata.gz: f8427fa06dc8162c52eb201ffd3f4c4a323a488e
4
+ data.tar.gz: c5b810a37514b5a38edfda4bfa5a25257b9888e0
5
5
  SHA512:
6
- metadata.gz: a48091dddb26039bda934f8736b2bb3d0ff2274073e341c9034e660ed9791127f3f65b157b0e8175fb7f71105e208893cf37ea3eddcd922c37143a27c9b954b5
7
- data.tar.gz: fd6135d6b659e31d4c5296e7b0b145929e3855bc03d3ea47a85b810b31080a85721b0eeee53bd0f71a1a9d6c4ee761dd504c9e7a0cc453662b5da1a22776ffea
6
+ metadata.gz: 408f7fb837a21eeab9c2e827c02e0f1d67ed2cd93f770f09608b0795a849230bbcd3c62dfa42412ea7a4f60cc3bb1207b07460cf7105a5f1a13d9e818989a94d
7
+ data.tar.gz: b077cd4a3bbd7188bff45b75f04ad842755cbbe6de46a708cce5b9466e9479480b7da65fa252d7214a57318509a33282188520442be2bed74bf5ae698cb44bcc
data/bin/bump-version CHANGED
@@ -1 +1 @@
1
- gem bump --version minor --remote --release
1
+ docker-compose run --rm --service-ports web /bin/bash -c "gem bump --version minor --release --tag"
@@ -3,49 +3,56 @@ module Coreference
3
3
  self.xpath("//coreference//coreference").map{|c| coref_nok_to_blob(c)}
4
4
  end
5
5
 
6
- def coref_nok_to_blob input
6
+ def coreferences_with_pos
7
+ self.xpath("//coreference//coreference").map{|c| coref_nok_to_blob(c, true)}
8
+ end
9
+
10
+ def coref_nok_to_blob input, with_pos_tags=nil
7
11
  {
8
- representative: coref_representative_nok_to_blob(input),
9
- mentions: coref_mentions_nok_to_blob(input)
12
+ representative: coref_representative_nok_to_blob(input, with_pos_tags),
13
+ mentions: coref_mentions_nok_to_blob(input, with_pos_tags)
10
14
  }
11
15
  end
12
16
 
13
- def coref_representative_nok_to_blob input
17
+ def coref_representative_nok_to_blob input, with_pos_tags=nil
14
18
  coref_mention_nok_to_blob(
15
19
  input
16
20
  .children
17
21
  .select{|m|
18
22
  m.name == 'mention' && m.attributes['representative']
19
23
  }
20
- .first
24
+ .first,
25
+ false,
26
+ with_pos_tags
21
27
  )
22
28
  end
23
29
 
24
- def coref_mentions_nok_to_blob input
30
+ def coref_mentions_nok_to_blob input, with_pos_tags=nil
25
31
  input
26
32
  .children
27
33
  .select{|m|
28
34
  m.name == 'mention'
29
35
  }
30
- .map{|m| coref_mention_nok_to_blob(m, true)}
36
+ .map{|m| coref_mention_nok_to_blob(m, true, with_pos_tags)}
31
37
  end
32
38
 
33
- def coref_mention_nok_to_blob input, add_representative_flag=nil
39
+ def coref_mention_nok_to_blob input, add_representative_flag=nil, with_pos_tags=nil
34
40
  add_representative_flag ?
35
41
  with_representative_flag(
36
- coref_mention(input),
42
+ coref_mention(input, with_pos_tags),
37
43
  input
38
44
  ) :
39
- coref_mention(input)
45
+ coref_mention(input, with_pos_tags)
40
46
  end
41
47
 
42
- def coref_mention input
43
- Hash[
48
+ def coref_mention input, with_pos_tags=nil
49
+ coref_blob = Hash[
44
50
  input
45
51
  .children
46
52
  .select{|v| v.class == Nokogiri::XML::Element}
47
53
  .map{|v| [v.name.to_sym, to_i_based_on_field_name(v.text, v.name)]}
48
54
  ]
55
+ with_pos_tags ? add_pos_tags_to(coref_blob) : coref_blob
49
56
  end
50
57
 
51
58
  def with_representative_flag input, parent
@@ -56,4 +63,15 @@ module Coreference
56
63
  def to_i_based_on_field_name input, field_name
57
64
  field_name == 'text' ? input : input.to_i
58
65
  end
66
+
67
+ def add_pos_tags_to coref_blob
68
+ coref_blob.merge({
69
+ pos: self
70
+ .sentences[coref_blob[:sentence] - 1]
71
+ .tokens
72
+ .each_with_index
73
+ .select{|s, i| i >= coref_blob[:start] - 1 && i < coref_blob[:end] - 1 }
74
+ .map{|t, i| t.pos.text }
75
+ })
76
+ end
59
77
  end
@@ -1,3 +1,3 @@
1
1
  module StanfordCorenlpXmlAdapter
2
- VERSION = "0.3.0"
2
+ VERSION = "0.6.0"
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.3.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joshweir
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-19 00:00:00.000000000 Z
11
+ date: 2018-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  version: '0'
216
216
  requirements: []
217
217
  rubyforge_project:
218
- rubygems_version: 2.5.2.3
218
+ rubygems_version: 2.6.13
219
219
  signing_key:
220
220
  specification_version: 4
221
221
  summary: Ruby adapter to the output returned by Stanford CoreNLP XML Server.