| Summary | Package variables | Synopsis | Description | General documentation | Methods |
| Summary | Top |
| Clair::MEAD::Summary - access to a MEAD summary |
| Package variables | Top |
| No package variables defined. |
| Included modules | Top |
| Carp |
| Synopsis | Top |
use Clair::MEAD::Wrapper; |
| Description | Top |
| Clair::MEAD::Summary is used to access a MEAD summary produced by MEAD::Wrapper. It includes methods to access the sentences, and their features. Clair::MEAD::Summary should only be obtained from other objects and never directly instantiated. The order of the sentences in the document is determined by two things. First, sentences from the same document are always in the same relative position as they were in the original document. Second, since there is no natural ordering of documents, there is a method that can be used to set the prefered document order. The default order is determined by Perl's sort function applied to the document ids. |
| Methods | Top |
| _cmp | No description | Code |
| _get_sent_attr | No description | Code |
| _sent_in_range | No description | Code |
| _sort_sents | No description | Code |
| get_centroid | No description | Code |
| get_did | No description | Code |
| get_dids | No description | Code |
| get_features | No description | Code |
| get_order | No description | Code |
| get_par | No description | Code |
| get_rsnt | No description | Code |
| get_sent | No description | Code |
| get_sno | No description | Code |
| get_text | No description | Code |
| new | No description | Code |
| set_doc_order | No description | Code |
| size | No description | Code |
| to_string | No description | Code |
| _cmp | description | prev | next | Top |
sub _cmp
{
my $self = shift;
my ($s1, $s2) = @_;
my $did1 = $s1->{did};
my $did2 = $s2->{did};
my %order = %{ $self->{_doc_order} };
if ($order{$did1} < $order{$did2}) {
return -1;
} elsif ($order{$did1} > $order{$did2}) {
return 1;
} else {
return $s1->{sno} <=> $s2->{sno};
}} |
| _get_sent_attr | description | prev | next | Top |
sub _get_sent_attr
{
my $self = shift;
my $i = shift;
my $attr = shift;
if ($self->_sent_in_range($i)) {
my %sent = $self->get_sent($i);
return $sent{$attr};
} else {
return undef;
}} |
| _sent_in_range | description | prev | next | Top |
sub _sent_in_range
{ my $self = shift;
my $i = shift;
return ( $i <= $self->size() and $i > 0 );} |
| _sort_sents | description | prev | next | Top |
sub _sort_sents
{
my $self = shift;
my @sents = @{ $self->{_sents} };
my @sorted = sort { $self->_cmp($a, $b) } @sents;
$self->{_sents} =\@ sorted;} |
| get_centroid | description | prev | next | Top |
sub get_centroid
{
my $self = shift;
return %{ $self->{_centroid} };} |
| get_did | description | prev | next | Top |
sub get_did
{ my $self = shift;
my $i = shift;
return $self->_get_sent_attr($i, "did");} |
| get_dids | description | prev | next | Top |
sub get_dids
{
my $self = shift;
return @{ $self->{_dids} };} |
| get_features | description | prev | next | Top |
sub get_features
{
my $self = shift;
my @sents = @{ $self->{_sents} };
my $i = shift;
if ($self->_sent_in_range($i)) {
return %{ $sents[$i - 1]->{feats} };
} else {
return undef;
}} |
| get_order | description | prev | next | Top |
sub get_order
{ my $self = shift;
my $i = shift;
return $self->_get_sent_attr($i, "order");} |
| get_par | description | prev | next | Top |
sub get_par
{ my $self = shift;
my $i = shift;
return $self->_get_sent_attr($i, "par");} |
| get_rsnt | description | prev | next | Top |
sub get_rsnt
{ my $self = shift;
my $i = shift;
return $self->_get_sent_attr($i, "rsnt");} |
| get_sent | description | prev | next | Top |
sub get_sent
{
my $self = shift;
my @sents = @{ $self->{_sents} };
my $i = shift;
unless ($self->_sent_in_range($i)) {
return undef;
}
my $sentref = $sents[$i - 1];
my %sent = (
text => $sentref->{text},
sno => $sentref->{sno},
did => $sentref->{did},
rsnt => $sentref->{rsnt},
par => $sentref->{par},
order => $sentref->{order}
);
return %sent;} |
| get_sno | description | prev | next | Top |
sub get_sno
{ my $self = shift;
my $i = shift;
return $self->_get_sent_attr($i, "sno");} |
| get_text | description | prev | next | Top |
sub get_text
{ my $self = shift;
my $i = shift;
return $self->_get_sent_attr($i, "text");} |
| new | description | prev | next | Top |
sub new
{
my $class = shift;
my $extract = shift;
my $centroid = shift;
croak "Extract not defined" unless (@$extract);
$centroid = {} unless ($centroid);
my $i = 1;
my @sents;
my %uniq_dids;
foreach my $sent (@$extract) {
my ($text, $did, $sno, $rsnt, $par, $feats) =
($sent->{TEXT}, $sent->{DID}, $sent->{SNO}, $sent->{RSNT},
$sent->{PAR}, $sent->{FEATURES});
if ($text and $did and $sno and $rsnt and $par and $feats) {
$uniq_dids{$did} = 1;
push @sents, {
text => $text, did => $did, sno => $sno,
rsnt => $rsnt, par => $par, feats => $feats, order => $i
};
} else {
carp "Sentence $i malformed, skipping";
next;
}
$i++;
}
croak "Empty summary" unless @sents;
my @dids = keys %uniq_dids;
my %doc_order;
my $count = 1;
map { $doc_order{$_} = $count++ } sort @dids;
my $self = {
_sents =>\@ sents,
_dids =>\@ dids,
_doc_order =>\% doc_order
};
bless $self, $class;
$self->_sort_sents();
return $self;} |
| set_doc_order | description | prev | next | Top |
sub set_doc_order
{
my $self = shift;
my %order = @_;
my @dids = @{ $self->{_dids} };
foreach my $did (@dids) {
return undef unless $order{$did};
}
$self->{_doc_order} =\% order;
$self->_sort_sents();
return %order;} |
| size | description | prev | next | Top |
sub size
{
my $self = shift;
return scalar @{ $self->{_sents} };} |
| to_string | description | prev | next | Top |
sub to_string
{
my $self = shift;
my @sents = @{ $self->{_sents} };
return join " ", map { $_->{text} } @sents;} |