Introduce some helper methods to make the PatternExtraction class more readable.