X-Git-Url: https://git.korewanetadesu.com/?p=python-collate.git;a=blobdiff_plain;f=collate%2F_abcollator.py;h=2e6ab9567338e48884c6e46778b112e914d229e5;hp=bc43dc384d75e926ba1636356f931a44f3b81096;hb=7c67e10286c784b572703666a980e85b39b858ee;hpb=53e1676b8d68cccd2b0692654d3871e44e0ba6b6 diff --git a/collate/_abcollator.py b/collate/_abcollator.py index bc43dc3..2e6ab95 100644 --- a/collate/_abcollator.py +++ b/collate/_abcollator.py @@ -13,12 +13,12 @@ class Collator(object): return string.split() def sortemes(self, string): - words = [] - for word in self.words(string): - words.extend(collate._strings.alnumsplit(word)) - return filter(collate._strings.wordlike, words) + return collate._strings.alnumsplit(string) - def sortemekey(self, string): - words = map(collate._strings.numeric, self.sortemes(string)) - words = [(i, self.key(word)) for (i, word) in words] + def sortemekey(self, string, invalid=float('inf')): + words = [] + for sorteme in self.sortemes(string): + num, alpha = collate._strings.numeric(sorteme, invalid) + alpha = self.key(collate._strings.strip_punc(alpha)) + words.append((num, alpha)) return words