Posted by: akawi April 24, 2009
kantipur maithili
Login in to Rate this Post:     0       ?        
machine translation done using following perl code
#-------------------------------
#!/usr/bin/perl


#

use strict;

use warnings;

use IO::File;

use Encode::Guess ();

use Encode ();

use Cwd;

use WWW::Mechanize;

    # -----------------------------------------------

    # user information for proxy user-id and password

    # -----------------------------------------------

   my  $dir =getcwd();

    #------------------------

    #Open url:

    #------------------------

    $agent->agent_alias( 'Windows Mozilla' ); # Mozilla =user agent

    my $url="http://www.kantipuronline.com/kolnepalinews.php?&nid=190777";

    eval {$agent->get($url);};

    if($@){

        print $@;

        exit;

    }

    my$contents=$agent->content();

my $filename= shift @ARGV;

my $dict = "dict.txt" ;

my $fh = IO::File->new($dict, "<:raw");



my @words = <$fh>;

my %replacements;

foreach my$w (@words){

    chomp($w);

    my@pair = split(/,/,$w);

    $pair[0] =$encoding->decode($pair[0]);

    $pair[1] =$encoding->decode($pair[1]);

    $replacements {$pair[0]} = $pair[1];

}

while ((my $key, my $val) = each(%replacements))

{

    $data =~ s/\b$key\b/$val/g;

}

my $data_out = Encode::encode_utf8($data);

print $filename;

IO::File->new($filename, ">:raw")->print($data_out);

  
<br>
Read Full Discussion Thread for this article