mexico 0.0.9

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.
Files changed (115) hide show
  1. checksums.yaml +15 -0
  2. data/.document +5 -0
  3. data/.gitmodules +3 -0
  4. data/.project +14 -0
  5. data/.rspec +2 -0
  6. data/Gemfile +31 -0
  7. data/LICENSE.txt +165 -0
  8. data/README.md +116 -0
  9. data/Rakefile +66 -0
  10. data/VERSION +1 -0
  11. data/assets/TESTCORPUS/Corpus.xml +26 -0
  12. data/assets/fiesta/b6/layer_connectors.fst +16 -0
  13. data/assets/fiesta/b6/match_jones_161_CM_neu_checked.parsed.xml +1225 -0
  14. data/assets/fiesta/elan/ElanFileFormat.eaf +76 -0
  15. data/assets/fiesta/elan/ElanFileFormat.pfsx +8 -0
  16. data/assets/fiesta/elan/ElanFileFormatComplexInterLayerLinks.eaf +107 -0
  17. data/assets/fiesta/elan/reflinks_example.eaf +270 -0
  18. data/assets/fiesta/elan/test_all_interlayerrelations.fst +43 -0
  19. data/assets/fiesta/head/head.fst +24 -0
  20. data/assets/fiesta/praat/mexico.ShortTextGrid +81 -0
  21. data/assets/fiesta/praat/mexico.TextGrid +104 -0
  22. data/assets/helpers/collection_ref_handler.rb +29 -0
  23. data/assets/helpers/id_ref_handler.rb +29 -0
  24. data/assets/helpers/roxml_attribute_handler.rb +57 -0
  25. data/assets/out_only/construct_and_write_spec.toe +99 -0
  26. data/assets/spec.html +554 -0
  27. data/bin/mexico +5 -0
  28. data/features/mexico.feature +9 -0
  29. data/features/step_definitions/mexico_steps.rb +0 -0
  30. data/features/support/env.rb +15 -0
  31. data/info/releasenotes/0.0.1.md +5 -0
  32. data/info/releasenotes/0.0.2.md +5 -0
  33. data/info/releasenotes/0.0.3.md +5 -0
  34. data/info/releasenotes/0.0.4.md +5 -0
  35. data/info/releasenotes/0.0.5.md +8 -0
  36. data/info/releasenotes/0.0.6.md +3 -0
  37. data/info/releasenotes/0.0.7.md +4 -0
  38. data/info/releasenotes/0.0.8.md +9 -0
  39. data/info/releasenotes/0.0.9.md +7 -0
  40. data/lib/mexico/cmd.rb +210 -0
  41. data/lib/mexico/constants.rb +82 -0
  42. data/lib/mexico/constraints/constraint.rb +85 -0
  43. data/lib/mexico/constraints/fiesta_constraints.rb +209 -0
  44. data/lib/mexico/constraints.rb +27 -0
  45. data/lib/mexico/core/corpus_core.rb +39 -0
  46. data/lib/mexico/core/design_core.rb +31 -0
  47. data/lib/mexico/core/media_type.rb +61 -0
  48. data/lib/mexico/core.rb +36 -0
  49. data/lib/mexico/fiesta/interfaces/b6_chat_game_interface.rb +222 -0
  50. data/lib/mexico/fiesta/interfaces/elan_interface.rb +143 -0
  51. data/lib/mexico/fiesta/interfaces/short_text_grid_interface.rb +99 -0
  52. data/lib/mexico/fiesta/interfaces/text_grid_interface.rb +103 -0
  53. data/lib/mexico/fiesta/interfaces.rb +31 -0
  54. data/lib/mexico/fiesta.rb +27 -0
  55. data/lib/mexico/file_system/bound_to_corpus.rb +37 -0
  56. data/lib/mexico/file_system/corpus.rb +207 -0
  57. data/lib/mexico/file_system/data.rb +96 -0
  58. data/lib/mexico/file_system/design.rb +75 -0
  59. data/lib/mexico/file_system/design_component.rb +78 -0
  60. data/lib/mexico/file_system/entry.rb +59 -0
  61. data/lib/mexico/file_system/fiesta_document.rb +344 -0
  62. data/lib/mexico/file_system/fiesta_map.rb +112 -0
  63. data/lib/mexico/file_system/head.rb +33 -0
  64. data/lib/mexico/file_system/id_ref.rb +46 -0
  65. data/lib/mexico/file_system/implicit_item_link.rb +19 -0
  66. data/lib/mexico/file_system/interval_link.rb +84 -0
  67. data/lib/mexico/file_system/item.rb +166 -0
  68. data/lib/mexico/file_system/item_link.rb +98 -0
  69. data/lib/mexico/file_system/item_links_proxy.rb +13 -0
  70. data/lib/mexico/file_system/layer.rb +89 -0
  71. data/lib/mexico/file_system/layer_connector.rb +74 -0
  72. data/lib/mexico/file_system/layer_link.rb +75 -0
  73. data/lib/mexico/file_system/local_file.rb +101 -0
  74. data/lib/mexico/file_system/participant.rb +69 -0
  75. data/lib/mexico/file_system/participant_role.rb +43 -0
  76. data/lib/mexico/file_system/point_link.rb +79 -0
  77. data/lib/mexico/file_system/property.rb +35 -0
  78. data/lib/mexico/file_system/property_map.rb +37 -0
  79. data/lib/mexico/file_system/resource.rb +174 -0
  80. data/lib/mexico/file_system/scale.rb +125 -0
  81. data/lib/mexico/file_system/section.rb +41 -0
  82. data/lib/mexico/file_system/static_collection_ref.rb +64 -0
  83. data/lib/mexico/file_system/template.rb +23 -0
  84. data/lib/mexico/file_system/trial.rb +87 -0
  85. data/lib/mexico/file_system/url.rb +65 -0
  86. data/lib/mexico/file_system.rb +62 -0
  87. data/lib/mexico/not_yet_implemented_error.rb +28 -0
  88. data/lib/mexico/util/fancy_container.rb +57 -0
  89. data/lib/mexico/util.rb +51 -0
  90. data/lib/mexico.rb +36 -0
  91. data/spec/constraints/constraints_spec.rb +306 -0
  92. data/spec/core/media_type_spec.rb +50 -0
  93. data/spec/fiesta/b6_spec.rb +43 -0
  94. data/spec/fiesta/elan_spec.rb +43 -0
  95. data/spec/fiesta/head_spec.rb +54 -0
  96. data/spec/fiesta/praat_spec.rb +54 -0
  97. data/spec/fiesta/read_spec.rb +76 -0
  98. data/spec/file_system_based/better_collection_spec.rb +142 -0
  99. data/spec/file_system_based/corpus_spec.rb +194 -0
  100. data/spec/file_system_based/design_spec.rb +100 -0
  101. data/spec/file_system_based/inter_links_spec.rb +100 -0
  102. data/spec/file_system_based/item_links_spec.rb +76 -0
  103. data/spec/file_system_based/rdf_spec.rb +177 -0
  104. data/spec/file_system_based/resource_spec.rb +111 -0
  105. data/spec/file_system_based/trial_spec.rb +129 -0
  106. data/spec/spec_helper.rb +14 -0
  107. data/spec/toe/construct_and_write_spec.rb +82 -0
  108. data/spec/toe/construction_spec.rb +110 -0
  109. data/spec/toe/item_spec.rb +58 -0
  110. data/spec/toe/layer_spec.rb +63 -0
  111. data/spec/toe/scale_spec.rb +89 -0
  112. data/spec/toe/toe_document_spec.rb +39 -0
  113. data/test/helper.rb +19 -0
  114. data/test/test_mexico.rb +7 -0
  115. metadata +357 -0
