match sentence and word adn fetch similar words in alist

Hi all,

I have ot match sentence list and word list anf fetch similar words in a separate file

second file with 2 columns

So I want the output shuld be 2 columns like this

How about this:

awk '
    NR==FNR{a[$2]=$1;next}
    $1 in a{$1=a[$1]" "$1;print;next}
    $1" "$2 in a{$2=$1" "$2;$1=a[$2];print}' FS=" it is used in " file1 FS=" " file2

Hi

It's checking the whole sentenece
and printing

which is very different form what I want

as I want

e

Sorry typo try:

awk '     
   NR==FNR{a[$2]=$1;next}     
   $1 in a{$1=a[$1]" "$1;print;next}     
   $1" "$2 in a{$2=$1" "$2;$1=a[$2];print}' FS=" it is used in " file1 OFS=" " file2