The set/number of matching patterns in a document for a query?

Is there any way to get the set/number of the matching patterns for some query in a document?

For example:
If we have the text "red people, white people, yellow people", and the query 'people NOT "yellow people"' (matching the word people but not the phrase "yellow people").

The result I expect is a matching pattern count of 2

Thank you.