@@ -0,0 +1,306 @@
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
+ include Mexico::FileSystem
21
+
22
+ describe Mexico::Constraints::Constraint do
23
+
24
+ # set up an initial corpus representation from the example file
25
+ before(:each) do
26
+ @basepath = File.join File.dirname(__FILE__), '..', '..'
27
+ @assetspath = File.join @basepath, 'assets'
28
+ @top_constraint = Mexico::Constraints::FiestaConstraints::TOP
29
+ @two_constraint = Mexico::Constraints::FiestaConstraints::SCALES_LTE_2
30
+
31
+ @path = File.join @assetspath, 'fiesta', 'elan'
32
+ @filename = File.join @path, 'ElanFileFormat.eaf'
33
+ @filename_inter = File.join @path, 'ElanFileFormatComplexInterLayerLinks.eaf'
34
+ @fiesta_doc = ::Mexico::Fiesta::Interfaces::ElanInterface.instance.import(File.read(@filename))
35
+ @fiesta_doc_inter = ::Mexico::Fiesta::Interfaces::ElanInterface.instance.import(File.read(@filename_inter))
36
+
37
+ end
38
+
39
+ context 'Constraints' do
40
+
41
+
42
+ context 'class level constraint retrieval' do
43
+
44
+ it 'should work' do
45
+
46
+ @top_constraint.should be Mexico::Constraints::Constraint::get('TOP')
47
+ end
48
+
49
+ it 'test' do
50
+ i = Mexico::FileSystem::Item.new
51
+ l = Mexico::FileSystem::ItemLink.new
52
+
53
+ puts "SEND <<"
54
+ puts i.item_links.send(:<<, '')
55
+
56
+ i.item_links << l
57
+
58
+ end
59
+
60
+ end
61
+
62
+
63
+ context 'parent child system' do
64
+
65
+ it 'should give access to the parents structure' do
66
+ @two_constraint.parents.should_not be nil
67
+ end
68
+ it 'should return the correct number of parents for a given child' do
69
+ @two_constraint.parents.size.should eq 1
70
+ end
71
+ it 'should return the correct parent object for a given child' do
72
+ @two_constraint.parents.first.should be Mexico::Constraints::Constraint::get('SCALES_LTE_3')
73
+ end
74
+
75
+ end
76
+
77
+
78
+ context 'The top-level (true) constraint' do
79
+
80
+ it 'should be error free' do
81
+
82
+ #puts @top_constraint
83
+ #puts @top_constraint.class.name
84
+ #puts @top_constraint.evaluator
85
+ #puts @top_constraint.evaluator.class.name
86
+ #puts @top_constraint.evaluator.call
87
+ #puts @top_constraint.evaluator.call.class.name
88
+
89
+ end
90
+
91
+ it 'should call the evaluate method without errors' do
92
+ expect { @top_constraint.evaluate @fiesta_doc }.to_not raise_error
93
+ end
94
+
95
+ it 'should always return true' do
96
+ @top_constraint.evaluate(@fiesta_doc).should be true
97
+ end
98
+
99
+ end
100
+
101
+ context 'layer hierarchy detector' do
102
+
103
+ it 'should detect that an ELAN document has a forest LS' do
104
+ @fiesta_doc.layers_form_a_forest?.should be true
105
+ end
106
+
107
+ it 'should detect that an ELAN document does not have an edgeless LS' do
108
+
109
+ puts "Layer Connectors:"
110
+
111
+ @fiesta_doc.layer_connectors.each do |c|
112
+
113
+ puts "LC %s:" % c.identifier
114
+ puts " source: %s" % c.source.identifier
115
+ puts " target: %s" % c.target.identifier
116
+
117
+ end
118
+
119
+
120
+ @fiesta_doc.layers.each do |l|
121
+
122
+ puts "Layer %s" % l.identifier
123
+ puts " Pred: %i" % l.predecessor_layers.size
124
+ puts " Succ: %i" % l.successor_layers.size
125
+ end
126
+
127
+ #puts "layers %s" % @fiesta_doc.layers
128
+ #puts "layers %s" % @fiesta_doc.layers.class.name
129
+ #puts "layers %s" % @fiesta_doc.layers.size
130
+ #puts @fiesta_doc.layer_connectors
131
+
132
+ @fiesta_doc.layers_form_an_edgeless_graph?.should be false
133
+ end
134
+
135
+ end
136
+
137
+ context 'inter-layer link methods' do
138
+
139
+ it 'should return correct values for inter-layer links' do
140
+
141
+ layer_1 = @fiesta_doc_inter.layers[0]
142
+ layer_2 = @fiesta_doc_inter.layers[1]
143
+
144
+ test_interlayer_graph_1 = @fiesta_doc.inter_layer_graph(layer_1, layer_2)
145
+
146
+ #puts test_interlayer_graph_1[:links]
147
+ #puts pp test_interlayer_graph_1[:source_map]
148
+
149
+ test_interlayer_graph_1[:source_map].each do |k,v|
150
+ puts '%s --> [%s]' % [k.identifier, v.to_a.collect{|x| x.identifier}.join(', ')]
151
+ end
152
+
153
+ test_interlayer_graph_1[:sink_map].each do |k,v|
154
+ puts '%s <-- [%s]' % [k.identifier, v.to_a.collect{|x| x.identifier}.join(', ')]
155
+ end
156
+
157
+ end
158
+
159
+ it 'test the constraints for interlayer relations' do
160
+
161
+ @fiesta_doc_inter.inter_layer_graph_list.each do |layers,graph|
162
+
163
+ puts 'LAYERS %s/%s' % [layers[0].identifier,layers[1].identifier]
164
+ graph[:source_map].each do |k,v|
165
+ puts '%s ---> %s' % [k.identifier,v.to_a.collect{|i| i.identifier}.join(',')]
166
+ end
167
+ graph[:sink_map].each do |k,v|
168
+ puts '%s <--- %s' % [k.identifier,v.to_a.collect{|i| i.identifier}.join(',')]
169
+ end
170
+ end
171
+
172
+ puts '1:n - %s' % Mexico::Constraints::FiestaConstraints::INTERLAYER_1_TO_N.evaluate(@fiesta_doc_inter)
173
+ puts 'n:1 - %s' % Mexico::Constraints::FiestaConstraints::INTERLAYER_N_TO_1.evaluate(@fiesta_doc_inter)
174
+ puts '1:1 - %s' % Mexico::Constraints::FiestaConstraints::INTERLAYER_1_TO_1.evaluate(@fiesta_doc_inter)
175
+ puts '0:0 - %s' % Mexico::Constraints::FiestaConstraints::INTERLAYER_EDGELESS.evaluate(@fiesta_doc_inter)
176
+
177
+ end
178
+
179
+ context 'test all cardinalities' do
180
+
181
+ it 'behaves correct on all cardinalities' do
182
+
183
+ @f = Mexico::FileSystem::FiestaDocument.new
184
+
185
+ l1 = Layer.new(identifier: 'l1', name: 'l1', document: @f)
186
+ l2 = Layer.new(identifier: 'l2', name: 'l2', document: @f)
187
+ l3 = Layer.new(identifier: 'l3', name: 'l3', document: @f)
188
+ l4 = Layer.new(identifier: 'l4', name: 'l4', document: @f)
189
+
190
+ @f.layers << l1
191
+ @f.layers << l2
192
+ @f.layers << l3
193
+ @f.layers << l4
194
+
195
+ @f.layer_connectors << LayerConnector.new(l1, l2, {identifier: 'l1l2'})
196
+ @f.layer_connectors << LayerConnector.new(l2, l3, {identifier: 'l2l3'})
197
+ @f.layer_connectors << LayerConnector.new(l3, l4, {identifier: 'l3l4'})
198
+
199
+
200
+ i1 = @f.add_item(nil) do |i|
201
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l1, document: @f)
202
+ end
203
+
204
+ i2 = @f.add_item(nil) do |i|
205
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l2, document: @f)
206
+ i.add_item_link ItemLink.new(identifier: "#{i.identifier}-il", role: ItemLink::ROLE_PARENT, target_object: i1, document: @f)
207
+ end
208
+
209
+ i3 = @f.add_item(nil) do |i|
210
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l2, document: @f)
211
+ i.add_item_link ItemLink.new(identifier: "#{i.identifier}-il", role: ItemLink::ROLE_PARENT, target_object: i1, document: @f)
212
+ end
213
+
214
+ i4 = @f.add_item(nil) do |i|
215
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l3, document: @f)
216
+ i.add_item_link ItemLink.new(identifier: "#{i.identifier}-il1", role: ItemLink::ROLE_PARENT, target_object: i2, document: @f)
217
+ i.add_item_link ItemLink.new(identifier: "#{i.identifier}-il2", role: ItemLink::ROLE_PARENT, target_object: i3, document: @f)
218
+ end
219
+
220
+ i5 = @f.add_item(nil) do |i|
221
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l4, document: @f)
222
+ end
223
+
224
+ # now, the following cardinalities should be there:
225
+ # l1 / l2 : 1:n
226
+ # l2 / l3 : n:1
227
+ # l3 / l4 : 0:0
228
+
229
+ card_src_12 = @f.source_cardinality_for_layer(l1,l2)
230
+ card_src_23 = @f.source_cardinality_for_layer(l2,l3)
231
+ card_src_34 = @f.source_cardinality_for_layer(l3,l4)
232
+ card_snk_12 = @f.sink_cardinality_for_layer(l1,l2)
233
+ card_snk_23 = @f.sink_cardinality_for_layer(l2,l3)
234
+ card_snk_34 = @f.sink_cardinality_for_layer(l3,l4)
235
+
236
+ puts "SRC 1-2: %i" % card_src_12
237
+ puts "SNK 1-2: %i" % card_snk_12
238
+ puts "SRC 2-3: %i" % card_src_23
239
+ puts "SNK 2-3: %i" % card_snk_23
240
+ puts "SRC 3-4: %i" % card_src_34
241
+ puts "SNK 3-4: %i" % card_snk_34
242
+
243
+ card_src_12.should <= 1
244
+ card_snk_12.should > 1
245
+ card_src_23.should > 1
246
+ card_snk_23.should <= 1
247
+ card_src_34.should == 0
248
+ card_snk_34.should == 0
249
+
250
+ File.open(File.join(@path,'test_all_interlayerrelations.fst'),'w') do |f|
251
+ f << @f.to_xml
252
+ end
253
+
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ context 'values' do
260
+
261
+ it 'correctly detects that all values are strings' do
262
+ @f = Mexico::FileSystem::FiestaDocument.new
263
+ l1 = Layer.new(identifier: 'l1', name: 'l1', document: @f)
264
+ @f.layers << l1
265
+ (1..4).each do |n|
266
+ @f.add_item(nil) do |i|
267
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l1, document: @f)
268
+ i.data=Mexico::FileSystem::Data.new(string_value: "#{n}")
269
+ end
270
+ end
271
+ Mexico::Constraints::FiestaConstraints::VALUES_STRINGS_ONLY.evaluate(@f).should eq true
272
+ Mexico::Constraints::FiestaConstraints::VALUES_MAPS_ONLY.evaluate(@f).should eq false
273
+ end
274
+
275
+ it 'correctly detects that all values are maps' do
276
+ @f = Mexico::FileSystem::FiestaDocument.new
277
+ l1 = Layer.new(identifier: 'l1', name: 'l1', document: @f)
278
+ @f.layers << l1
279
+ (1..4).each do |n|
280
+ @f.add_item(nil) do |i|
281
+ i.add_layer_link LayerLink.new(identifier: "#{i.identifier}-ll", role: '', target_object: l1, document: @f)
282
+ i.data=Mexico::FileSystem::Data.new(map_value: {key: "#{n}"})
283
+ end
284
+ end
285
+
286
+ @f.items.each do |i|
287
+ puts i.data
288
+ puts "-"*80
289
+ puts i.data.is_string?
290
+ puts i.data.is_map?
291
+ puts "-"*80
292
+ puts i.data.string_value
293
+ puts i.data.map_value
294
+ puts i.data.list_value
295
+ puts "-"*80
296
+
297
+ end
298
+ Mexico::Constraints::FiestaConstraints::VALUES_STRINGS_ONLY.evaluate(@f).should eq false
299
+ Mexico::Constraints::FiestaConstraints::VALUES_MAPS_ONLY.evaluate(@f).should eq true
300
+ end
301
+
302
+ end
303
+
304
+ end
305
+
306
+ end
@@ -0,0 +1,50 @@
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::Core::MediaType do
22
+
23
+
24
+ # set up an initial corpus representation from the example file
25
+ before(:each) do
26
+ @basepath = File.join(File.dirname(__FILE__), '..','..','assets','TESTCORPUS')
27
+ @xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
28
+ @corpus = Mexico::FileSystem::Corpus.from_xml(@xml, {:path => @basepath})
29
+ @resource = @corpus.resources.first
30
+ end
31
+
32
+ context 'Read MediaType field' do
33
+
34
+ it 'should respond to all methods' do
35
+ @resource.should respond_to(:media_type_id)
36
+ @resource.should respond_to(:media_type)
37
+ @resource.should respond_to(:media_type_id=)
38
+ @resource.should respond_to(:media_type=)
39
+ end
40
+
41
+ it 'should default to OTHER if not given' do
42
+ @resource.media_type_id.should be nil
43
+ @resource.media_type.should eq Mexico::Constants::MediaTypes::OTHER
44
+ end
45
+
46
+
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,43 @@
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__), '..', '..'
25
+ @assetspath = File.join @basepath, 'assets'
26
+ end
27
+
28
+ context 'Fiesta ' do
29
+ context 'Interfaces ' do
30
+ context 'B6 Chat Game ' do
31
+ it 'reads data from a test file' do
32
+ path = File.join @assetspath, 'fiesta', 'b6'
33
+ filename = File.join path, 'match_jones_161_CM_neu_checked.parsed.xml'
34
+ @fdoc = ::Mexico::Fiesta::Interfaces::B6ChatGameInterface.instance.import(File.read(filename))
35
+ File.open(File.join(path,'test.out.fst'),'w') do |f|
36
+ f << @fdoc.to_xml
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,43 @@
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::Fiesta::Interfaces::ElanInterface do
22
+
23
+ before(:each) do
24
+ @basepath = File.join File.dirname(__FILE__), '..', '..'
25
+ @assetspath = File.join @basepath, 'assets'
26
+ end
27
+
28
+ context 'Fiesta ' do
29
+ context 'Interfaces ' do
30
+ context 'Elan ' do
31
+ it 'reads data from a test file' do
32
+ path = File.join @assetspath, 'fiesta', 'elan'
33
+ filename = File.join path, 'ElanFileFormat.eaf'
34
+ @fdoc = ::Mexico::Fiesta::Interfaces::ElanInterface.import(File.open(filename))
35
+ File.open(File.join(path,'test.out.fst'),'w') do |f|
36
+ f << @fdoc.to_xml
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,54 @@
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__), '..', '..'
25
+ @path = File.join @basepath, 'assets', 'fiesta', 'head'
26
+ @filename = File.join(@path,'head.fst')
27
+ @fdoc = ::Mexico::FileSystem::FiestaDocument.open(@filename)
28
+ end
29
+
30
+ context 'Fiesta' do
31
+ context 'Head' do
32
+
33
+ it 'should read all head entries correctly' do
34
+
35
+ @fdoc.head.should_not be nil
36
+ @fdoc.head.head_sections.size.should > 0
37
+
38
+ @fdoc.head.head_sections.first.key.should eq 'vocabularies'
39
+ @fdoc.head.head_sections.first.key.should_not eq 'waterlily'
40
+
41
+
42
+
43
+ end
44
+
45
+ it 'should write correct head info out' do
46
+ @outfilename = File.join(@path,'head.OUT.fst')
47
+ File.open @outfilename, 'w' do |f|
48
+ f << @fdoc.to_xml
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,54 @@
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::Fiesta::Interfaces::ShortTextGridInterface do
22
+
23
+ before(:each) do
24
+ @basepath = File.join File.dirname(__FILE__), '..', '..'
25
+ @assetspath = File.join @basepath, 'assets'
26
+ end
27
+
28
+ context 'Fiesta ' do
29
+ context 'Interfaces ' do
30
+ context 'Praat ' do
31
+ it 'reads data from a short text grid file' do
32
+ path = File.join @assetspath, 'fiesta', 'praat'
33
+ filename = File.join path, 'mexico.ShortTextGrid'
34
+ @fdoc = ::Mexico::Fiesta::Interfaces::ShortTextGridInterface.import(File.open(filename))
35
+
36
+ File.open(File.join(path,'mexico.ShortTextGrid.out.fst'),'w') do |f|
37
+ f << @fdoc.to_xml
38
+ end
39
+ end
40
+ it 'reads data from a text grid file' do
41
+ path = File.join @assetspath, 'fiesta', 'praat'
42
+ filename = File.join path, 'mexico.TextGrid'
43
+ @fdoc = ::Mexico::Fiesta::Interfaces::TextGridInterface.import(File.open(filename))
44
+
45
+ File.open(File.join(path,'mexico.TextGrid.out.fst'),'w') do |f|
46
+ f << @fdoc.to_xml
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,76 @@
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__), '..', '..'
25
+
26
+ end
27
+
28
+ context 'Fiesta ' do
29
+ context 'Read Fiesta files' do
30
+ it 'reads data from a fiesta file' do
31
+ @path = File.join @basepath, 'assets', 'fiesta', 'b6'
32
+ @filename = File.join(@path,'test.out.fst')
33
+ @fdoc = ::Mexico::FileSystem::FiestaDocument.open(@filename)
34
+ @fdoc.should_not be nil
35
+ end
36
+
37
+ it 'writes data to a dot file' do
38
+ @path = File.join @basepath, 'assets', 'fiesta', 'b6'
39
+ @filename = File.join(@path,'test.out.fst')
40
+ @fdoc = ::Mexico::FileSystem::FiestaDocument.open(@filename)
41
+ @fdoc.should_not be nil
42
+ @outfile = File.join(@path,'test.dot')
43
+ File.open(@outfile, 'w') do |f|
44
+ ::Mexico::Fiesta::Interfaces::DotInterface.instance.export @fdoc, f
45
+ end
46
+ end
47
+
48
+
49
+ it 'handles maps' do
50
+ @path = File.join @basepath, 'assets', 'fiesta', 'b6'
51
+ @filename = File.join(@path,'map.fst')
52
+ @fdoc = ::Mexico::FileSystem::FiestaDocument.open(@filename)
53
+ @fdoc.should_not be nil
54
+ puts "="*32
55
+ @outfile = File.join(@path,'map.OUT.fst')
56
+ File.open(@outfile, 'w') do |f|
57
+ f << @fdoc.to_xml
58
+ end
59
+ end
60
+
61
+
62
+ it 'reads layer connectors properly' do
63
+
64
+ @path = File.join @basepath, 'assets', 'fiesta', 'b6'
65
+ @filename = File.join(@path,'layer_connectors.fst')
66
+ @fdoc = ::Mexico::FileSystem::FiestaDocument.open(@filename)
67
+ @fdoc.layer_connectors.size.should be 2
68
+
69
+ ffirst = @fdoc.layer_connectors.first
70
+ ffirst.identifier.should eq 'chats_to_sentences'
71
+
72
+ end
73
+
74
+ end
75
+ end
76
+ end