# -*- coding: utf-8 -*- import re def splitWords(str): str = str.decode("utf-8") p = re.compile(u'[^a-zа-я\-]+', re.IGNORECASE | re.UNICODE) m = p.split(str) return m def countWords(list): count = {} for word in list: try: count[word] += 1 except KeyError: count[word] = 1 return count # пример str = "мама мыла раму мама" m = countWords(splitWords(str)) for word in m: print word, m[word]