MEAD

Cluster

Included libraries Package variables General documentation Methods

Package variables top
Privates (from my definitions)
$lang;
@read_cluster_DIDs;
Included modulestop
MEAD::Document
MEAD::MEAD
XML::Parser
strict
Inherit top
Exporter
Synopsistop
No synopsis!
Descriptiontop
No description!
Methodstop
flatten_clusterNo descriptionCode
load_clusterNo descriptionCode
read_clusterNo descriptionCode
read_cluster_handle_startNo descriptionCode

Methods description


Methods code

flatten_clusterdescriptiontopprevnext
sub flatten_cluster {
    my $cluster = shift;

    my @flattened_cluster = ();

    foreach my $did (keys %{$cluster}) {

	my $docref = $$cluster{$did};

        for (my $sno = 1; $sno < @{$docref}; $sno++) {

	    my $sentref = $$docref[$sno];
	    next unless $sentref;

	    my %sentence = ();

	    $sentence{'DID'} = $did;
	    $sentence{'SNO'} = $sno;

            foreach my $key (keys %{$sentref}) {
		$sentence{$key} = $$sentref{$key};
            }

	    push @flattened_cluster,\% sentence;
        }
    }

    return\@ flattened_cluster;
}
load_clusterdescriptiontopprevnext
sub load_cluster {
    my $datadir = shift;
    my @DIDs = @_;

    my $result = {};

    foreach my $DID (@DIDs) {
	my $document_filename = &DID_to_docsent_filename($DID,$datadir);
	$$result{$DID} = read_document($DID, $document_filename);
    }

    return $result;
}
read_clusterdescriptiontopprevnext
sub read_cluster {
    my $cluster_arg = shift;
    my $datadir = shift;
    
    @read_cluster_DIDs = ();

    my $xml_parser = new XML::Parser(Handlers => {
	Start =>\& read_cluster_handle_start});

    ## $cluster_arg can be a filehandle, a stream, or a filename.
if (ref $cluster_arg) { $xml_parser->parse($cluster_arg); } else { $xml_parser->parsefile($cluster_arg); } my $result = {}; foreach my $DID (@read_cluster_DIDs) { my $document_filename = &DID_to_docsent_filename($DID, $datadir); $$result{$DID} = read_document($DID, $document_filename); } return $result;
}
read_cluster_handle_startdescriptiontopprevnext
sub read_cluster_handle_start {
    shift;
    my $element_name = shift;
    my %atts = @_;

    if ($element_name eq 'CLUSTER') {
	$lang = $atts{'LANG'};
    } elsif ($element_name eq 'D') {
	push @read_cluster_DIDs, $atts{'DID'};
    }
}

General documentation

No general documentation available.