Skip to content

Instantly share code, notes, and snippets.

@k-gun k-gun/fn_vector.py

Created Mar 10, 2019
Embed
What would you like to do?
def fn_vector(words):
import re, locale
#global words
def slug(words):
return fn_slug(words)
i = 0
dic = {}
words = slug(words)
for word in re.split('\s+', words):
i = i + 1; # position
c = [i];
if (word in dic):
c = dic[word]
c.append(i)
dic[word] = c
arr = []
for word, c in dic.items():
c = ','.join(map(str, c))
arr.append('%s:%s' % (word, c))
locale.setlocale(locale.LC_COLLATE, 'tr_TR.UTF-8')
arr.sort(key=locale.strxfrm)
return ' '.join(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.