So I have some medium-length string - somewhere between a few words and a few sentences. Sometimes, a substring in the text is repeated twice in a row. I need to write automatic code to identify the repeated part. Or at least flag it with a high probability.
What I know:
- The repeated substring is a series of a few whole words (and punctuation marks). A repeat will not happen in the middle of a word.
- The repeat is of a variable length. It can be a few words to a few sentences itself. But it's always at least a few words long. I would like to avoid flagging single word repetitions if possible.
- When a repeat happens, it's always repeated exactly once, and right after the previous appearence. right after the previous appearence. (<- example)
- I need to run this check on about a million different strings, so the code has to be somewhat efficient at least (not the brute force check-every-option approach).
I've been struggling with this for a while now. Would really appreciate your help.