natural language – Finding position of specific substring within string


Is there a simple way of finding the position of a specific instance of a substring within a string? For instance, in the sentence “Bob bought his car at the car dealership”. Something like StringPosition would give me the position of both instances of car, namely {{16, 18}, {27, 29}}, but what if I only wanted the first or the second instance of the word?

If I do a StringPosition on every word of the sentece, both instances of the word “car” would yield {{16, 18}, {27, 29}}, as opposed to {16, 18} for the first instance and {27, 29} for the second instance, which is not very useful.

This seems to be a recurrent theme for a lot of Mathematica’s NLP functions when they are applied to text: The functions act on each word, without considering the context of the word within the text. Mathematica just gives you all possible answers for each word.