Text this: Learning algorithm for the recursive pattern recognition model