from re import finditer
from collections import Counter
from sys import argv

#data = open(argv[1], 'rt', encoding='cp1251')
data = ['abcd, def -ref +\n', 'abcd+(ref)\n', 'abcd\n']

wordcount = Counter()
for line in data:
    for word in finditer('[^-+().,:\s;><"\'?!]+', line):
        w = word.group()
        #print(w)
        wordcount[w] += 1
for count, word in sorted(((c, w) for w, c in wordcount.items()), reverse=True):
    print(word, count)
