... --> []|[_],... .
file_contains(File, Pattern) :-
phrase_from_file((..., Pattern, ...), File).
match_count(File, Pattern, Count) :-
findall(x, file_contains(File, Pattern), Xs),
length(Xs, Count).
This can be called as (note that the pattern must be a string (code list)):
?- match_count('pure_input.pl', "file", Count).