| Summary | Package variables | Synopsis | Description | General documentation | Methods |
| Summary | Top |
| Clair::IDF - Provides access to an inverse document frequency (IDF) database. |
| Package variables | Top |
| No package variables defined. |
| Included modules | Top |
| Config |
| File::Spec |
| MEAD::MEAD |
| Synopsis | Top |
use Clair::IDF
open_nidf($dbmname);
my $idf = get_nidf("word");
my $output = ($idf == $Clair::IDF::DEFAULT_UNKNOWN_IDF
? "unknown"
: $idf);
print qq(IDF of "word": $output\n); |
| Description | Top |
| This module provides access to an inverse document frequency (IDF) database via a tied hash. If $dbmname is not supplied, the database name is assumed to be $Clair::IDF::DEFAULT_DBMNAME. In any case, calling open_nidf() sets $Clair::IDF::current_dbmname to the name of the database being opened, which is assumed to be located in $Clair::IDF::$IDFDIR. Calling get_nidf($word) returns the IDF of $word in the database opened by open_nidf(), or $Clair::IDF::DEFAULT_UNKNOWN_IDF if the IDF is not known. |
| Methods | Top |
| get_nidf | No description | Code |
| open_nidf | No description | Code |
| get_nidf | description | prev | next | Top |
sub get_nidf
{
my $word = shift;
unless (defined $current_dbmname) {
open_nidf($DEFAULT_DBMNAME);
}
if (defined $nidf{$word}) {
return $nidf{$word};
}
return $DEFAULT_UNKNOWN_IDF;} |
| open_nidf | description | prev | next | Top |
sub open_nidf
{ my $dbmname = shift || $DEFAULT_DBMNAME;
if ($dbmname eq $DEFAULT_DBMNAME) {
$dbmname = File::Spec->rel2abs($dbmname, $IDFDIR);
}
if ($current_dbmname && $current_dbmname eq $dbmname) {
return 1;
}
unless (dbmopen %nidf, $dbmname, 0666) {
die "Cannot open DBM $dbmname: $!";
}
unless (scalar(keys(%nidf))) {
die "Empty DBM $dbmname";
}
$current_dbmname = $dbmname;
return 1;} |
| EXPORTS | Top |
open_nidf()
get_nidf() |
| CONFIGURATION AND ENVIRONMENT | Top |
$current_dbmname # last dbmname opened by open_nidf() $DEFAULT_DBMNAME = "enidf"; $DEFAULT_UNKNOWN_IDF = 3; $IDFDIR = File::Spec->catdir($MEAD::MEAD::MEADDIR, "etc"); |
| DEPENDENCIES | Top |
Exporter File::Spec MEAD::MEAD |
| BUGS AND LIMITATIONS | Top |
| There are no known bugs in this module. Please report problems to Dragomir R. Radev (radev@umich.edu). Patches are welcome. |
| SEE ALSO | Top |
Clair::Utils::TF |
| AUTHOR | Top |
| Dragomir R. Radev (radev@umich.edu) |
| LICENCE AND COPYRIGHT | Top |
| Copyright (c) 2007 the Clair group, all rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |