--- trunk/t/10homer.pl 2004/10/06 15:33:33 21 +++ trunk/t/10homer.t 2004/10/07 16:21:54 23 @@ -17,24 +17,33 @@ my $p = 0; my $text = ''; my %words; -my $max = 2; +my $word_count = 0; +my $max_words = 100; my $res; +my $full_text; + ok(open(U, "t/homer.txt"), "open homer.txt"); while() { chomp; if (/^\s*$/) { $p++; + $full_text .= "\n" if ($full_text); + $full_text = "paragraph $p\n\n"; + diag "paragraph $p"; my %usage; - foreach (split(/\s+/,lc($text))) { + + my @words = split(/\s+/,lc($text)); + + foreach (@words) { $usage{$_}++; } - foreach my $word (keys %usage) { + foreach my $word (@words) { $words{$word} += $usage{$word}; @@ -50,11 +59,17 @@ Insert => 1, Append => 1, ); + + $word_count++; + + $full_text .= "$word "; + + last if ($max_words && $word_count >= $max_words); } $text = ''; - last if ($max && $max == $p); + last if ($max_words && $word_count >= $max_words); } else { $text .= $_; } @@ -76,6 +91,18 @@ # $sum += $words{$w}; #} +if (open(T,"> homer_text.txt")) { + print T $full_text; + close(T); +} +diag "homer_text.txt created"; + +if (open(T,"> homer_words.txt")) { + print T $t->to_string; + close(T); +} +diag "homer_words.txt created"; + my $total_words = scalar keys %words; cmp_ok($t->to_jsfind("./html/homer"), '==', $total_words, " jsfind index with $total_words words");