string = 'abba com mother bill mother com abba dog abba mother com'
words = string.split()
res = {}
for n in range(len(words)-2):
    comb = ' '.join(sorted(words[n:n+3]))
    res[comb] = res.get(comb, 0) + 1
print(res)