is => 'rw',
isa => 'Int',
predicate => 'has_rank',
+ clearer => 'clear_rank',
);
+
+## For morphological analysis
+
+has 'normal_form' => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_normal_form',
+ );
+
+has 'lemma' => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_lemma',
+ );
+
+has 'morphology' => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_morphology',
+ );
+
+has 'morph_possibilities' => (
+ is => 'ro',
+ isa => 'HashRef[Str]',
+ default => sub { {} },
+ );
+
+## For prefix/suffix readings
+
+has 'join_prior' => (
+ is => 'ro',
+ isa => 'Bool',
+ default => undef,
+ );
+
+has 'join_next' => (
+ is => 'ro',
+ isa => 'Bool',
+ default => undef,
+ );
around BUILDARGS => sub {
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 witnesses
+
+Calls Collation's reading_witnesses with $self as the first argument.
+
+=cut
+
+sub witnesses {
+ my $self = shift;
+ return $self->collation->reading_witnesses( $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,
return $self->id;
}
+sub TO_JSON {
+ my $self = shift;
+ return $self->text;
+}
+
no Moose;
__PACKAGE__->meta->make_immutable;