Using any POSIX awk in any shell on every Unix box:
$ cat tst.awk
BEGIN { OFS="\t" }
NR==FNR {
words[NR] = $1
next
}
{
$0 = " " $0 " "
gsub(/[^[:alpha:]]+/," ")
for ( i in words ) {
word = words[i]
cnts[word] += gsub(" "word" ","&")
}
}
END {
for ( i=1; i in words; i++ ) {
word = words[i]
print word, cnts[word]+0
}
}
$ awk -f tst.awk file1 file2
dog 1
apple 1
cat 2
The above assumes that "word"s are all alphabetic characters and that you want the matches to be case-sensitive or the input is all lower case as in your example and that the words in file1 are unique as in your example.