summaryrefslogtreecommitdiffstats
path: root/blog/blog.pl
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-25 16:00:32 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-25 16:00:32 +0800
commitd5c1e17d4914c8409a7a741570e94e0ade6ec017 (patch)
tree3c1b5d165e5321365cf9e14b874c2bd745ec7d9b /blog/blog.pl
parent8b95b780207789b0b5531429ee07027ab9ea85e2 (diff)
downloadpttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.gz
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.bz2
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.lz
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.xz
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.tar.zst
pttbbs-d5c1e17d4914c8409a7a741570e94e0ade6ec017.zip
FuzzyIndex
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@966 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'blog/blog.pl')
-rwxr-xr-xblog/blog.pl17
1 files changed, 14 insertions, 3 deletions
diff --git a/blog/blog.pl b/blog/blog.pl
index 96c929af..515c1e65 100755
--- a/blog/blog.pl
+++ b/blog/blog.pl
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $Id: blog.pl,v 1.23 2003/06/19 13:06:58 in2 Exp $
+# $Id: blog.pl,v 1.24 2003/06/25 08:00:32 in2 Exp $
use CGI qw/:standard/;
use lib qw/./;
use LocalVars;
@@ -9,6 +9,7 @@ use Data::Dumper;
use Date::Calc qw(:all);
use Template;
use HTML::Calendar::Simple;
+use OurNet::FuzzyIndex;
use vars qw/@emonth @cnumber %config %attr %article %th/;
@@ -69,6 +70,15 @@ sub main
$ptr);
}
}
+ elsif( $attr{"$fn.loadBlog"} =~ /FuzzySearch/i ){
+ my $idx = OurNet::FuzzyIndex->new("$BLOGDATA/$brdname.idx");
+ my %result = $idx->query($th{SearchKey} = param('SearchKey'),
+ MATCH_FUZZY);
+ foreach my $t (sort { $result{$b} <=> $result{$a} } keys(%result)) {
+ AddArticle('blog', $attr{"$fn.loadBlogFields"},
+ $idx->getkey($t), sprintf("%5.1f", $result{$t} / 10));
+ }
+ }
if( $attr{"$fn.loadBlogPrevNext"} ){
my $s = packdate($y, $m, $d);
@@ -225,9 +235,9 @@ sub main
print "<pre>template error: ". $tmpl->error();
}
-sub AddArticle($$$)
+sub AddArticle($$$;$)
{
- my($cl, $fields, $s) = @_;
+ my($cl, $fields, $s, $score) = @_;
my($content, $short) = ();
$content = applyfilter($article{"$s.content"}, $config{outputfilter})
if( $fields =~ /content/i );
@@ -248,6 +258,7 @@ sub AddArticle($$$)
author => (($fields !~ /author/i) ? '' :
$article{"$s.author"}),
short => $short,
+ score => $score,
}
if( $article{"$s.title"} );
}