yes i finally did it. it consumed a bit long time but felt good that i did it using perl. seems a portent.
its PERL program for concordance
what is concordance can be found on http://www.concordancesoftware.co.uk/
thought the disadvantage of the program is, the output is slightly distorted (i.e the word doesnt come in the middle) if the input word lies in less than half of the sentence with prescribed lenth. if length given is 12 then the word doesnt come in the middle if the word is within the first few words.
but it may be avoided as other words will be in different places
#################(c) PUNJ ###########
#! /usr/bin/perl
open (file, "source.txt");
$string = $ARGV[0];
print "Enter the no. of characters to be printed\n";
$noLines =
while ($lines =
chomp $lines;
@array = split (/$string/,$lines);
$test = ($lines =~ s/($string)/\1/g);
if ($test ge 1) {
$countFirst = ($array[0] =~ s/(.)/\1/g);
$countSecond = ($array[1] =~ s/(.)/\1/g);
$countThird = ($string =~ s/(.)/\1/g);
$total = $noLines - $countThird;
$each = int($total / 2);
$third = substr($array[1], 0, $each);
$first = substr($array[0], -$each);
print "\n**\n$first $string $third\n**\n";
}
}
close(file);
###########################
Sunday, July 26, 2009
concordance using perl
Posted by Punj Pokharel at 10:02 PM 0 comments
Labels: concordance, perl, programming, technical
Subscribe to:
Posts (Atom)