mexico 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.document +5 -0
- data/.gitmodules +3 -0
- data/.project +14 -0
- data/.rspec +2 -0
- data/Gemfile +31 -0
- data/LICENSE.txt +165 -0
- data/README.md +116 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/assets/TESTCORPUS/Corpus.xml +26 -0
- data/assets/fiesta/b6/layer_connectors.fst +16 -0
- data/assets/fiesta/b6/match_jones_161_CM_neu_checked.parsed.xml +1225 -0
- data/assets/fiesta/elan/ElanFileFormat.eaf +76 -0
- data/assets/fiesta/elan/ElanFileFormat.pfsx +8 -0
- data/assets/fiesta/elan/ElanFileFormatComplexInterLayerLinks.eaf +107 -0
- data/assets/fiesta/elan/reflinks_example.eaf +270 -0
- data/assets/fiesta/elan/test_all_interlayerrelations.fst +43 -0
- data/assets/fiesta/head/head.fst +24 -0
- data/assets/fiesta/praat/mexico.ShortTextGrid +81 -0
- data/assets/fiesta/praat/mexico.TextGrid +104 -0
- data/assets/helpers/collection_ref_handler.rb +29 -0
- data/assets/helpers/id_ref_handler.rb +29 -0
- data/assets/helpers/roxml_attribute_handler.rb +57 -0
- data/assets/out_only/construct_and_write_spec.toe +99 -0
- data/assets/spec.html +554 -0
- data/bin/mexico +5 -0
- data/features/mexico.feature +9 -0
- data/features/step_definitions/mexico_steps.rb +0 -0
- data/features/support/env.rb +15 -0
- data/info/releasenotes/0.0.1.md +5 -0
- data/info/releasenotes/0.0.2.md +5 -0
- data/info/releasenotes/0.0.3.md +5 -0
- data/info/releasenotes/0.0.4.md +5 -0
- data/info/releasenotes/0.0.5.md +8 -0
- data/info/releasenotes/0.0.6.md +3 -0
- data/info/releasenotes/0.0.7.md +4 -0
- data/info/releasenotes/0.0.8.md +9 -0
- data/info/releasenotes/0.0.9.md +7 -0
- data/lib/mexico/cmd.rb +210 -0
- data/lib/mexico/constants.rb +82 -0
- data/lib/mexico/constraints/constraint.rb +85 -0
- data/lib/mexico/constraints/fiesta_constraints.rb +209 -0
- data/lib/mexico/constraints.rb +27 -0
- data/lib/mexico/core/corpus_core.rb +39 -0
- data/lib/mexico/core/design_core.rb +31 -0
- data/lib/mexico/core/media_type.rb +61 -0
- data/lib/mexico/core.rb +36 -0
- data/lib/mexico/fiesta/interfaces/b6_chat_game_interface.rb +222 -0
- data/lib/mexico/fiesta/interfaces/elan_interface.rb +143 -0
- data/lib/mexico/fiesta/interfaces/short_text_grid_interface.rb +99 -0
- data/lib/mexico/fiesta/interfaces/text_grid_interface.rb +103 -0
- data/lib/mexico/fiesta/interfaces.rb +31 -0
- data/lib/mexico/fiesta.rb +27 -0
- data/lib/mexico/file_system/bound_to_corpus.rb +37 -0
- data/lib/mexico/file_system/corpus.rb +207 -0
- data/lib/mexico/file_system/data.rb +96 -0
- data/lib/mexico/file_system/design.rb +75 -0
- data/lib/mexico/file_system/design_component.rb +78 -0
- data/lib/mexico/file_system/entry.rb +59 -0
- data/lib/mexico/file_system/fiesta_document.rb +344 -0
- data/lib/mexico/file_system/fiesta_map.rb +112 -0
- data/lib/mexico/file_system/head.rb +33 -0
- data/lib/mexico/file_system/id_ref.rb +46 -0
- data/lib/mexico/file_system/implicit_item_link.rb +19 -0
- data/lib/mexico/file_system/interval_link.rb +84 -0
- data/lib/mexico/file_system/item.rb +166 -0
- data/lib/mexico/file_system/item_link.rb +98 -0
- data/lib/mexico/file_system/item_links_proxy.rb +13 -0
- data/lib/mexico/file_system/layer.rb +89 -0
- data/lib/mexico/file_system/layer_connector.rb +74 -0
- data/lib/mexico/file_system/layer_link.rb +75 -0
- data/lib/mexico/file_system/local_file.rb +101 -0
- data/lib/mexico/file_system/participant.rb +69 -0
- data/lib/mexico/file_system/participant_role.rb +43 -0
- data/lib/mexico/file_system/point_link.rb +79 -0
- data/lib/mexico/file_system/property.rb +35 -0
- data/lib/mexico/file_system/property_map.rb +37 -0
- data/lib/mexico/file_system/resource.rb +174 -0
- data/lib/mexico/file_system/scale.rb +125 -0
- data/lib/mexico/file_system/section.rb +41 -0
- data/lib/mexico/file_system/static_collection_ref.rb +64 -0
- data/lib/mexico/file_system/template.rb +23 -0
- data/lib/mexico/file_system/trial.rb +87 -0
- data/lib/mexico/file_system/url.rb +65 -0
- data/lib/mexico/file_system.rb +62 -0
- data/lib/mexico/not_yet_implemented_error.rb +28 -0
- data/lib/mexico/util/fancy_container.rb +57 -0
- data/lib/mexico/util.rb +51 -0
- data/lib/mexico.rb +36 -0
- data/spec/constraints/constraints_spec.rb +306 -0
- data/spec/core/media_type_spec.rb +50 -0
- data/spec/fiesta/b6_spec.rb +43 -0
- data/spec/fiesta/elan_spec.rb +43 -0
- data/spec/fiesta/head_spec.rb +54 -0
- data/spec/fiesta/praat_spec.rb +54 -0
- data/spec/fiesta/read_spec.rb +76 -0
- data/spec/file_system_based/better_collection_spec.rb +142 -0
- data/spec/file_system_based/corpus_spec.rb +194 -0
- data/spec/file_system_based/design_spec.rb +100 -0
- data/spec/file_system_based/inter_links_spec.rb +100 -0
- data/spec/file_system_based/item_links_spec.rb +76 -0
- data/spec/file_system_based/rdf_spec.rb +177 -0
- data/spec/file_system_based/resource_spec.rb +111 -0
- data/spec/file_system_based/trial_spec.rb +129 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/toe/construct_and_write_spec.rb +82 -0
- data/spec/toe/construction_spec.rb +110 -0
- data/spec/toe/item_spec.rb +58 -0
- data/spec/toe/layer_spec.rb +63 -0
- data/spec/toe/scale_spec.rb +89 -0
- data/spec/toe/toe_document_spec.rb +39 -0
- data/test/helper.rb +19 -0
- data/test/test_mexico.rb +7 -0
- metadata +357 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Mexico::FileSystem::Corpus do
|
22
|
+
|
23
|
+
# def write_corpus
|
24
|
+
# doc = Nokogiri::XML::Document.new
|
25
|
+
# doc.root = @corpus.to_xml
|
26
|
+
# open(File.join(@basepath, "Corpus.OUT.xml"), 'w') do |file|
|
27
|
+
# file << doc.serialize
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
# context 'Corpus' do
|
32
|
+
#
|
33
|
+
# # set up an initial corpus representation from the example file
|
34
|
+
# before(:each) do
|
35
|
+
# @basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus', 'mexico')
|
36
|
+
# @corpus = Mexico::FileSystem::Corpus.open(@basepath)
|
37
|
+
# @corpus.resources[1].load
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# it 'should output RDF ntriples' do
|
41
|
+
# rdf = @corpus.to_rdf
|
42
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','corpus.nt'), 'w:utf-8') do |f|
|
43
|
+
# f << rdf
|
44
|
+
# end
|
45
|
+
# rdf.should_not be nil
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# it 'should output RDF RDFXML' do
|
49
|
+
# rdf = @corpus.to_rdf(:format => :rdfxml, :base_uri => 'http://phoibos.sfb673.org/corpora/',
|
50
|
+
# :prefixes => {:cats=>'http://cats.sfb673.org/',:phoibos=>'http://phoibos.sfb673.org/corpora/'})
|
51
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','corpus.rdf'), 'w:utf-8') do |f|
|
52
|
+
# f << rdf
|
53
|
+
# end
|
54
|
+
# rdf.should_not be nil
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# end
|
58
|
+
|
59
|
+
context 'Fiesta Document' do
|
60
|
+
|
61
|
+
before :each do
|
62
|
+
@basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus', 'mexico')
|
63
|
+
@corpus = Mexico::FileSystem::Corpus.open(@basepath)
|
64
|
+
@corpus.resources[1].load
|
65
|
+
@document = @corpus.resources[1].document
|
66
|
+
end
|
67
|
+
|
68
|
+
# it 'should output RDF XML' do
|
69
|
+
# rdf = @document.to_rdf(:format => :rdfxml, :base_uri => 'http://phoibos.sfb673.org/corpora/',
|
70
|
+
# :prefixes => {:cats=>'http://cats.sfb673.org/',:phoibos=>'http://phoibos.sfb673.org/corpora/'})
|
71
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','document.rdf'), 'w:utf-8') do |f|
|
72
|
+
# f << rdf
|
73
|
+
# end
|
74
|
+
# rdf.should_not be nil
|
75
|
+
# end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'Scale' do
|
80
|
+
|
81
|
+
before :each do
|
82
|
+
@basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus', 'mexico')
|
83
|
+
@corpus = Mexico::FileSystem::Corpus.open(@basepath)
|
84
|
+
@corpus.resources[1].load
|
85
|
+
@document = @corpus.resources[1].document
|
86
|
+
end
|
87
|
+
|
88
|
+
# it 'outputs correct rdf for scales' do
|
89
|
+
#
|
90
|
+
# puts "SCALE CLASS"
|
91
|
+
# puts "*" * 40
|
92
|
+
# puts Mexico::FileSystem::Scale.to_turtle
|
93
|
+
# puts "*" * 40
|
94
|
+
# puts @document.scales.first.to_turtle
|
95
|
+
# puts "*" * 40
|
96
|
+
#
|
97
|
+
#
|
98
|
+
# end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'B6 Document' do
|
103
|
+
|
104
|
+
before :each do
|
105
|
+
@basepath = File.join(File.dirname(__FILE__),'..','..','assets','fiesta', 'b6')
|
106
|
+
@filename = File.join @basepath, 'match_jones_161_CM_neu_checked.parsed.xml'
|
107
|
+
@document = ::Mexico::Fiesta::Interfaces::B6ChatGameInterface.instance.import(File.read(@filename))
|
108
|
+
puts "DCN: %s " % @document.class.name
|
109
|
+
@document.self_uri('http://phoibos.sfb673.org/corpora/example/b6.fst')
|
110
|
+
end
|
111
|
+
|
112
|
+
# it 'should output RDF XML' do
|
113
|
+
# rdf = @document.to_rdf(:format => :rdfxml, :base_uri => 'http://phoibos.sfb673.org/corpora/',
|
114
|
+
# :prefixes => {:cats=>'http://cats.sfb673.org/',:phoibos=>'http://phoibos.sfb673.org/corpora/'})
|
115
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','b6.rdf'), 'w:utf-8') do |f|
|
116
|
+
# f << rdf
|
117
|
+
# end
|
118
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','b6.fst'),'w') do |f|
|
119
|
+
# f << @document.to_xml
|
120
|
+
# end
|
121
|
+
# rdf.should_not be nil
|
122
|
+
# end
|
123
|
+
|
124
|
+
# it 'should output RDF Turtle' do
|
125
|
+
#
|
126
|
+
# # check document
|
127
|
+
#
|
128
|
+
# @document.items.each do |i|
|
129
|
+
# i.layer_links.each do |ll|
|
130
|
+
# puts "%s, %s" % [ll, ll.document]
|
131
|
+
# end
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# puts @document.self_uri
|
135
|
+
# # return
|
136
|
+
#
|
137
|
+
# asrdf = @document.as_rdf
|
138
|
+
# asrdf.statements.each do |s|
|
139
|
+
# puts s
|
140
|
+
# end
|
141
|
+
#
|
142
|
+
# rdf = @document.to_rdf(:format => :turtle, :base_uri => 'http://phoibos.sfb673.org/corpora/',
|
143
|
+
# :prefixes => {:cats=>'http://cats.sfb673.org/',:phoibos=>'http://phoibos.sfb673.org/corpora/'})
|
144
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','b6.ttl'), 'w:utf-8') do |f|
|
145
|
+
# f << rdf
|
146
|
+
# end
|
147
|
+
# File.open(File.join(File.dirname(__FILE__), '..','..','assets','rdf-output','b6.fst'),'w') do |f|
|
148
|
+
# f << @document.to_xml
|
149
|
+
# end
|
150
|
+
# rdf.should_not be nil
|
151
|
+
# end
|
152
|
+
|
153
|
+
it 'converts all to RDF' do
|
154
|
+
dir = '/Users/pmenke/Dropbox/Work/b6/data_20_12_12/'
|
155
|
+
|
156
|
+
n = 1
|
157
|
+
Dir.open(dir).each do |f|
|
158
|
+
if f =~ /^*xml$/
|
159
|
+
puts f
|
160
|
+
filename = File.join dir, f
|
161
|
+
doc = ::Mexico::Fiesta::Interfaces::B6ChatGameInterface.instance.import(File.read(filename))
|
162
|
+
doc.identifier = n.to_s
|
163
|
+
|
164
|
+
rdf = doc.to_rdf(:format => :turtle, :base_uri => 'http://phoibos.sfb673.org/resources/',
|
165
|
+
:prefixes => {:cats=>'http://cats.sfb673.org/',:phoibos=>'http://phoibos.sfb673.org/resources/'})
|
166
|
+
File.open("#{filename}.ttl", 'w:utf-8') do |f|
|
167
|
+
f << rdf
|
168
|
+
end
|
169
|
+
puts "done"
|
170
|
+
n=n+1
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Mexico::FileSystem::Resource do
|
22
|
+
|
23
|
+
# set up an initial corpus representation from the example file
|
24
|
+
before(:each) do
|
25
|
+
@basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus','utterance')
|
26
|
+
# @xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
|
27
|
+
@corpus = Mexico::FileSystem::Corpus.open(@basepath)
|
28
|
+
@resource = @corpus.resources.first
|
29
|
+
@local_file = @resource.local_files[0]
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'any resource' do
|
33
|
+
|
34
|
+
it 'should provide access to (possibly zero) local files' do
|
35
|
+
@resource.should respond_to('local_files')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should provide access to (possibly zero) URLs' do
|
39
|
+
@resource.should respond_to('urls')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should return a collection when asked for local files' do
|
43
|
+
@resource.local_files.should be_kind_of(Enumerable)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should return a collection when asked for urls' do
|
47
|
+
@resource.urls.should be_kind_of(Enumerable)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'the first example resource' do
|
53
|
+
|
54
|
+
it 'should have four local files' do
|
55
|
+
# puts '/\\/\\/\\/\\'
|
56
|
+
# puts @resource
|
57
|
+
# puts @resource.identifier
|
58
|
+
# puts @resource.local_files
|
59
|
+
# puts @resource.local_files.count
|
60
|
+
#
|
61
|
+
|
62
|
+
@resource.local_files.count.should eq(4)
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'its design component links' do
|
66
|
+
|
67
|
+
it 'should link to correct dcs' do
|
68
|
+
@resource.design_component.should eq @corpus.designs[0].design_components[0]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'its local file' do
|
74
|
+
|
75
|
+
it 'should have some path' do
|
76
|
+
@resource.local_files[0].should respond_to(:path)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should have the correct path value' do
|
80
|
+
@resource.local_files[0].path.should eq './video_files/utterance.mov'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should resolve relative paths correctly' do
|
84
|
+
@local_file.should respond_to :absolute_path
|
85
|
+
@local_file.absolute_path.should match /^\/.*$/
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should tell whether there is an actual file at this path' do
|
89
|
+
@local_file.should respond_to :file_exists?
|
90
|
+
@local_file.file_exists?.should eq true
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should return a file handle for this path if there is an actual file' do
|
94
|
+
@local_file.should respond_to :file_handle
|
95
|
+
@local_file.file_handle.should be_kind_of(File)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should tell the size of the actual file' do
|
99
|
+
@local_file.should respond_to :file_size
|
100
|
+
@local_file.file_size.should be_kind_of(Integer)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should have one url' do
|
106
|
+
@resource.urls.count.should eq(0)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Mexico::FileSystem::Trial do
|
22
|
+
|
23
|
+
# set up an initial corpus representation from the example file
|
24
|
+
before(:each) do
|
25
|
+
@basepath = File.join(File.dirname(__FILE__), '..','..','assets','TESTCORPUS')
|
26
|
+
@xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
|
27
|
+
@corpus = Mexico::FileSystem::Corpus.from_xml(@xml, {:path => @basepath})
|
28
|
+
@design = @corpus.designs.first
|
29
|
+
@other_design = @corpus.designs[1]
|
30
|
+
@trial = @corpus.trials.first
|
31
|
+
end
|
32
|
+
|
33
|
+
context "Attributes" do
|
34
|
+
|
35
|
+
context "identifier" do
|
36
|
+
|
37
|
+
it "should have accessor methods" do
|
38
|
+
@trial.should respond_to(:identifier, :identifier=)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have the right type" do
|
42
|
+
@trial.identifier.kind_of?(String).should be true
|
43
|
+
@trial.identifier.should match /^\w[-\w\d_]*$/
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have the correct value" do
|
47
|
+
@trial.identifier.should eq "example-trial"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context "name" do
|
53
|
+
|
54
|
+
it "should have accessor methods" do
|
55
|
+
@trial.should respond_to(:name, :name=)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have the right type" do
|
59
|
+
@trial.name.kind_of?(String).should be true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should have the correct value" do
|
63
|
+
@trial.name.should eq "Example Trial"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
context "description" do
|
69
|
+
|
70
|
+
it "should have accessor methods" do
|
71
|
+
@trial.should respond_to(:description, :description=)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should have the right type" do
|
75
|
+
@trial.description.kind_of?(String).should be true
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should have the correct value" do
|
79
|
+
@trial.description.should eq "Trial Description"
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
context "running_number" do
|
85
|
+
|
86
|
+
it "should have accessor methods" do
|
87
|
+
@trial.should respond_to(:running_number, :running_number=)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should have the right type" do
|
91
|
+
@trial.running_number.kind_of?(Integer).should be true
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should have the correct value" do
|
95
|
+
@trial.running_number.should eq 1
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
context "Aggregated components" do
|
106
|
+
|
107
|
+
it "should respond to id method" do
|
108
|
+
@trial.should respond_to(:design_id)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should respond to object getter method" do
|
112
|
+
@trial.should respond_to(:design)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should deliver the correct design object" do
|
116
|
+
@trial.design.identifier.should eq @design.identifier
|
117
|
+
@trial.design.name.should eq @design.name
|
118
|
+
@trial.design.description.should eq @design.description
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should, upon change, use the correct design object" do
|
122
|
+
@trial.design.identifier.should eq @design.identifier
|
123
|
+
@trial.design=@other_design
|
124
|
+
@trial.design.identifier.should eq @other_design.identifier
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'mexico.rb'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Mexico::FileSystem::FiestaDocument do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@testfile = File.join(File.dirname(__FILE__), '..','..','assets','out_only')
|
25
|
+
#@basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus','structured')
|
26
|
+
#@xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
|
27
|
+
#@corpus = Mexico::FileSystem::Corpus.from_xml(@xml, {:path => @basepath})
|
28
|
+
#@resource = @corpus.resources[1]
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'writes a correct ToE structure' do
|
32
|
+
|
33
|
+
it 'to a local file' do
|
34
|
+
@toe_doc = Mexico::FileSystem::FiestaDocument.new
|
35
|
+
@toe_doc.add_standard_timeline('s')
|
36
|
+
@timeline = @toe_doc.scales.first
|
37
|
+
(1..4).each do |x|
|
38
|
+
@toe_doc.layers << Mexico::FileSystem::Layer.new(identifier: "layer0#{x}", name: "Layer #{x}")
|
39
|
+
end
|
40
|
+
# @todo add layer hierarchies
|
41
|
+
vals = %w(yes all work and no play makes jack andsoon)
|
42
|
+
(1..8).each do |n|
|
43
|
+
puts @toe_doc.class.name
|
44
|
+
@toe_doc.add_item(Mexico::FileSystem::Item.new(identifier: "i#{n}")) do |i|
|
45
|
+
i.data = Mexico::FileSystem::Data.new(string_value: vals[n-1])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# create predecessors and successors
|
50
|
+
(0..6).each do |n|
|
51
|
+
puts "i 1 exists? %s" % @toe_doc.items[n]
|
52
|
+
puts "i 2 exists? %s" % @toe_doc.items[n+1]
|
53
|
+
@toe_doc.items[n].item_links << Mexico::FileSystem::ItemLink.new(target_object: @toe_doc.items[n+1], role: 'successor')
|
54
|
+
@toe_doc.items[n+1].item_links << Mexico::FileSystem::ItemLink.new(target_object: @toe_doc.items[n], role: 'predecessor')
|
55
|
+
end
|
56
|
+
|
57
|
+
# points, first layer
|
58
|
+
(0..3).each do |n|
|
59
|
+
@toe_doc.items[n].point_links << Mexico::FileSystem::PointLink.new(target_object: @timeline, point: 100.0*(n+1))
|
60
|
+
@toe_doc.items[n].layer_links << Mexico::FileSystem::LayerLink.new(target_object: @toe_doc.layers[0])
|
61
|
+
end
|
62
|
+
|
63
|
+
# points, first layer
|
64
|
+
(4..7).each do |n|
|
65
|
+
@toe_doc.items[n].interval_links << Mexico::FileSystem::IntervalLink.new(target_object: @timeline, min: 100.0*(n+1), max: 100.0*(n+2))
|
66
|
+
@toe_doc.items[n].layer_links << Mexico::FileSystem::LayerLink.new(target_object: @toe_doc.layers[1])
|
67
|
+
end
|
68
|
+
|
69
|
+
File.open(File.join(@testfile,'construct_and_write_spec.toe'), "w:utf-8") do |file|
|
70
|
+
xml_node = @toe_doc.to_xml
|
71
|
+
xml_node['xmlns:xsi'] = "http://www.w3.org/2001/XMLSchema-instance"
|
72
|
+
xml_node['xsi:noNamespaceSchemaLocation'] = "../../xml/schema/fiesta.xsd"
|
73
|
+
|
74
|
+
puts "Atts: %s" % xml_node.attributes
|
75
|
+
file << xml_node
|
76
|
+
end
|
77
|
+
@toe_doc.should_not be_nil
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Mexico::FileSystem::FiestaDocument do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus','structured')
|
25
|
+
@xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
|
26
|
+
@corpus = Mexico::FileSystem::Corpus.from_xml(@xml, {:path => @basepath})
|
27
|
+
@resource = @corpus.resources[1]
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'should yield a correct xml representation when constructed from scratch' do
|
31
|
+
|
32
|
+
it 'has a local file' do
|
33
|
+
local_file = @resource.local_files[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'can read annotation data' do
|
37
|
+
@resource.load.should_not eq nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has two items' do
|
41
|
+
@resource.load
|
42
|
+
@resource.document.items.size.should be 2
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'responds to the item link collection' do
|
46
|
+
@resource.load.items[0].should respond_to :item_links
|
47
|
+
end
|
48
|
+
it 'responds to the layer link collection' do
|
49
|
+
@resource.load.items[0].should respond_to :layer_links
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'responds to the interval link collection' do
|
53
|
+
@resource.load.items[0].should respond_to :interval_links
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'responds to the point link collection' do
|
57
|
+
@resource.load.items[0].should respond_to :point_links
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'has items with correct number of linked layers' do
|
61
|
+
@resource.load
|
62
|
+
(0..1).each do |n|
|
63
|
+
@resource.document.items[n].layer_links.size.should eq 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'has items with correctly linked layers' do
|
68
|
+
@resource.load
|
69
|
+
(0..1).each do |n|
|
70
|
+
@resource.document.items[n].layer_links[0].target_object.should eq @resource.document.layers[0]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'has items with correct number of linked items' do
|
75
|
+
@resource.load
|
76
|
+
(0..1).each do |n|
|
77
|
+
@resource.document.items[n].item_links.size.should eq 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'has items with correctly linked other-items' do
|
82
|
+
|
83
|
+
it "has first item with correct item target" do
|
84
|
+
@resource.load
|
85
|
+
puts "i0 : %s" % @resource.document.items[0].object_id
|
86
|
+
puts "i1 : %s" % @resource.document.items[1].object_id
|
87
|
+
puts "i0 link t: %s" % @resource.document.items[0].item_links[0].target_object.object_id
|
88
|
+
puts "i1 link t: %s" % @resource.document.items[1].item_links[0].target_object.object_id
|
89
|
+
@resource.document.items[0].item_links[0].target_object.should eq @resource.document.items[1]
|
90
|
+
end
|
91
|
+
|
92
|
+
it "has second item with correct item target" do
|
93
|
+
@resource.load
|
94
|
+
@resource.document.items[1].item_links[0].target_object.should eq @resource.document.items[0]
|
95
|
+
end
|
96
|
+
|
97
|
+
it "has first item with correct role" do
|
98
|
+
@resource.load
|
99
|
+
@resource.document.items[0].item_links[0].role.should eq "successor"
|
100
|
+
end
|
101
|
+
|
102
|
+
it "has second item with correct role" do
|
103
|
+
@resource.load
|
104
|
+
@resource.document.items[1].item_links[0].role.should eq "predecessor"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Mexico::FileSystem::Item do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus','mexico')
|
25
|
+
@corpus = Mexico::FileSystem::Corpus.open(@basepath)
|
26
|
+
@trans_resource = @corpus.resources[1]
|
27
|
+
@anno_file = @trans_resource.local_files.find{ |i| i.identifier=="mexico-transcription-toe" }
|
28
|
+
@trans_resource.load
|
29
|
+
@annodoc = @trans_resource.document
|
30
|
+
@i = @annodoc.items[0]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
it "has an items collection" do
|
35
|
+
@trans_resource.should_not eq nil
|
36
|
+
@trans_resource.document.should_not eq nil
|
37
|
+
@trans_resource.document.should respond_to(:items)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "has twelve items inside the collection" do
|
41
|
+
@annodoc.items.size.should be 12
|
42
|
+
end
|
43
|
+
|
44
|
+
it "has a first item with working accessors" do
|
45
|
+
@i.should respond_to(:identifier)
|
46
|
+
@i.should respond_to(:data)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'has the correct identifier' do
|
50
|
+
@i.identifier.should eq 'i1'
|
51
|
+
puts "Data: %s" % @i.data
|
52
|
+
puts "String: %s" % @i.data.string_value
|
53
|
+
puts "Int: %s" % @i.data.int_value
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
end
|