X-Git-Url: https://git.korewanetadesu.com/?p=python-collate.git;a=blobdiff_plain;f=collate%2F_abcollator.py;h=bc43dc384d75e926ba1636356f931a44f3b81096;hp=a6ec268d9bb6512bffd6b1d752088798fde6ea09;hb=53e1676b8d68cccd2b0692654d3871e44e0ba6b6;hpb=96cd5d3ad9dd1390c7739a6c3b9fa03ac3a2b4ff diff --git a/collate/_abcollator.py b/collate/_abcollator.py index a6ec268..bc43dc3 100644 --- a/collate/_abcollator.py +++ b/collate/_abcollator.py @@ -1,3 +1,5 @@ +import collate._strings + class Collator(object): def cmp(self, string1, string2): """Return negative if a < b, zero if a == b, positive if a > b.""" @@ -10,5 +12,13 @@ class Collator(object): """ return string.split() - def wordkeys(self, string): - return map(self.key, self.words) + def sortemes(self, string): + words = [] + for word in self.words(string): + words.extend(collate._strings.alnumsplit(word)) + return filter(collate._strings.wordlike, words) + + def sortemekey(self, string): + words = map(collate._strings.numeric, self.sortemes(string)) + words = [(i, self.key(word)) for (i, word) in words] + return words