Class: PROIEL::AnnotationSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/proiel/annotation_schema.rb

Overview

A representation of the annotation schema found in the header of a PROIEL XML file. This should not be confused with the PROIEL XML schema, which is used for validating the XML in a PROIEL XML file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_object) ⇒ AnnotationSchema

Creates a new annotation schema object.



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/proiel/annotation_schema.rb', line 24

def initialize(xml_object)
  if xml_object
    @part_of_speech_tags = make_part_of_speech_tags(xml_object).freeze
    @relation_tags = make_relation_tags(xml_object).freeze
    @morphology_tags = make_morphology_tags(xml_object).freeze
    @information_status_tags = make_information_status_tags(xml_object).freeze
  else
    @part_of_speech_tags = {}.freeze
    @relation_tags = {}.freeze
    @morphology_tags = {}.freeze
    @information_status_tags = {}.freeze
  end
end

Instance Attribute Details

#information_status_tagsHash<String,InformationStatusTagDefinition> (readonly)

Returns definition of information status tags.

Returns:



21
22
23
# File 'lib/proiel/annotation_schema.rb', line 21

def information_status_tags
  @information_status_tags
end

#morphology_tagsHash<Symbol,Hash<String,MorphologyFieldTagDefinition>> (readonly)

Returns definition of morphology tags.

Returns:



18
19
20
# File 'lib/proiel/annotation_schema.rb', line 18

def morphology_tags
  @morphology_tags
end

#part_of_speech_tagsHash<String,PartOfSpeechTagDefinition> (readonly)

Returns definition of part of speech tags.

Returns:



12
13
14
# File 'lib/proiel/annotation_schema.rb', line 12

def part_of_speech_tags
  @part_of_speech_tags
end

#relation_tagsHash<String,RelationTagDefinition> (readonly)

Returns definition of relation tags.

Returns:



15
16
17
# File 'lib/proiel/annotation_schema.rb', line 15

def relation_tags
  @relation_tags
end

Instance Method Details

#==(o) ⇒ true, false

Tests for equality of two annotation schema objects.

Returns:

  • (true, false)


52
53
54
55
# File 'lib/proiel/annotation_schema.rb', line 52

def ==(o)
  @part_of_speech_tags.sort_by(&:first) == o.part_of_speech_tags.sort_by(&:first) and
    @relation_tags.sort_by(&:first) == o.relation_tags.sort_by(&:first)
end

#primary_relationsHash<String,RelationTagDefinition>

Returns definition of primary relation tags.

Returns:



39
40
41
# File 'lib/proiel/annotation_schema.rb', line 39

def primary_relations
  @relation_tags.select { |_, features| features.primary }
end

#secondary_relationsHash<String,RelationTagDefinition>

Returns definition of secondary relation tags.

Returns:



44
45
46
# File 'lib/proiel/annotation_schema.rb', line 44

def secondary_relations
  @relation_tags.select { |_, features| features.secondary }
end