llt-review 0.0.2 → 0.0.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 +4 -4
- data/lib/llt/review/api.rb +1 -1
- data/lib/llt/review/common/sentence.rb +9 -1
- data/lib/llt/review/treebank/postag.rb +9 -1
- data/lib/llt/review/treebank/sentence.rb +7 -0
- data/lib/llt/review/treebank/word.rb +5 -1
- data/lib/llt/review/version.rb +1 -1
- data/spec/lib/llt/review/treebank_spec.rb +111 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b91983dc42ac4d0aece4d4d745e2576442f91fc
|
4
|
+
data.tar.gz: faa768dab56010e1bc570506e7ae718ca503a11b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2f9e3f7d61e8ac1493035d8789eb414190cbbe3f218a3c229ab66af09d55f0f7df1d7ba2ae0c761e195caa6a103a9bd77081a8938adb88e0626bcf849a65ff3
|
7
|
+
data.tar.gz: 65f0e95aa16565761a0025f2832e91b2e8e22b4277ad35d625bc8ab63ad2072cad9d0c1acb8b321edddd7d0bb4b89e19d224129a243b7d329dbd4113b5e0d520
|
data/lib/llt/review/api.rb
CHANGED
@@ -44,7 +44,7 @@ class Api < Sinatra::Base
|
|
44
44
|
if backend = params[:backend]
|
45
45
|
p = case backend
|
46
46
|
when 'perseids' then 'sosol.perseids.org/sosol'
|
47
|
-
when 'perseids-dev' then '
|
47
|
+
when 'perseids-dev' then 'sosol-rep.perseids.org'
|
48
48
|
end
|
49
49
|
|
50
50
|
expand_perseids_urls(params, :gold, p)
|
@@ -13,7 +13,11 @@ module LLT
|
|
13
13
|
|
14
14
|
def compare(other, comparables = nil)
|
15
15
|
diff = new_sentence_diff
|
16
|
-
words.each
|
16
|
+
words.each do |id, word|
|
17
|
+
other_word = other[id] || dummy_word(id)
|
18
|
+
|
19
|
+
word.compare(other_word, diff, comparables)
|
20
|
+
end
|
17
21
|
diff
|
18
22
|
end
|
19
23
|
|
@@ -25,6 +29,10 @@ module LLT
|
|
25
29
|
|
26
30
|
private
|
27
31
|
|
32
|
+
def dummy_word(id)
|
33
|
+
# implemented by subclasses
|
34
|
+
end
|
35
|
+
|
28
36
|
def new_sentence_diff
|
29
37
|
diff_namespace.const_get(:Sentence).new(self)
|
30
38
|
end
|
@@ -5,7 +5,7 @@ module LLT
|
|
5
5
|
|
6
6
|
def initialize(postag)
|
7
7
|
@id = :postag
|
8
|
-
@postag = postag
|
8
|
+
@postag = new_postag(postag)
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_s
|
@@ -58,6 +58,14 @@ module LLT
|
|
58
58
|
data.add(Report::Generic.new(pl, 0, sg))
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
def new_postag(postag)
|
63
|
+
if !postag || postag.empty? || postag == '-'
|
64
|
+
'-' * POSTAG_SCHEMA.length
|
65
|
+
else
|
66
|
+
postag
|
67
|
+
end
|
68
|
+
end
|
61
69
|
end
|
62
70
|
end
|
63
71
|
end
|
@@ -3,7 +3,7 @@ module LLT
|
|
3
3
|
class Word
|
4
4
|
include Core::Structures::HashContainable
|
5
5
|
|
6
|
-
attr_accessor :form, :lemma, :head, :relation
|
6
|
+
attr_accessor :form, :lemma, :head, :relation, :inexistant
|
7
7
|
attr_reader :postag
|
8
8
|
|
9
9
|
Attr = Struct.new(:id, :attribute) do
|
@@ -20,6 +20,10 @@ module LLT
|
|
20
20
|
define_method("#{type}=") { |val| add(Attr.new(type, val)) }
|
21
21
|
end
|
22
22
|
|
23
|
+
def [](key)
|
24
|
+
super(key) || send("#{key}=", '-')
|
25
|
+
end
|
26
|
+
|
23
27
|
def postag=(tag)
|
24
28
|
add(Postag.new(tag))
|
25
29
|
end
|
data/lib/llt/review/version.rb
CHANGED
@@ -141,6 +141,117 @@ describe LLT::Review::Treebank do
|
|
141
141
|
diff[3].should be_nil # has only lemma and postag differences
|
142
142
|
diff[4].should be_true
|
143
143
|
end
|
144
|
+
|
145
|
+
context "with slightly out of sync documents" do
|
146
|
+
let(:ge1) do
|
147
|
+
<<-EOF
|
148
|
+
<treebank>
|
149
|
+
<sentence id="21" document_id="Perseus:text:1999.02.0002" subdoc="Book=2:chapter=5" span="In3:erat0">
|
150
|
+
<word id="1" form="In" lemma="in1" postag="r--------" head="5" relation="AuxP"/>
|
151
|
+
<word id="2" form="eo" lemma="is1" postag="p-s---nb-" head="3" relation="ATR"/>
|
152
|
+
<word id="3" form="flumine" lemma="flumen1" postag="n-s---nb-" head="1" relation="ADV"/>
|
153
|
+
<word id="4" form="pons" lemma="pons1" postag="n-s---mn-" head="5" relation="SBJ"/>
|
154
|
+
<word id="5" form="erat" lemma="sum1" postag="v3siia---" head="0" relation="PRED"/>
|
155
|
+
<word id="6" form="erat" lemma="sum1" postag="v3siia---" head="0" relation="PRED" elliptic="true"/>
|
156
|
+
</sentence>
|
157
|
+
</treebank>
|
158
|
+
EOF
|
159
|
+
end
|
160
|
+
|
161
|
+
let(:re1) do
|
162
|
+
<<-EOF
|
163
|
+
<treebank>
|
164
|
+
<sentence id="21" document_id="Perseus:text:1999.02.0002" subdoc="Book=2:chapter=5" span="In3:erat0">
|
165
|
+
<word id="1" form="In" lemma="in1" postag="r--------" head="4" relation="AuxP"/>
|
166
|
+
<word id="2" form="eo" lemma="is1" postag="p-s---nd-" head="3" relation="ATR"/>
|
167
|
+
<word id="3" form="flumine" lemma="flumen2" postag="n-s---nd-" head="1" relation="ADV"/>
|
168
|
+
<word id="4" form="pons" lemma="pons1" postag="n-s---mn-" head="5" relation="OBJ"/>
|
169
|
+
<word id="5" form="erat" lemma="sum1" postag="v3siia---" head="0" relation="PRED"/>
|
170
|
+
</sentence>
|
171
|
+
</treebank>
|
172
|
+
EOF
|
173
|
+
end
|
174
|
+
|
175
|
+
it "does not fall for additional (such as elliptic) nodes in the gold file" do
|
176
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_ge1) { ge1 }
|
177
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_re1) { re1 }
|
178
|
+
|
179
|
+
expect { differ.diff([:uri_for_ge1], [:uri_for_re1]) }.to_not raise_error
|
180
|
+
end
|
181
|
+
|
182
|
+
it "does not fall for additional (such as elliptic) nodes in the review file" do
|
183
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_re1) { re1 }
|
184
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_ge1) { ge1 }
|
185
|
+
|
186
|
+
expect { differ.diff([:uri_for_re1], [:uri_for_ge1]) }.to_not raise_error
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context "with partially unannotated files" do
|
191
|
+
let(:gi1) do
|
192
|
+
<<-EOF
|
193
|
+
<treebank>
|
194
|
+
<sentence id="21" document_id="Perseus:text:1999.02.0002" subdoc="Book=2:chapter=5" span="In3:erat0">
|
195
|
+
<word id="1" form="In" lemma="in1" postag="r--------" head="5" relation="AuxP"/>
|
196
|
+
<word id="2" form="eo" lemma="is1" postag="p-s---nb-" head="3" relation="ATR"/>
|
197
|
+
<word id="3" form="flumine" lemma="flumen1" postag="n-s---nb-" head="1" relation="ADV"/>
|
198
|
+
<word id="4" form="pons" lemma="pons1" postag="n-s---mn-" head="5" relation="SBJ"/>
|
199
|
+
<word id="5" form="erat" lemma="sum1" postag="v3siia---" head="0" relation="PRED"/>
|
200
|
+
</sentence>
|
201
|
+
</treebank>
|
202
|
+
EOF
|
203
|
+
end
|
204
|
+
|
205
|
+
let(:ri1) do
|
206
|
+
<<-EOF
|
207
|
+
<treebank>
|
208
|
+
<sentence id="21" document_id="Perseus:text:1999.02.0002" subdoc="Book=2:chapter=5" span="In3:erat0">
|
209
|
+
<word id="1" form="In" postag="r--------" head="4" relation="AuxP"/>
|
210
|
+
<word id="2" form="eo" postag="p-s---nd-" head="3" relation="ATR"/>
|
211
|
+
<word id="3" form="flumine" lemma="flumen2" postag="n-s---nd-" relation="ADV"/>
|
212
|
+
<word id="4" form="pons" lemma="pons1" postag="n-s---mn-" head="5"/>
|
213
|
+
<word id="5" form="erat" lemma="sum1" postag="v3siia---" head="0" relation="PRED"/>
|
214
|
+
</sentence>
|
215
|
+
</treebank>
|
216
|
+
EOF
|
217
|
+
end
|
218
|
+
|
219
|
+
let(:ri2) do
|
220
|
+
<<-EOF
|
221
|
+
<treebank>
|
222
|
+
<sentence id="21" document_id="Perseus:text:1999.02.0002" subdoc="Book=2:chapter=5" span="In3:erat0">
|
223
|
+
<word id="1" form="In" postag="" head="4" relation="AuxP"/>
|
224
|
+
<word id="2" form="eo" head="3" relation="ATR"/>
|
225
|
+
<word id="3" form="flumine" lemma="flumen2" postag="n-s---nd-" relation="ADV"/>
|
226
|
+
<word id="4" form="pons" lemma="pons1" postag="n-s---mn-" head="5"/>
|
227
|
+
<word id="5" form="erat" lemma="sum1" postag="v3siia---" head="0" relation="PRED"/>
|
228
|
+
</sentence>
|
229
|
+
</treebank>
|
230
|
+
EOF
|
231
|
+
end
|
232
|
+
|
233
|
+
it "does not fall with less content in the review file" do
|
234
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_gi1) { gi1 }
|
235
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_ri1) { ri1 }
|
236
|
+
|
237
|
+
expect { differ.diff([:uri_for_gi1], [:uri_for_ri1]) }.to_not raise_error
|
238
|
+
end
|
239
|
+
|
240
|
+
it "does not fall with less content in the gold file" do
|
241
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_gi1) { gi1 }
|
242
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_ri1) { ri1 }
|
243
|
+
|
244
|
+
expect { differ.diff([:uri_for_ri1], [:uri_for_gi1]) }.to_not raise_error
|
245
|
+
end
|
246
|
+
|
247
|
+
it "does not fall with missing postags" do
|
248
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_gi1) { gi1 }
|
249
|
+
allow(differ).to receive(:get_from_uri).with(:uri_for_ri2) { ri2 }
|
250
|
+
|
251
|
+
expect { differ.diff([:uri_for_ri2], [:uri_for_gi1]) }.to_not raise_error
|
252
|
+
expect { differ.diff([:uri_for_gi1], [:uri_for_ri2]) }.to_not raise_error
|
253
|
+
end
|
254
|
+
end
|
144
255
|
end
|
145
256
|
|
146
257
|
describe "#report" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llt-review
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LFDM
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
225
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.2.
|
226
|
+
rubygems_version: 2.2.2
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: Reviews annotations
|