How to get the number of matched term to a doc in script score

how to get the number of matched term to a doc in script score,
if there is not any way, may i do this by implementing any plugin my self?