A grammaticometric approach to modeling functional variation