self._breaker = _icu.WordBreaker("root")
def words(self, string):
+ """Split the string along word boundries."""
if isinstance(string, str):
- string = string.decode(self.encoding, 'replace')
- return filter(lambda u: not u.isspace(), self._breaker.words(string))
+ string = string.decode(self.encoding)
+ words = self._breaker.words(string)
+ return [w for w in words if not w.isspace()]
def key(self, string):
"""Sort key for a string.
if isinstance(a, str):
a = a.decode(self.encoding, 'replace')
if isinstance(b, str):
- b = a.decode(self.encoding, 'replace')
+ b = b.decode(self.encoding, 'replace')
return self._collator.cmp(a, b)