/[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 79 - (show annotations)
Sat Jul 6 13:13:27 2002 UTC (21 years, 9 months ago) by dpavlin
File MIME type: application/octet-stream
File size: 2474 byte(s)
Unable to calculate annotation data on binary file contents.
URL na novi dio �lanka

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 use Unicode::String qw(utf8 utf16);
9 require Unicode::Map8;
10
11 my $dir='/home/dpavlin/nn/swish';
12
13 my $hits=0;
14 my $max_hits=100;
15
16 my %labels = (100=>' 100', 200=>' 200', 500=>' 500', 0=>'neograničeno');
17
18 print header(-charset=>'iso-8859-2'),start_html(-title=>'NN pretrazivanje',-lang=>'hr'),start_form;
19 print "Potraži ",popup_menu(-name=>'max_hits',-values=>[ sort keys %labels ],-labels=>\%labels,-default=>$max_hits)," zakona sa riječima: ",textfield('search');
20 print submit(-value=>'prikaži');
21 print end_form,hr;
22
23 if (param('search')) {
24
25 my $s;
26 # re-write query from +/- to and/and not
27 foreach (split(/\s+/,param('search'))) {
28 if (m/^([+-])(\S+)/) {
29 $s.= ($s) ? "and " : "";
30 $s.="not " if ($1 eq "-");
31 $s.="$2 ";
32 } else {
33 $s .= "$_ ";
34 }
35 }
36 $s=~tr/šđžčćŠĐŽČĆ/šđžčćŠĐŽČĆ/; # 1250 -> iso8859-2
37 $s=~tr/šŠđĐčČćĆžŽ/sSdDcCcCzZ/;
38
39 my $l2_map = Unicode::Map8->new("ISO-8859-2") || die;
40 my $us = Unicode::String->new();
41
42 my $sh = SWISH->connect('Fork',
43 prog => "$dir/swish-e",
44 indexes => "$dir/nn.index",
45 properties => [qw/god br nr/],
46 results => sub {
47 my ($sh,$hit) = @_;
48
49 $us->utf8($hit->swishtitle);
50
51 print "<a href=\"",$hit->swishdocpath,"\"><tt>NN",$hit->god,"/",$hit->br,"</a> ",$hit->nr," </tt>",$l2_map->to8($us->utf16),"</a> [",$hit->swishrank,"]<br>\n";
52
53 # print $_[1]->as_string,"<br>\n";
54 # my @fields = $hit->field_names;
55 # print "Field '$_' = '", $hit->$_, "'<br>\n" for sort @fields;
56 },
57 maxhits => param('max_hits') || $max_hits,
58 );
59
60 die $SWISH::errstr unless $sh;
61
62 $hits = $sh->query("naslov_czs=($s)");
63
64 if ($hits > 0) {
65 print p,hr,"Prikazujem $hits zakona (maks. ",param('max_hits') || $max_hits,")... <small>($s)</small>";
66 } else {
67 print p,"Nije nađen niti jedan zakon... <small>($s, ",$sh->errstr,")</small>";
68 }
69 } else {
70 print p('Kod pretraživanja pretraživač pronalazi sve zakone u kojima se pojavljuju <b>sve upisanje riječi</b>.',br,'Ako ispred riječi upišete minus (-) neće se prikazivati zakoni koji imaju takvu riječ. Npr. <tt>+kava +zakon -dopunama</tt>');
71 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."),p("Ovo je <i>nova i brža verzija pretraživača</i> o kojoj <a href=\"http://www.rot13.org/~dpavlin/nn.html#buducnost\">više možete saznati</a> iz članka.");
72 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26