From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: ntg-context@ntg.nl
Cc: Hans Hagen <j.hagen@freedom.nl>
Subject: [NTG-context] Re: Quickly invoke a self-defined index sorting file?
Date: Sun, 12 Jan 2025 16:59:22 +0100 [thread overview]
Message-ID: <907c05e0-2b20-4ee7-9326-a86ea8bfd399@freedom.nl> (raw)
In-Reply-To: <173669007779.1763.15669299589208533051@cgl.ntg.nl>
[-- Attachment #1: Type: text/plain, Size: 719 bytes --]
On 1/12/2025 2:54 PM, autumnus wrote:
> Chinese Hanzi PinYin : https://github.com/mozillazg/pinyin-data/tree/master
> Chinese Hanzi Stroke : https://github.com/leo-liu/zhmakeindex/blob/master/CJK/strokes.go
assuming that you donwloaded kHanyuPinlu.txt you can run the attached
test file You might want to set up an order / entries for the latin variant
just prototyping here
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
[-- Attachment #2: lang-imp-cn.lua --]
[-- Type: text/plain, Size: 441 bytes --]
local function whatever(name)
local data = io.loaddata(name)
if data then
local mapping = { }
for a, b in string.gmatch(data,".-: ([^, ]+).-# (%S+)") do -- U+4E00: yī # 一
mapping[b] = a
end
return mapping
end
end
return {
name = "cn transliterations",
transliterations = {
["hanyu to pinlu"] = {
mapping = whatever("kHanyuPinlu.txt")
}
}
}
[-- Attachment #3: sort-imp-cn.lua --]
[-- Type: text/plain, Size: 666 bytes --]
local utfchar, utfbyte = utf.char, utf.byte
local sorters = sorters or { }
local definitions = sorters.definitions or { }
local replacementoffset = sorters.constants.replacementoffset
local variables = interfaces.variables or { }
local function whatever(name)
local data = io.loaddata(name)
if data then
local replacements = { }
for a, b in string.gmatch(data,".-: ([^, ]+).-# (%S+)") do -- U+4E00: yī # 一
replacements[#replacements+1] = { b, a }
end
return replacements
end
end
definitions["cn-hanzi"] = {
-- orders = {
-- }
replacements = whatever("kHanyuPinlu.txt"),
}
[-- Attachment #4: test.tex --]
[-- Type: text/plain, Size: 907 bytes --]
\mainlanguage[cn]
\registerctxluafile{sort-imp-cn}{}
\usetransliteration[cn]
\definetransliteration
[MyChinese]
[color=blue,
vector={hanyu to pinlu}]
\starttext
\definedfont[name:adobesongstdlight]
test 词语拼音数据 \index{词语拼音数据}\par
test 据词语拼音数 \index{据词语拼音数}\par
test 数据词语拼音 \index{数据词语拼音}\par
\blank
\starttransliteration[MyChinese]
\tf
词语拼音数据
据词语拼音数
数据词语拼音
\stoptransliteration
\placeregister
[index]
[n=1,indicator=no]
\placeregister
[index]
[language=cn-hanzi,n=1]
\starttransliteration[MyChinese]
\tf
\placeregister
[index]
[language=cn-hanzi,n=1,inbetween=]
\stoptransliteration
\stoptext
[-- Attachment #5: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2025-01-12 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 8:58 [NTG-context] " autumnus
2025-01-12 11:01 ` [NTG-context] " Hans Hagen
2025-01-12 11:53 ` autumnus
2025-01-12 12:18 ` Hans Hagen
2025-01-12 13:54 ` autumnus
2025-01-12 15:59 ` Hans Hagen via ntg-context [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=907c05e0-2b20-4ee7-9326-a86ea8bfd399@freedom.nl \
--to=ntg-context@ntg.nl \
--cc=j.hagen@freedom.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).