! Copyright (C) 2008 Daniel Ehrenberg.\r
! See http://factorcode.org/license.txt for BSD license.\r
-USING: sequences io.files io.encodings.ascii kernel values splitting\r
+USING: sequences io.files io.encodings.ascii kernel splitting\r
accessors math.parser ascii io assocs strings math namespaces make\r
sorting combinators math.order arrays unicode.normalize unicode.data\r
locals macros sequences.deep words unicode.breaks quotations\r
IN: unicode.collation\r
\r
<PRIVATE\r
-VALUE: ducet\r
+SYMBOL: ducet\r
\r
TUPLE: weight primary secondary tertiary ignorable? ;\r
\r
: parse-ducet ( file -- ducet )\r
data [ [ parse-keys ] [ parse-weight ] bi* ] H{ } assoc-map-as ;\r
\r
-"vocab:unicode/collation/allkeys.txt" parse-ducet \ ducet set-value\r
+"vocab:unicode/collation/allkeys.txt" parse-ducet ducet set-global\r
\r
! Fix up table for long contractions\r
: help-one ( assoc key -- )\r
! Need to be more general? Not for DUCET, apparently\r
2 head 2dup swap key? [ 2drop ] [\r
- [ [ 1string swap at ] with { } map-as concat ]\r
+ [ [ 1string of ] with { } map-as concat ]\r
[ swap set-at ] 2bi\r
] if ;\r
\r
dup keys [ length 3 >= ] filter\r
[ help-one ] with each ;\r
\r
-ducet insert-helpers\r
+ducet get-global insert-helpers\r
\r
: base ( char -- base )\r
{\r
\r
:: ?combine ( char slice i -- ? )\r
i slice nth char suffix :> str\r
- str ducet key? dup\r
+ str ducet get-global key? dup\r
[ str i slice set-nth ] when ;\r
\r
: add ( char -- )\r
dup blocked? [ 1string , ] [\r
dup possible-bases dup length iota\r
- [ ?combine ] with with any?\r
+ [ ?combine ] 2with any?\r
[ drop ] [ 1string , ] if\r
] if ;\r
\r
: graphemes>weights ( graphemes -- weights )\r
[\r
dup weight? [ 1array ] ! From tailoring\r
- [ dup ducet at [ ] [ derive-weight ] ?if ] if\r
+ [ dup ducet get-global at [ ] [ derive-weight ] ?if ] if\r
] { } map-as concat ;\r
\r
: append-weights ( weights quot -- )\r
- [ [ ignorable?>> not ] filter ] dip\r
- map [ zero? not ] filter % 0 , ; inline\r
+ [ [ ignorable?>> ] reject ] dip\r
+ map [ zero? ] reject % 0 , ; inline\r
\r
: variable-weight ( weight -- )\r
dup ignorable?>> [ primary>> ] [ drop 0xFFFF ] if , ;\r
[\r
[ collation-key ] dip\r
[ [ 0 = not ] trim-tail but-last ] times\r
- ] curry bi@ = ;\r
+ ] curry same? ;\r
PRIVATE>\r
\r
: primary= ( str1 str2 -- ? )\r