#!/usr/bin/perl -w # NATools - Package with parallel corpora tools # Copyright (C) 2002-2012 Alberto Simões # # This package is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. use POSIX qw(locale_h); setlocale(LC_CTYPE, "pt_PT.UTF-8"); use locale; use URI::Escape; use Lingua::NATools::Client; use Lingua::NATools::CGI; use CGI qw/:standard/; # Create a new client my $server = Lingua::NATools::Client->new(); # Get the list of available corpora my $corpora = $server->list(); # Current corpus if undefined, without a name my $crp = undef; my $name; # Check if we got a corpus identifier if (param("crp")) { $crp = $corpora->{param("crp")}{id} || undef; $name = param("crp"); } # Ok, we didn't get a corpus identifier, just a corpus name if (param("corpus") && !param("crp")) { $crp = param("corpus"); for (keys %$corpora) { $name = $_ if $corpora->{$_}{id} == $crp; } } # We didn't get a corpus identifier nor a corpus name, so get randomly one. ($name) = keys %$corpora unless $name; # Create JavaScript combo-box to change corpus being queried my $s = join("\n", join("\n", map { "source[\"$_\"]=\"$corpora->{$_}{source}\";"} keys %$corpora), join("\n", map { "target[\"$_\"]=\"$corpora->{$_}{target}\";"} keys %$corpora)); my $JSCRIPT = <<"EOS"; var source = new Array(); var target = new Array(); $s function changeLanguages() { var corpus = document.getElementById('crp').value; document.getElementById('source').innerHTML = source[corpus]; document.getElementById('target').innerHTML = target[corpus]; } function go(l,c) { if (parseInt(navigator.appVersion)>=4) if (navigator.userAgent.indexOf("MSIE")>0) { //IE 4+ var sel=document.selection.createRange(); sel.expand("word"); window.location="nat-dict.cgi?corpus=" + c + "&" + l + "=" + escape(sel.text) } else // NS4+ window.location="nat-dict.cgi?corpus=" + c + "&" + l + "=" + escape(document.getSelection()) } function help() { window.open('nat-search.cgi?HELP=1','NAT-QI Quick Help', 'menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); } EOS print Lingua::NATools::CGI::my_header(jscript => $JSCRIPT); # Check if we were asked for help if (param("HELP")) { print Lingua::NATools::CGI::close_window(); print_help(); print Lingua::NATools::CGI::my_footer(); exit; } # Print form HTML print div({-class=>"hlpbt", -onclick=>"help()"}, "Help "); print h1("NAT-QI: NATools Corpora Query Interface"); print start_form({-class=>"main"}); print "
NAT-QI (NATools Query Interface) is a web frontend to query and browse Parallel Corpora. For details about its architecture and associated tools see this page.
This interface is querying a server (NATServer) with a specific parallel corpora, and a specific pair of languages.
Toolbar Usage:
Related Tools Integration: