Hi Anjali,
you can try $system() system task with Linux command to get no of keywords in your file.
i.e to calculate num of word_spec ( string type ) in file_name you can use following :
$system($sformatf(“grep -r -o %0s %0s | wc -l | tee line_1”,word_spec,file_name));
this will store number of keyword in line_1 file. and you can read that file to get actual number of keyword…
Regards,
-Dhaval