Created
March 10, 2019 23:11
-
-
Save krmgns/3077e615ce02f2bf9bfe9aa5694866cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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