« blib/lib/Lingua/Ogmios/Annotations/AnaphoraRelation.pm
↑ Summary
blib/lib/Lingua/Ogmios/Annotations/Stem.pm »
| 1 | package Lingua::Ogmios::Annotations::DomainSpecificRelation; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Lingua::Ogmios::Annotations::Element; | ||
| 7 | our @ISA = qw(Lingua::Ogmios::Annotations::Element); | ||
| 8 | |||
| 9 | # <!-- =================================================== --> | ||
| 10 | # <!-- DOMAIN_SPECIFIC_RELATION_LEVEL --> | ||
| 11 | # <!-- =================================================== --> | ||
| 12 | |||
| 13 | # <!-- domain_specific_relation --> | ||
| 14 | # <!ELEMENT domain_specific_relation | ||
| 15 | # (id, log_id?, | ||
| 16 | # domain_specific_relation_type, | ||
| 17 | # list_refid_semantic_unit) > | ||
| 18 | |||
| 19 | # <!-- domain_specific_relation_type --> | ||
| 20 | # <!ELEMENT domain_specific_relation_type (#PCDATA) > | ||
| 21 | |||
| 22 | # <!ELEMENT list_refid_semantic_unit (refid_semantic_unit)+ > | ||
| 23 | # <!ELEMENT refid_semantic_unit (#PCDATA) > | ||
| 24 | |||
| 25 | |||
| 26 | sub new { | ||
| 27 | my ($class, $fields) = @_; | ||
| 28 | |||
| 29 | if (!defined $fields->{'id'}) { | ||
| 30 | $fields->{'id'} = -1; | ||
| 31 | } | ||
| 32 | if (!defined $fields->{'domain_specific_relation_type'}) { | ||
| 33 | die("domain_specific_relation_type is not defined"); | ||
| 34 | } | ||
| 35 | if (!defined $fields->{'list_refid_semantic_unit'}) { | ||
| 36 | die("list_refid_semantic_unit is not defined"); | ||
| 37 | } | ||
| 38 | my $domainspecificrelation = $class->SUPER::new({ | ||
| 39 | 'id' => $fields->{'id'}, | ||
| 40 | # 'form' => $fields->{'form'}, | ||
| 41 | } | ||
| 42 | ); | ||
| 43 | bless ($domainspecificrelation,$class); | ||
| 44 | |||
| 45 | $domainspecificrelation->list_refid_semantic_unit($fields->{'list_refid_semantic_unit'}); | ||
| 46 | $domainspecificrelation->domain_specific_relation_type($fields->{'domain_specific_relation_type'}); | ||
| 47 | |||
| 48 | if (defined $fields->{'log_id'}) { | ||
| 49 | $domainspecificrelation->setLogId($fields->{'log_id'}); | ||
| 50 | } | ||
| 51 | return($domainspecificrelation); | ||
| 52 | } | ||
| 53 | |||
| 54 | sub list_refid_semantic_unit { | ||
| 55 | my $self = shift; | ||
| 56 | |||
| 57 | my $ref; | ||
| 58 | my $elt; | ||
| 59 | |||
| 60 | if (@_) { | ||
| 61 | $self->{'reference'} = 'list_refid_semantic_unit'; | ||
| 62 | $self->{$self->{'reference'}} = []; | ||
| 63 | $ref = shift; | ||
| 64 | if (ref($ref) eq "ARRAY") { | ||
| 65 | foreach $elt (@$ref) { | ||
| 66 | # warn $elt->getForm . "\n"; | ||
| 67 | push @{$self->{$self->{'reference'}}}, $elt; | ||
| 68 | } | ||
| 69 | } else { | ||
| 70 | if (ref($ref) eq "HASH") { | ||
| 71 | foreach $elt (keys %$ref) { | ||
| 72 | # warn $elt->getForm . "\n"; | ||
| 73 | push @{$self->{$self->{'reference'}}}, { $elt => $ref->{$elt}}; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } | ||
| 78 | return($self->{$self->{'reference'}}); | ||
| 79 | |||
| 80 | # $self->{'list_refid_semantic_unit'} = shift if @_; | ||
| 81 | # return($self->{'list_refid_semantic_unit'}); | ||
| 82 | } | ||
| 83 | |||
| 84 | sub domain_specific_relation_type { | ||
| 85 | my $self = shift; | ||
| 86 | |||
| 87 | $self->{'domain_specific_relation_type'} = shift if @_; | ||
| 88 | return($self->{'domain_specific_relation_type'}); | ||
| 89 | } | ||
| 90 | |||
| 91 | sub XMLout { | ||
| 92 | my ($self, $order) = @_; | ||
| 93 | |||
| 94 | return($self->SUPER::XMLout("domain_specific_relation", $order)); | ||
| 95 | } | ||
| 96 | |||
| 97 | sub reference { | ||
| 98 | my ($self) = @_; | ||
| 99 | |||
| 100 | return($self->list_refid_semantic_unit); | ||
| 101 | } | ||
| 102 | |||
| 103 | 1; | ||
| 104 | |||
| 105 | __END__ |