I’m thinking that the standard library’s sort would do the job. You would need
to supply 3 functions for your data: Len, Swap, and Less. You could implement
Less to incorporate your collation scheme.
One other idea: Using an array to define the collating order sounds good, but
it would require a binary search for each lookup. After building the array,
how about using it to build a map which would connect each of the entries to
its order number – a “reversed” array, so to speak. This would reduce the
lookup time from O(log n) to O(1).
John
John Souvestre - New Orleans LA
From: [email protected] [mailto:[email protected]] On
Behalf Of Jonathan Hall
Sent: 2016 October 31, Mon 17:36
To: golang-nuts
Subject: [go-nuts] Custom collation
I need to collate some IPA transcriptions, which means that following the
standard collation rules for a given language doesn't really make sense. As
such, I wish to define my own collation order. Is there any documentation,
howto, or other easier-to-digest documentation on this than what can be found
in the colltab godoc (https://godoc.org/golang.org/x/text/internal/colltab) ?
Or is there a better way to accomplish my goal?
For those interested, in the details:
I wish to order by mouth position, so collation order would be something like:
pbtdʈɖcɟ... iyɨʉ...
So right off the bat, the ordering is pretty close to random, with respect to
normal alphabetization.
My initial implementation simply defines the order of the expected phonemes in
a sorted array, and sorts on this position. But this is very limited, doesn't
scale, and doesn't account for unanticipated phoneme modifiers or diphthongs.
So the collate package & friends seem like the natural tools for this job. Am
I on the right track here?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.