#!/usr/local/bin/perl -w use strict; use CGI; my $query = new CGI; my $dbroot = "/var/www/html/lextypedb/db"; my $cssdir = "/lextypedb"; my $cgidir = "/cgi-bin/lextypedb_tools"; my $charset = "utf-8"; my $version = "???"; if(-e "params"){ open(PARAM, "params"); while(){ chomp; (my $para, my $val) = split /=/;#/ if($para eq "dbroot"){ $dbroot = $val; }elsif($para eq "charset"){ $charset = $val; }elsif($para eq "cssdir"){ $cssdir = $val; }elsif($para eq "cgidir"){ $cgidir = $val; }elsif($para eq "version"){ $version = $val; } } close(PARAM); } #Receive the confusing param. my $confusing = $query->param("confusing"); #Retrieve all lexical types that contain the confusing word as an instance. use DBI; my @lextypes; my $lexicon_table = "lex_and_freq_tbl"; my $dbname = $dbroot."/"."lt.db"; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "", {AutoCommit => 0}); my $sth = $dbh->prepare( "select lextype from $lexicon_table where orth=?" ); $sth->execute($confusing); while(my @row = $sth->fetchrow_array){ push(@lextypes, $row[0]); } my $list_table = "list_tbl"; $sth = $dbh->prepare( "select * from $list_table where lextype=?" ); my $total=0; my $out = ""; #$out .= ""; $out .= ""; foreach my $lt (@lextypes){ $sth->execute($lt); while(my @row = $sth->fetchrow_array){ my @word_and_id_tmp = split /@/, $row[2]; my @examples_a = (); foreach (@word_and_id_tmp){ my @word_and_id = split /:/, $_;#/ push(@examples_a, $word_and_id[1]); } my $examples = join(",  ", @examples_a); $out .= ""; $out .= ""; $out .= ""; $out .= ""; $out .= ""; $total++; } } $out .= "
Lexical TypeExample (Lexicon, Corpus)
Lexical TypeLinguistic NameExample (Lexicon, Corpus)
".$row[0]."".$row[1]."".$examples."  (".$row[3].", ".$row[4].")"."
"; $dbh->commit; # Message ------------------------------------- print $query->header(-type => 'text/html;charset='.$charset), $query->start_html(-title=>'Confusing Types: "'.$confusing.'"', -style=>{'src' => $cssdir.'/lextypedb.css'}); print <<"HTML_VIEW";
Word Search: 

Lexical Types for "$confusing" ($version)

$total Lexical Types are found.
$out

HTML_VIEW print $query->end_html; exit; # Error report ----------------------------------- sub error { my ($mes) = @_; print $query->header(-type => 'text/html;charset='.$charset), $query->start_html(-title=>'Creation Error', -style=>{'src' => $cssdir.'/lextypedb.css'}); print <<"HTML_VIEW";

Lexical Type Database: ERROR

$mes


HTML_VIEW print $query->end_html; exit; } __END__