Ed Summers > MARC-SubjectMap-0.92 > MARC::SubjectMap

Download:
MARC-SubjectMap-0.92.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.93   Source  

NAME ^

MARC::SubjectMap - framework for translating subject headings

SYNOPSIS ^

    use MARC::SubjectMap;
    my $map = MARC::SubjectMap->newFromConfig( "config.xml" );

    my $batch = MARC::Batch->new( 'USMARC', 'batch.dat' );
    while ( my $record = $batch->next() ) {
        my $new = $map->translateRecord( $record );
        ...
    }

DESCRIPTION ^

MARC::SubjectMap is a framework for providing translations of subject headings. MARC::SubjectMap is essentially a configuration which contains a list of fields/subfields to translate or copy, and a list of rules for translating one field/subfield value into another.

Typical usage of the framework will be to use the subjmap-template command line application to generate a template XML configuration from a batch of MARC records. You tell subjmap-template the fields you'd like to translate and/or copy and it will look through the records and extract and add rule templates for the unique values. For example:

    subjmap-template --in=marc.dat --out=config.xml --translate=650ab 

Once the template configuration has been filled in with translations, the MARC batch file can be run through another command line utility called subjmap which will add new subject headings where possible using the configuration file. If a subject headings can't be translated it will be logged to a file so that the configuration file can be improved if necessary.

    subjmap --in=marc.dat --out=new.dat --config=config.xml --log=log.txt

The idea is that all the configuration is done in the XML file, and the command line programs take care of driving these modules for you. Methods and related modules are listed below for the sake of completeness, and if you want to write your own driving program for some reason.

METHODS ^

new()

The constructor which accepts no arguments.

newFromConfig()

Factory method for creating a MARC::SubjectMap object from an XML configuration. If there is an error you will get it on STDERR.

    my $mapper = MARC::SubjectMap->new( 'config.xml' ); 

writeConfig()

Serializes the configuration to disk as XML.

addField()

Adds a field specification to the configuration. Each specification defines the fields and subfields to look for and copy/translate in MARC data. The information is bundled up in a MARC::SubjectMap::Field object.

fields()

Returns a list of MARC::SubjectMap::Field objects which specify the fields/subfields in MARC data that will be copied and/or translated.

rules()

Get/set the rules being used in this configuration. You should pass in a MARC::SubjectMap::Rules object if you are setting the rules.

    $map->rules( $rules );

The reason why a sepearte object is used to hold the Rules as opposed to the fields being contained in the MARC::SubjectMap object is that there can be many (thousands perhaps) of rules -- which need to be stored differently than the handful of fields.

sourceLanguage()

Option for specifying the three digit language code to be expected in translation records. If a record is passed is translated that is not of the expected source language then a log message will be generated.

translateRecord()

Accepts a MARC::Record object and returns a translated version of it if there were any translations that could be performed. If no translations were possible undef will be returned.

stats()

Returns a hash of statistics for conversions performed by a MARC::SubjectMap object.

setLog()

Set a file to send diagnostic messages to. If unspecified messages will go to STDERR. Alternatively you can pass in a IO::Handle object.

SEE ALSO ^

AUTHORS ^

syntax highlighting: