#!/usr/local/bin/perl

$kp="";

dbmopen(%INVERT, "invertdatabase", 0644);
open(QUIET, "> quiet");
open(NOISE, "noise");
$i=1;

while(<NOISE>){
	chop;
	/\s+(.*)/;
	$a = $1;
	($mcount, $chapter, $page, $line, $dnoise[$i]) = split(/\ +/, $a);
	$i++;
}

close(NOISE);

$dummy=join(' ', @dnoise);

$lastkeywd =  "ZZZ";
$keywd = "PPP";


while(<>){

	chop;
	($chapter, $page, $line, $keywd) = split(/:/);

	if ($dummy =~ /\s$keywd\s/){
	}
	else{

		if ($lastkeywd eq $keywd) {
			print "$chapter:$page:$line\n";
		}else{
				print "%K $keywd\n";
				print "$chapter:$page:$line\n";
		}

		$lastkeywd = $keywd;
	}


}

close (QUIET);
dbmclose(%INVERT);
