Finding and counting the frequency of known pairs of words in multiple files [closed]

When using combinations() you are getting all pairs, even the non-adjacent ones. You can create a function that will return the adjacent pairs. I’ve tried the following code and it worked, maybe it can give you some insight: import os import re from collections import Counter def pairs(text): ans = re.findall(r'[A-Za-z]+’, text) return (tuple(ans[i:i+2]) for … Read more