#!/usr/bin/perl

use strict;
use warnings;

# binmode(STDOUT, "utf8");

my $lemma = $ARGV[0];
my $dbclass = $ARGV[1];

open(LEMMA,"$lemma") or die;
open(DB,"$dbclass") or die;

my $db;

while(<LEMMA>){
    chomp;

    s/\s+$//;
    s/^\s+//;

    next if /^\W+$/;

    $db->{$_} = 1;
}

while(<DB>){
    chomp;

    s/\s+$//;
    s/^\s+//;

    next if /^\W+$/;

    my($lemma, $class) = split /\t+/, $_;
   # print $lemma, "###",$class,"\n";
    if(defined $db->{$lemma}){
	print $lemma,"\t",$class,"\n";
    }
}
