NAME
Library - Perl extension for Digital Library support
SYNOPSIS
use Library;
$a = mkdiglib($conf)
DESCRIPTION
Library is a module for managing a digital library. It is composed of three other modules named news, catalog and thesaurus. You can read the documentation for each of them in the corresponding pod file. To use this module there is only the need of using Library::Thesaurus. The other two modules are totally optional.
The main purpose of this module is to maintain the relation between one or more catalogs and a thesaurus. While we need that the user define a thesaurus and process it with the Library::Thesaurus module, the catalog can be implemented in any way the user wants.
To this be possible, it should be some way to access any kind of catalog: a plain text file, XML document, SQL database or anything else. The only method possible is to define functions to convert these implementation techniques into a mathematical definition. So, the user should give four functions to this module to it be capable of use the catalog. These functions are:
Given a string (say, a catalog identifier) the function should return a Perl array with all catalog entries. This array should be the same everytime the function is called for the same catalog to maintain some type of indexing. The function can use this string as a filename, a SQL table identifier or anything else the function can understand.
Given an entry with the format returned by the previous function, this function should return a list of terms related to the object catalogued by this entry. These terms will be used latter for thesaurus integration.
Given an entry, return a piece of HTML code to be embebed when listing records.
Given an entry, return the searchable text it includes.
The following example shows a sample configuration:
$userconf = {
catfile => '/var/library/catalog',
thesaurus => '/var/library/thesaurus',
name => 'library name',
catsyn => {
1 => sub{ my $file=shift;
my $t=`cat $file`;
return ($t =~ m{(<entry.*?</entry>)}gs); },
2 => sub{ ay $f=shift;
my @r=();
while($f =~ m{<rel\s+tipo='(.*?)'>(.*?)</rel>}g)
{ push @r, $2; }
@r; },
3 => sub{ my $f=shift; &mp::cat::fichacat2html($f)},
4 => sub{ my $f=shift;
$f =~ s{</?\w+}{ }g;
$f =~ s/(\s*[\n>"'])+\s*/,/g;
$f =~ s/\w+=//g;
$f =~ s/\s{2,}/ /g;
$f } } };
When using the mkdiglib
function with this configuration information, the module will create a set of files with cached data for quick response. This function returns a Library object.
After creating the object, we can open it on another script with the opendiglib
command wich receives the base name of the digital library. The base name is the path where it was created concatenated with the identifier used.
To consult these object, one can use some of the following methods:
Given a thesaurus term, return a HTML string with the catalog entries related to the term. It is used a transitive closure in a way that some entries without that term will be matched because they contain a term wich is related with the searched one.
The same thing as the above but for more than one term.
Given a regular expression, return the HTML corresponding with the matched entries.
This is a mix of 1 with 3. Given a term and regular expression, return the intersection result.
AUTHOR
José João Almeida <jj@di.uminho.pt>
Alberto Simões <albie@alfarrabio.di.uminho.pt>
SEE ALSO
perl(1).
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 297:
Non-ASCII character seen before =encoding in 'José'. Assuming CP1252