forked from icl/elan_parser
/
helper.rb
executable file
·52 lines (42 loc) · 1.21 KB
/
helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module ElanParser
module Helper
class Validator
def validate_elan_xml(document_xml)
xsd = Nokogiri::XML::Schema(File.open("assets/EAFv2.7.xsd"))
is_valid = xsd.validate(document_xml)
return is_valid
end
end
class Destroyer
def destroy_children(annotation_document)
annotation_document.header.media_descriptors.each do |md|
md.destroy
end
annotation_document.header.properties.each do |p|
p.destroy
end
annotation_document.tiers.each do |t|
t.annotations.each do |a|
a.alignable_annotation.alignable_annotation_time_slot.time_slot_ref1.delete
a.alignable_annotation.alignable_annotation_time_slot.time_slot_ref2.delete
a.alignable_annotation.destroy
a.destroy
end
t.destroy
end
annotation_document.time_order.time_slots.each do |ts|
ts.destroy
end
annotation_document.linguistic_types.each do |l|
l.destroy
end
annotation_document.constraints.each do |c|
c.destroy
end
annotation_document.locales.each do |l|
l.destroy
end
end
end
end
end