What have the names and whether they are necessary I did not understand. PHP I know at the level
<?php echo "Hello world" ?>
But I know bash quite well. And I would do it:
for FILE in *txt ; do
comm -12 <(cat $FILE | sed 's/[!?., ]/\n/g'|sort -u) <(sort FILE_WITH_NAME_LIST)
Times requested algorithm, then it does the following: turns the file into a sequence of strings, where each string is one word. Also assumes that the file names is also the same sequence, and then the comm is still overkill for matches.
To compare this method with php nor proizvoditelnosti nor the complexity, alas, can not.