/[nn.old]/trunk/search/nn-swish.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/search/nn-swish.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations)
Wed Jun 19 19:54:43 2002 UTC (21 years, 10 months ago) by dpavlin
File MIME type: application/octet-stream
File size: 1924 byte(s)
Unable to calculate annotation data on binary file contents.
output same as before (other than rank at the end and utf8 in titles which
isn't yet converted to iso-8859-2)

1 #!/usr/bin/perl -w
2
3 use strict;
4 use CGI qw/:standard -no_xhtml/;
5 use Text::Query;
6 use CGI::Carp qw(fatalsToBrowser);
7 use SWISH;
8 require Unicode::Map8;
9
10 my $dir='/home/dpavlin/nn/swish';
11
12 my $hits=0;
13
14 print header(-charset=>'iso-8859-2'),start_html(-title=>'NN pretrazivanje',-lang=>'hr'),start_form;
15 print "Potraži zakone sa riječima: ",textfield('search');
16 print submit(-value=>'prikaži');
17 print end_form,hr;
18
19 if (param('search')) {
20
21 my $s=param('search');
22 $s=~tr/šđžčćŠĐŽČĆ/šđžčćŠĐŽČĆ/; # 1250 -> iso8859-2
23 $s=~tr/šŠđĐčČćĆžŽ/sSdDcCcCzZ/;
24
25 my $l2_map = Unicode::Map8->new("ISO-8859-2") || die;
26 #my $utf8_map = Unicode::Map8->new("utf8") || die;
27
28 my $sh = SWISH->connect('Fork',
29 prog => "$dir/swish-e",
30 indexes => "$dir/nn.index",
31 properties => [qw/god br nr/],
32 results => sub {
33 my ($sh,$hit) = @_;
34
35 my $us=$hit->swishtitle;
36
37 print "<a href=\"",$hit->swishdocpath,"\"><tt>",$hit->god,"/",$hit->br,"</a> ",$hit->nr," </tt>",$hit->swishtitle,"x</a> [",$hit->swishrank,"]<br>\n";
38
39 # print $_[1]->as_string,"<br>\n";
40 # my @fields = $hit->field_names;
41 # print "Field '$_' = '", $hit->$_, "'<br>\n" for sort @fields;
42 },
43 );
44
45 die $SWISH::errstr unless $sh;
46
47 $hits = $sh->query("naslov_czs=($s)");
48
49 if ($hits > 0) {
50 print p,hr,"Nađeno je $hits zakona...";
51 } else {
52 print p,"Nije nađen niti jedan zakon... (",$sh->errstr,")";
53 }
54 } else {
55 print p('U jednostavnom pretraživanju pretraživač pronalazi sve zakone u kojima se pojavljuje <b>bilo koja</b> od tih riječi. Da bi našli sve zakone u kojima se pojavljuju <b>sve upisane riječi</b>, upišite ispred svake riječi znak plus (+). Npr: <tt>+zakon +kava</tt>',br,'Ako ispred riječi upišete minus (-) neće se prikazivati zakoni koji imaju takvu riječ. Npr. <tt>+kava +zakon -dopunama</tt>');
56 print p("Možete pročitati i <a href=\"http://www.rot13.org/~dpavlin/nn.html\">članak</a> o tome kako je ovaj pretraživač napravljen i zašto.");
57 }

Properties

Name Value
cvs2svn:cvs-rev 1.3
svn:executable *
svn:mime-type application/octet-stream

  ViewVC Help
Powered by ViewVC 1.1.26