stanford_corenlp_xml_adapter 0.6.0 → 0.6.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e550911f0774a1b4b630f926ad15c86d24f8e95d
|
4
|
+
data.tar.gz: 6cf0bfebb9415a1424a80269536b9cd4bd77d640
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f217242382efac2820c0c0642665ca3b878487fc608509d1547173a10d03c88d411cfd12c11b897cfe9028bbf830e288337536d46605fa6fffa25746204b3eee
|
7
|
+
data.tar.gz: fd9b7ed307e6c8e4ab6cec52bc4f256c35037b69abd67f9105d8538d9f54d6d2ca3e6352fafd6034f260f72d7ef2e99123fc0b033a5af16ad03d4648b9f7b06a
|
@@ -1,66 +1,67 @@
|
|
1
1
|
module DependencyParse
|
2
|
-
def basic_dependencies
|
3
|
-
dependencies_for_type doc, sentence_index,
|
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
|
7
|
-
dependencies_for_type doc, sentence_index,
|
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
|
11
|
-
dependencies_for_type doc, sentence_index,
|
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
|
15
|
-
dependencies_for_type doc, sentence_index,
|
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
|
19
|
-
dependencies_for_type doc, sentence_index,
|
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
|
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
|
32
|
+
def dependency_parse_nok_to_blob(dep_parse_input, pos_tags_input, ner_tags_input)
|
33
33
|
dep_parse_input
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
40
|
+
def dependency_nok_to_blob(dep_parse_input, pos_tags_input, ner_tags_input)
|
41
41
|
{
|
42
|
-
type: dep_parse_input.attributes[
|
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
|
-
|
45
|
+
"governor", dep_parse_input, pos_tags_input, ner_tags_input
|
45
46
|
),
|
46
47
|
dependent: dependency_slice_nok_to_blob(
|
47
|
-
|
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
|
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[
|
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] !=
|
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
|
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.
|
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:
|
11
|
+
date: 2019-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|