isa => 'Bool',
default => undef,
);
+
+has 'is_common' => (
+ is => 'rw',
+ isa => 'Bool',
+ default => undef,
+ );
has 'rank' => (
is => 'rw',
} else {
$args = { @_ };
}
-
- # Did we get a JSON token to parse into a reading? If so, massage it.
- if( exists $args->{'json'} ) {
- my $j = delete $args->{'json'};
-
- # If we have separated punctuation, restore it.
- if( exists $j->{'punctuation'} ) {
- $args->{'text'} = _restore_punct( $j->{'t'}, $j->{'punctuation'} );
- } else {
- $args->{'text'} = $j->{'t'};
- # we don't use comparison or canonical forms yet
- }
- }
-
+
# If one of our special booleans is set, we change the text and the
# ID to match.
if( exists $args->{'is_lacuna'} && !exists $args->{'text'} ) {
$class->$orig( $args );
};
-# Utility function for parsing JSON from nCritic
-sub _restore_punct {
- my( $word, @punct ) = @_;
- foreach my $p ( sort { $a->{pos} <=> $b->{pos} } @punct ) {
- substr( $word, $p->{pos}, 0, $p->{char} );
- }
- return $word;
-}
-
=head2 is_meta
A meta attribute (ha ha), which should be true if any of our 'special'
return $self->is_start || $self->is_end || $self->is_lacuna || $self->is_ph;
}
-# Some syntactic sugar
+=head1 Convenience methods
+
+=head2 related_readings
+
+Calls Collation's related_readings with $self as the first argument.
+
+=cut
+
sub related_readings {
my $self = shift;
return $self->collation->related_readings( $self, @_ );
}
+=head2 predecessors
+
+Returns a list of Reading objects that immediately precede $self in the collation.
+
+=cut
+
sub predecessors {
my $self = shift;
my @pred = $self->collation->sequence->predecessors( $self->id );
return map { $self->collation->reading( $_ ) } @pred;
}
+=head2 successors
+
+Returns a list of Reading objects that immediately follow $self in the collation.
+
+=cut
+
sub successors {
my $self = shift;
my @succ = $self->collation->sequence->successors( $self->id );
return map { $self->collation->reading( $_ ) } @succ;
}
+=head2 set_identical( $other_reading)
+
+Backwards compatibility method, to add a transposition relationship
+between $self and $other_reading. Don't use this.
+
+=cut
+
sub set_identical {
my( $self, $other ) = @_;
return $self->collation->add_relationship( $self, $other,