#!/usr/bin/perl -T # (1) get wprel.cgi(this) and wp-rel.txt # (2) install SUFARY and SUFARY.pm (in SUFARY package) # (3) exec "mkary -l wp-rel.txt" # (4) copy wprel.cgi and wp-rel.txt* to the same directory use strict; use warnings; use CGI; use SUFARY; use utf8; use URI::Escape; my $fn = "wp-rel.txt"; my $suf = SUFARY->new($fn); my $q = new CGI; my $key = $q->param('key') || ""; print $q->header(-charset => 'UTF-8'); print << "FORM" Wikipedia: Related Word @{[($key !~ /^\s*$/) ? qq() : ""]}
FORM ; if ($key !~ /^\s*$/) { my @res = $suf->search($key."\t"); if (@res == 1) { my $str = $suf->get_line($res[0]); my @c = split("\t", $str); shift @c; print join(", ", map { my ($k, $s) = /^(.+):(\d+)$/; qq($k ($s))} @c); } my $ek = uri_escape($key); print qq(

Wikipedia: $key

); } print qq(\n);