I wanted to find all sets of words that are repeated in a text. for example:
string21="we read all sort of books, we read sci-fi books, historical books, advanture books and etc."
Now regex should output these words: we,read,books
How can I get this result?
I tried using this:
pattern="\b(\w+)\s+\1\b"
match=re.findall(pattern,string)
But it didn't work as I expected, and only showed 2 duplicate words exactly next to each other and doesn't search the whole text.