What does the substr exctract? Depending on that it could be moved to getEntititesForPage?

The processed entities could also be stored in Memcache and purged when the NLP script ingests new values for the WF variable as this would happen on every non-cached Pageview.