I would guess it is something like
var Pages = Application(“Pages”);
pagesdoc = Pages.open(Path(‘path to document’));
var text = pagesdoc.body
var count = (text.match(/certain word/g) || ).length;
Would be really great if you could help!