X-Git-Url: https://git.korewanetadesu.com/?p=python-collate.git;a=blobdiff_plain;f=collate%2Ficu%2F__init__.py;h=5f3ec05f98f19d051c4c8a6beda8b14fc0968081;hp=892b8a1c80acb807a976077ae64f6bcd95c03025;hb=9a7cf6459c40d53b58634f2df56386bf52c12f7c;hpb=c2e6d9413b5780bf96302569cf641f09de90f9fa diff --git a/collate/icu/__init__.py b/collate/icu/__init__.py index 892b8a1..5f3ec05 100644 --- a/collate/icu/__init__.py +++ b/collate/icu/__init__.py @@ -36,6 +36,13 @@ class Collator(collate._abcollator.Collator): # so this is a harmless error. self._breaker = _icu.WordBreaker("root") + def words(self, string): + """Split the string along word boundries.""" + if isinstance(string, str): + 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.