open CF, 'd.txt' or die $!;
my %tagdict;
while (<CF>) {
chomp;
my ($word, $cat) = split;
$tagdict{$word} = $cat;
}
while ( ($k,$v) = each %tagdict ) {
#print "$k => $v\n";
}
open CP, 'c.txt' or die $!;
my %tagcorpus;
while (<CP>) {
chomp;
my @cwords =split;
#$lcwords=@cwords;
#for($i=0;$i<$lcwords;$i++){
#$cwords[$i]=~ s/,/ /d;
#$cwords[$i]=~ s/'/ /d;
#$cwords[$i]=~ s/./ /d;
#}
@tagcorpus{@cwords} = (1) x @cwords;
}
while ( ($k,$v) = each %tagcorpus ) {
#print "$k => $v\n";
}
my @common=();
foreach (keys %tagdict){
push(@common,$_) if exists $tagcorpus{$_};
}
#print "\n@common";
foreach $citem(@common){
#print "\n$tagdict{$citem}";
}
close CP;
The st.
print "\n$tagdict{$citem}";
gives this
advb
noun
verb
which reminds me that I don't have the categories of
the words in the order they were inserted into the hash.
I guess that can be taken care of.
I've also removed commas, periods, quotes in c.txt for
the time being.But I need to do away with them within the
script. Tried some s// stmts which didn't work.
But the trickiest part of all is

writing the category
against the appropriate word in c.txt.
c.txt needs to look like this:
Here<noun> I am<verb> this is me Theres<adverb> nowhere else on earth Id rather be