Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

about dumping inverted file (*.inv) in freeWAIS-sf-2.1.2

0 views
Skip to first unread message

Shigeru Ishida

unread,
Jan 12, 1998, 3:00:00 AM1/12/98
to

石田@インテック・システム研究所です。

freeWAIS-sf-2.1.2 で作成する転置インデックスファイルをダンプする
ツールに inverted_file (perl script) がありますが、以下は、これを
little endian で機能するようにしたものです。(inverted_file.le)

keyword, weight, occurrence を表示しますが、keyword の出現位置は
表示しません。

inverted_file.le により、FreeBSD など pentium 系で作成した転置
インデックスを閲覧することができます。なお、SPARC など big endian
系で作成したものも表示できます。


== ここより ===================================================================
#!/usr/local/bin/perl
#
# inverted_file.le
#
# This program is based on inverted_file in freeWAIS-sf-2.1.2/bin
# to be available on little endian.
#

$db = $ARGV[0];

open(INV, "<$db.inv") || die "Could not open $db.inv: $!\n";

if ($#ARGV > $[) {
seek(INV,$ARGV[1],0);
&entry;
} else {
read(INV,$head,4);
($nib) = unpack('N', $head);
print "$db.inv contains $nib terms\n";
$terms=0;

while (!eof(INV)) {
&header();
&entry();
$terms++;
}
}

sub entry {
my($np, $i);
$np = &header_rest();
for($i=0;$i<$np;$i++) {
&posting($np);
}
}

sub header {
my($entry, $df, $x, $y, $next_1, $size_1, $postings,
$occ, $term);
read(INV,$entry,13);

($df, $x, $y, $next_1, $size_1, $occ) = unpack('CCCNnN', $entry);
#^^^ 00 00 0000 ^^^^^^^ ^^^^

die "Dictionary flag not valid" if $df != 123;

read(INV,$term,$size_1-13); chomp($term);
printf ("%-20s %6d\n", $term, $occ);
}

sub header_rest {
my($full,$postings,$size_2);

read(INV,$entry,9);
($full,$postings,$size_2,) = unpack('aNL', $entry);
#^^^^^ ^^^^^^^ 0000 ^^^^^^^
#print "$size_2)\n";
die "invalid full flag: $full" if $full ne 'E';
die if $x;
die if $y;
die if $next_1;
return($postings);
}

sub posting {
my($ints) = @_;
my($docid, $size_3, $weight, $p1, $p2, $p3);

read(INV,$entry,15);
($docid,$size_3,$weight, $p1,$p2,$p3) = unpack('NLfCCC', $entry);
printf ("\t\t(%6d, %7.5f)\n", $docid,$weight);
read(INV,$entry,$size_3-3);
}
== ここまで ===================================================================

--
ish...@isl.intec.co.jp

0 new messages