* pinyin in context @ 2009-03-11 4:44 Bill Long 2009-03-11 5:08 ` Yue Wang ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Bill Long @ 2009-03-11 4:44 UTC (permalink / raw) To: ntg-context I input pinyin above Chinese character in bellow way: ------------------------------------------- \documentclass{article} \usepackage[overlap, CJK]{ruby} \usepackage{pinyin} \usepackage{CJK} \begin{CJK*}{UTF8}{song} \begin{document} \renewcommand{\rubysep}{.3ex} \renewcommand{\rubysize}{.5} \ruby{静}{\jing4} \ruby{夜}{\ye4}\ruby{思}{\si1} \end{CJK*} \end{document} ------------------------------------------------ but it has poor line break, Does contex support pinyin ? and how to implement? Thanks. -- 卷829_3 【怀香炉峰道人】贯休 常思峰顶叟,石窟土为床。日日先见日,烟霞多异香。 冥心同槁木,扫雪带微阳。终必相寻去,斯人不可忘。 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-11 4:44 pinyin in context Bill Long @ 2009-03-11 5:08 ` Yue Wang 2009-03-12 4:48 ` Bill Long 2009-03-11 15:26 ` Arthur Reutenauer 2009-03-15 3:23 ` Bill Long 2 siblings, 1 reply; 14+ messages in thread From: Yue Wang @ 2009-03-11 5:08 UTC (permalink / raw) To: mailing list for ConTeXt users post the result you want to have here so context developers can help you. 2009/3/11 Bill Long <longweilai@sohu.com>: > I input pinyin above Chinese character in bellow way: > ------------------------------------------- > \documentclass{article} > \usepackage[overlap, CJK]{ruby} > \usepackage{pinyin} > \usepackage{CJK} > \begin{CJK*}{UTF8}{song} > \begin{document} > \renewcommand{\rubysep}{.3ex} > \renewcommand{\rubysize}{.5} > > \ruby{静}{\jing4} \ruby{夜}{\ye4}\ruby{思}{\si1} > > \end{CJK*} > \end{document} > ------------------------------------------------ > > but it has poor line break, > > Does contex support pinyin ? and how to implement? > > Thanks. > > -- > 卷829_3 【怀香炉峰道人】贯休 > > 常思峰顶叟,石窟土为床。日日先见日,烟霞多异香。 > 冥心同槁木,扫雪带微阳。终必相寻去,斯人不可忘。 > > > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ > ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-11 5:08 ` Yue Wang @ 2009-03-12 4:48 ` Bill Long 0 siblings, 0 replies; 14+ messages in thread From: Bill Long @ 2009-03-12 4:48 UTC (permalink / raw) To: ntg-context thanks. I upload the target I wanna got in http://rhce4u.googlepages.com/yourpage%27stitle. On Wed, Mar 11, 2009 at 01:08:05PM +0800, Yue Wang wrote: > post the result you want to have here so context developers can help you. > > 2009/3/11 Bill Long <longweilai@sohu.com>: > > I input pinyin above Chinese character in bellow way: > > ------------------------------------------- > > \documentclass{article} > > \usepackage[overlap, CJK]{ruby} > > \usepackage{pinyin} > > \usepackage{CJK} > > \begin{CJK*}{UTF8}{song} > > \begin{document} > > \renewcommand{\rubysep}{.3ex} > > \renewcommand{\rubysize}{.5} > > > > \ruby{静}{\jing4} \ruby{夜}{\ye4}\ruby{思}{\si1} > > > > \end{CJK*} > > \end{document} > > ------------------------------------------------ > > > > but it has poor line break, > > > > Does contex support pinyin ? and how to implement? > > > > Thanks. > > > > > > 常思峰顶叟,石窟土为床。日日先见日,烟霞多异香。 > > 冥心同槁木,扫雪带微阳。终必相寻去,斯人不可忘。 > > > > > > > > ___________________________________________________________________________________ > > If your question is of interest to others as well, please add an entry to the Wiki! > > > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > > archive : https://foundry.supelec.fr/projects/contextrev/ > > wiki : http://contextgarden.net > > ___________________________________________________________________________________ > > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ -- 卷146_2 【燕歌行】陶翰 请君留楚调,听我吟燕歌。家在辽水头,边风意气多。 出身为汉将,正值戎未和。雪中凌天山,冰上渡交河。 大小百馀战,封侯竟蹉跎。归来灞陵下,故旧无相过。 雄剑委尘匣,空门垂雀罗。玉簪还赵女,宝瑟付齐娥。 昔日不为乐,时哉今奈何。 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-11 4:44 pinyin in context Bill Long 2009-03-11 5:08 ` Yue Wang @ 2009-03-11 15:26 ` Arthur Reutenauer 2009-03-12 6:27 ` Bill Long 2009-03-15 3:23 ` Bill Long 2 siblings, 1 reply; 14+ messages in thread From: Arthur Reutenauer @ 2009-03-11 15:26 UTC (permalink / raw) To: ntg-context > \documentclass{article} You're not using ConTeXt at all. This is LaTeX code. Which is fine, but then this list is really not the place to ask your question :-) There are hyphenation patterns for pinyin that could be added to ConTeXt; it wouldn't be too much work, but you would need to specify how you would like ConTeXt to behave exactly. For that matter, the LaTeX syntax for pinyin (\ni2\hao3!) is not supported at the moment. Arthur ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-11 15:26 ` Arthur Reutenauer @ 2009-03-12 6:27 ` Bill Long 0 siblings, 0 replies; 14+ messages in thread From: Bill Long @ 2009-03-12 6:27 UTC (permalink / raw) To: ntg-context On Wed, Mar 11, 2009 at 04:26:21PM +0100, Arthur Reutenauer wrote: > > \documentclass{article} > > You're not using ConTeXt at all. This is LaTeX code. Which is fine, > but then this list is really not the place to ask your question :-) Yes, just as I say the latex+cjk behave poor on line break, so I ask if context can do it, and do it better. > > There are hyphenation patterns for pinyin that could be added to > ConTeXt; it wouldn't be too much work, but you would need to specify how > you would like ConTeXt to behave exactly. For that matter, the LaTeX > syntax for pinyin (\ni2\hao3!) is not supported at the moment. > > Arthur Got it, then now I should try to manually do line break with latex+cjk. Thanks > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ -- 卷676_55 【野步】郑谷 翠岚迎步兴何长,笑领渔翁入醉乡。 日暮渚田微雨后,鹭鹚闲暇稻花香。 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-11 4:44 pinyin in context Bill Long 2009-03-11 5:08 ` Yue Wang 2009-03-11 15:26 ` Arthur Reutenauer @ 2009-03-15 3:23 ` Bill Long 2009-03-15 16:17 ` Hans Hagen 2009-03-15 17:20 ` Wolfgang Schuster 2 siblings, 2 replies; 14+ messages in thread From: Bill Long @ 2009-03-15 3:23 UTC (permalink / raw) To: ntg-context Dear Hans, Can you help check if you can implement a new feature of "pinyin" input in context? I upload the effect I wanna get in bellow link ( what I provide last time seemed doesn't work), Please check. http://picasaweb.google.com/lh/sredir?uname=weilai.long&target=ALBUM&id=5313243080349643217&authkey=Gv1sRgCJLO9v__gOPr_gE&feat=email Thanks in advance. On Wed, Mar 11, 2009 at 12:44:49PM +0800, Bill Long wrote: > I input pinyin above Chinese character in bellow way: > ------------------------------------------- > \documentclass{article} > \usepackage[overlap, CJK]{ruby} > \usepackage{pinyin} > \usepackage{CJK} > \begin{CJK*}{UTF8}{song} > \begin{document} > \renewcommand{\rubysep}{.3ex} > \renewcommand{\rubysize}{.5} > > \ruby{静}{\jing4} \ruby{夜}{\ye4}\ruby{思}{\si1} > > \end{CJK*} > \end{document} > ------------------------------------------------ > > but it has poor line break, > > Does contex support pinyin ? and how to implement? > > Thanks. > -- 卷206_55 【送王牧往吉州谒王使君叔】李嘉祐 细草绿汀洲,王孙耐薄游。年华初冠带,文体旧弓裘。 野渡花争发,春塘水乱流。使君怜小阮,应念倚门愁。 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-15 3:23 ` Bill Long @ 2009-03-15 16:17 ` Hans Hagen 2009-03-15 17:20 ` Wolfgang Schuster 1 sibling, 0 replies; 14+ messages in thread From: Hans Hagen @ 2009-03-15 16:17 UTC (permalink / raw) To: ntg-context Bill Long wrote: so > http://picasaweb.google.com/lh/sredir?uname=weilai.long&target=ALBUM&id=5313243080349643217&authkey=Gv1sRgCJLO9v__gOPr_gE&feat=email is the result of >> \ruby{静}{\jing4} \ruby{夜}{\ye4}\ruby{思}{\si1} i.e. you want transliterations on top? is that \jing4 a convention or something specific for tex packages Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-15 3:23 ` Bill Long 2009-03-15 16:17 ` Hans Hagen @ 2009-03-15 17:20 ` Wolfgang Schuster 2009-03-16 16:17 ` Bill Long 1 sibling, 1 reply; 14+ messages in thread From: Wolfgang Schuster @ 2009-03-15 17:20 UTC (permalink / raw) To: mailing list for ConTeXt users Am 15.03.2009 um 04:23 schrieb Bill Long: > Dear Hans, > > Can you help check if you can implement a new feature of "pinyin" > input in context? Is a lua based method a option for you? Here is a primitive converter, not perfect and could fail but it gives you a first impression, the missing 'ǎ' in the output is a font problem. \startluacode function commands.convertpinyin(text,number) local replaced local number = tonumber(number) if string.find(text,"a") or string.find(text,"e") then if number==1 then text = string.gsub(text,"a","ā") text = string.gsub(text,"e","ē") elseif number==2 then text = string.gsub(text,"a","á") text = string.gsub(text,"e","é") elseif number==3 then text = string.gsub(text,"a","ǎ") text = string.gsub(text,"e","ě") elseif number==4 then text = string.gsub(text,"a","à") text = string.gsub(text,"e","è") end replaced = false else replaced = true end while replaced do if number==1 then text = string.gsub(text,"i","ī") text = string.gsub(text,"o","ō") if string.find(text,"o") then else text = string.gsub(text,"u","ū") end text = string.gsub(text,"v","ǖ") elseif number==2 then text = string.gsub(text,"i","í") text = string.gsub(text,"o","ó") if string.find(text,"o") then else text = string.gsub(text,"u","ú") end text = string.gsub(text,"v","ǘ") elseif number==3 then text = string.gsub(text,"o","ǒ") text = string.gsub(text,"i","ǐ") if string.find(text,"o") then else text = string.gsub(text,"u","ǔ") end text = string.gsub(text,"u","ǔ") text = string.gsub(text,"v","ǚ") elseif number==4 then text = string.gsub(text,"o","ò") text = string.gsub(text,"i","ì") if string.find(text,"o") then else text = string.gsub(text,"u","ù") end text = string.gsub(text,"v","ǜ") end replaced = false end tex.sprint(tex.ctxcatcodes,text) end local letter = lpeg.R("az") local number = lpeg.R("09") local pinyin = lpeg.C(letter^1) * lpeg.C(number^0) / commands.convertpinyin local parser = (pinyin)^0 function commands.pinyin(str) parser:match(str) end \stopluacode \def\pinyin#1{\ctxlua{commands.pinyin([[#1]])}} \starttext \pinyin{ni2hao3} \pinyin{huai4} \stoptext Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-15 17:20 ` Wolfgang Schuster @ 2009-03-16 16:17 ` Bill Long 2009-03-16 18:29 ` Arthur Reutenauer 2009-03-16 20:23 ` Wolfgang Schuster 0 siblings, 2 replies; 14+ messages in thread From: Bill Long @ 2009-03-16 16:17 UTC (permalink / raw) To: ntg-context The pinyin has 5 kind of tone for one pronunciation. As it's hard to input, and in CJK 1,2,3,4 are use to represent the tone, (the fifth is no special tone mark). In the book for children, the pinyin always show above the Chinese like the picture I upload. To make it show correctly is an good start, but if there are some tools to automatic add PinYin , it will be more attractive. In Chinese they do have the character which have multi pronunciation, but most of them only has single pronunciation, I can try to find out some dict to translate Chinese Character into PinYin if anyone can help integrate this convert tool into context. On Sun, Mar 15, 2009 at 06:20:34PM +0100, Wolfgang Schuster wrote: > > Am 15.03.2009 um 04:23 schrieb Bill Long: > >> Dear Hans, >> >> Can you help check if you can implement a new feature of "pinyin" >> input in context? > > > Is a lua based method a option for you? > > Here is a primitive converter, not perfect and could fail but it gives > you a first impression, the missing 'ǎ' in the output is a font problem. > > \startluacode > > function commands.convertpinyin(text,number) > local replaced > local number = tonumber(number) > if string.find(text,"a") or string.find(text,"e") then > if number==1 then > text = string.gsub(text,"a","ā") > text = string.gsub(text,"e","ē") > elseif number==2 then > text = string.gsub(text,"a","á") > text = string.gsub(text,"e","é") > elseif number==3 then > text = string.gsub(text,"a","ǎ") > text = string.gsub(text,"e","ě") > elseif number==4 then > text = string.gsub(text,"a","à") > text = string.gsub(text,"e","è") > end > replaced = false > else > replaced = true > end > while replaced do > if number==1 then > text = string.gsub(text,"i","ī") > text = string.gsub(text,"o","ō") > if string.find(text,"o") then else text = > string.gsub(text,"u","ū") end > text = string.gsub(text,"v","ǖ") > elseif number==2 then > text = string.gsub(text,"i","í") > text = string.gsub(text,"o","ó") > if string.find(text,"o") then else text = > string.gsub(text,"u","ú") end > text = string.gsub(text,"v","ǘ") > elseif number==3 then > text = string.gsub(text,"o","ǒ") > text = string.gsub(text,"i","ǐ") > if string.find(text,"o") then else text = > string.gsub(text,"u","ǔ") end > text = string.gsub(text,"u","ǔ") > text = string.gsub(text,"v","ǚ") > elseif number==4 then > text = string.gsub(text,"o","ò") > text = string.gsub(text,"i","ì") > if string.find(text,"o") then else text = > string.gsub(text,"u","ù") end > text = string.gsub(text,"v","ǜ") > end > replaced = false > end > tex.sprint(tex.ctxcatcodes,text) > end > > local letter = lpeg.R("az") > local number = lpeg.R("09") > > local pinyin = lpeg.C(letter^1) * lpeg.C(number^0) / > commands.convertpinyin > > local parser = (pinyin)^0 > > function commands.pinyin(str) > parser:match(str) > end > > \stopluacode > > \def\pinyin#1{\ctxlua{commands.pinyin([[#1]])}} > > \starttext > > \pinyin{ni2hao3} > \pinyin{huai4} > > \stoptext > > Wolfgang > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-16 16:17 ` Bill Long @ 2009-03-16 18:29 ` Arthur Reutenauer 2009-03-16 20:23 ` Wolfgang Schuster 1 sibling, 0 replies; 14+ messages in thread From: Arthur Reutenauer @ 2009-03-16 18:29 UTC (permalink / raw) To: ntg-context > To make it show correctly is an good start, but if there are some > tools to automatic add PinYin , it will be more attractive. It is definitely possible to do that in Lua, given the appropriate data. The Unihan database could be a start. We also need to find a way to report if a character has several possible pronounciations, and let the user input the correct one in the given context. Arthur ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-16 16:17 ` Bill Long 2009-03-16 18:29 ` Arthur Reutenauer @ 2009-03-16 20:23 ` Wolfgang Schuster 2009-03-16 21:17 ` Arthur Reutenauer 2009-03-17 21:22 ` Bill Long 1 sibling, 2 replies; 14+ messages in thread From: Wolfgang Schuster @ 2009-03-16 20:23 UTC (permalink / raw) To: mailing list for ConTeXt users Am 16.03.2009 um 17:17 schrieb Bill Long: > The pinyin has 5 kind of tone for one pronunciation. As it's hard to > input, and in CJK 1,2,3,4 are use to represent the tone, (the fifth > is no special tone mark). > > In the book for children, the pinyin always show above the Chinese > like the picture I upload. A solution like can be easy integrated in a ruby command because you need only a command parameter for the ruby text, e.g. \setupruby[command=\pinyin] but you're looking for something like the translate module. > To make it show correctly is an good start, but if there are some > tools to automatic add PinYin , it will be more attractive. In Chinese > they do have the character which have multi pronunciation, but most of > them only has single pronunciation, I can try to find out some dict to > translate Chinese Character into PinYin if anyone can help integrate > this convert tool into context. If you can provide such a list Hans can add the information to char- def.lua, for the moment you have to rely on my \pinyin command, I have now written a new version on a word macro I found. Wolfgang \startluacode function commands.pinyin(str) str = string.gsub(str,"r1","1r") str = string.gsub(str,"r2","2r") str = string.gsub(str,"r3","3r") str = string.gsub(str,"r4","4r") str = string.gsub(str,"r5","5r") str = string.gsub(str,"ng1","1ng") str = string.gsub(str,"ng2","2ng") str = string.gsub(str,"ng3","3ng") str = string.gsub(str,"ng4","4ng") str = string.gsub(str,"ng5","5ng") str = string.gsub(str,"n1","1n") str = string.gsub(str,"n2","2n") str = string.gsub(str,"n3","3n") str = string.gsub(str,"n4","4n") str = string.gsub(str,"n1","5n") str = string.gsub(str,"ai1","a1i") str = string.gsub(str,"ai2","a2i") str = string.gsub(str,"ai3","a3i") str = string.gsub(str,"ai4","a4i") str = string.gsub(str,"ai5","a5i") str = string.gsub(str,"ei1","e1i") str = string.gsub(str,"ei2","e2i") str = string.gsub(str,"ei3","e3i") str = string.gsub(str,"ei4","e4i") str = string.gsub(str,"ei5","e5i") str = string.gsub(str,"ao1","a1o") str = string.gsub(str,"ao2","a2o") str = string.gsub(str,"ao3","a3o") str = string.gsub(str,"ao4","a4o") str = string.gsub(str,"ao5","a5o") str = string.gsub(str,"ou1","o1u") str = string.gsub(str,"ou2","o2u") str = string.gsub(str,"ou3","o3u") str = string.gsub(str,"ou4","o4u") str = string.gsub(str,"ou5","o5u") str = string.gsub(str,"uu1","v1") str = string.gsub(str,"uu2","v2") str = string.gsub(str,"uu3","v3") str = string.gsub(str,"uu4","v4") str = string.gsub(str,"uu","ü") -- is this correct? str = string.gsub(str,"o1","ō") str = string.gsub(str,"o2","ó") str = string.gsub(str,"o3","ǒ") str = string.gsub(str,"o4","ò") str = string.gsub(str,"e1","ē") str = string.gsub(str,"e2","é") str = string.gsub(str,"e3","ě") str = string.gsub(str,"e4","è") str = string.gsub(str,"i1","ī") str = string.gsub(str,"i2","í") str = string.gsub(str,"i3","ǐ") str = string.gsub(str,"i4","ì") str = string.gsub(str,"u1","ū") str = string.gsub(str,"u2","ú") str = string.gsub(str,"u3","ǔ") str = string.gsub(str,"u4","ù") str = string.gsub(str,"v1","ǖ") str = string.gsub(str,"v2","ǘ") str = string.gsub(str,"v3","ǚ") str = string.gsub(str,"v4","ǜ") str = string.gsub(str,"a1","ā") str = string.gsub(str,"a2","á") str = string.gsub(str,"a3","ǎ") str = string.gsub(str,"a4","à") tex.sprint(tex.ctxcatcodes,str) end \stopluacode \def\pinyin#1{\ctxlua{commands.pinyin([[#1]])}} \starttext \definedfont[name:arialunicodems*default] \pinyin{ni2hao3} \pinyin{huai4} \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-16 20:23 ` Wolfgang Schuster @ 2009-03-16 21:17 ` Arthur Reutenauer 2009-03-17 21:22 ` Bill Long 1 sibling, 0 replies; 14+ messages in thread From: Arthur Reutenauer @ 2009-03-16 21:17 UTC (permalink / raw) To: Mailing list for ConTeXt users > If you can provide such a list Hans can add the information to > char-def.lua, As I mentioned, the Unihan database has a very comprehensive list (probably too comprehensive). I made it into a Lua list, but need to polish it (sorry, 500+ Kb, not attaching). It can be downloaded from http://github.com/reutenauer/luapinyin then tools/pinyins.lua We will need the \pinyin command anyway, for the cases where there is an ambiguity. Arthur ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-16 20:23 ` Wolfgang Schuster 2009-03-16 21:17 ` Arthur Reutenauer @ 2009-03-17 21:22 ` Bill Long 2009-03-17 21:47 ` Wolfgang Schuster 1 sibling, 1 reply; 14+ messages in thread From: Bill Long @ 2009-03-17 21:22 UTC (permalink / raw) To: ntg-context On Mon, Mar 16, 2009 at 09:23:50PM +0100, Wolfgang Schuster wrote: > > Am 16.03.2009 um 17:17 schrieb Bill Long: > >> The pinyin has 5 kind of tone for one pronunciation. As it's hard to >> input, and in CJK 1,2,3,4 are use to represent the tone, (the fifth >> is no special tone mark). >> >> In the book for children, the pinyin always show above the Chinese >> like the picture I upload. > > A solution like can be easy integrated in a ruby command because > you need only a command parameter for the ruby text, > e.g. \setupruby[command=\pinyin] but you're looking for something > like the translate module. In fact, 2 features I need, 1. the easy way to support PinYin, both input and the format, As I mentioned, I hope the pinyin can be placed over the Chinese character it represented automatically with some environment or so. 2. automatic convert/add pinyin to Chinese Character , now I use sed to make, but I still hope there are some more easy way. > >> To make it show correctly is an good start, but if there are some >> tools to automatic add PinYin , it will be more attractive. In Chinese >> they do have the character which have multi pronunciation, but most of >> them only has single pronunciation, I can try to find out some dict to >> translate Chinese Character into PinYin if anyone can help integrate >> this convert tool into context. > > If you can provide such a list Hans can add the information to char- > def.lua, > for the moment you have to rely on my \pinyin command, I have now > written > a new version on a word macro I found. > > Wolfgang > > \startluacode > > function commands.pinyin(str) > str = string.gsub(str,"r1","1r") > str = string.gsub(str,"r2","2r") > str = string.gsub(str,"r3","3r") > str = string.gsub(str,"r4","4r") > str = string.gsub(str,"r5","5r") > str = string.gsub(str,"ng1","1ng") > str = string.gsub(str,"ng2","2ng") > str = string.gsub(str,"ng3","3ng") > str = string.gsub(str,"ng4","4ng") > str = string.gsub(str,"ng5","5ng") > str = string.gsub(str,"n1","1n") > str = string.gsub(str,"n2","2n") > str = string.gsub(str,"n3","3n") > str = string.gsub(str,"n4","4n") > str = string.gsub(str,"n1","5n") > str = string.gsub(str,"ai1","a1i") > str = string.gsub(str,"ai2","a2i") > str = string.gsub(str,"ai3","a3i") > str = string.gsub(str,"ai4","a4i") > str = string.gsub(str,"ai5","a5i") > str = string.gsub(str,"ei1","e1i") > str = string.gsub(str,"ei2","e2i") > str = string.gsub(str,"ei3","e3i") > str = string.gsub(str,"ei4","e4i") > str = string.gsub(str,"ei5","e5i") > str = string.gsub(str,"ao1","a1o") > str = string.gsub(str,"ao2","a2o") > str = string.gsub(str,"ao3","a3o") > str = string.gsub(str,"ao4","a4o") > str = string.gsub(str,"ao5","a5o") > str = string.gsub(str,"ou1","o1u") > str = string.gsub(str,"ou2","o2u") > str = string.gsub(str,"ou3","o3u") > str = string.gsub(str,"ou4","o4u") > str = string.gsub(str,"ou5","o5u") > str = string.gsub(str,"uu1","v1") > str = string.gsub(str,"uu2","v2") > str = string.gsub(str,"uu3","v3") > str = string.gsub(str,"uu4","v4") > str = string.gsub(str,"uu","ü") -- is this correct? it's correct, although this character maybe rarely/never been used with this tone. > str = string.gsub(str,"o1","ō") > str = string.gsub(str,"o2","ó") > str = string.gsub(str,"o3","ǒ") > str = string.gsub(str,"o4","ò") > str = string.gsub(str,"e1","ē") > str = string.gsub(str,"e2","é") > str = string.gsub(str,"e3","ě") > str = string.gsub(str,"e4","è") > str = string.gsub(str,"i1","ī") > str = string.gsub(str,"i2","í") > str = string.gsub(str,"i3","ǐ") > str = string.gsub(str,"i4","ì") > str = string.gsub(str,"u1","ū") > str = string.gsub(str,"u2","ú") > str = string.gsub(str,"u3","ǔ") > str = string.gsub(str,"u4","ù") > str = string.gsub(str,"v1","ǖ") > str = string.gsub(str,"v2","ǘ") > str = string.gsub(str,"v3","ǚ") > str = string.gsub(str,"v4","ǜ") > str = string.gsub(str,"a1","ā") > str = string.gsub(str,"a2","á") > str = string.gsub(str,"a3","ǎ") > str = string.gsub(str,"a4","à") > tex.sprint(tex.ctxcatcodes,str) > end > > \stopluacode > > \def\pinyin#1{\ctxlua{commands.pinyin([[#1]])}} > > \starttext > > \definedfont[name:arialunicodems*default] > > \pinyin{ni2hao3} > \pinyin{huai4} > > \stoptext > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: pinyin in context 2009-03-17 21:22 ` Bill Long @ 2009-03-17 21:47 ` Wolfgang Schuster 0 siblings, 0 replies; 14+ messages in thread From: Wolfgang Schuster @ 2009-03-17 21:47 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: wolf-newjap.tex --] [-- Type: application/octet-stream, Size: 1337 bytes --] %D \module %D [ file=wolf-jap, %D version=20xx.xx.xx, %D title=\CONTEXT\ User Module, %D subtitle=Japanese, %D author=Wolfgang Schuster, %D date=\currentdate, %D copyright=Wolfgang Schuster] \unprotect \startconstants all overhang: overhang \stopconstants \def\????rb{@@@@rb} \newdimen\rubywidth \newsignal\rubysignal \def\setupruby {\dodoubleargument\getparameters[\????rb]} \def\startRUBY {\dosingleempty\dostartRUBY} \def\dostartRUBY[#1]% {\dontleavehmode \bgroup \iffirstargument \setupruby[#1]% \fi \ifdim\lastskip=\rubysignal \def\@@@@rboverhang{no}% \fi} \def\startRB#1\stopRB {\setbox1=\hbox{#1}} \def\startRT#1\stopRT {\setbox0=\hbox{#1}} \def\stopRUBY {\dimen0=\wd0 \multiply\dimen0 by\@@@@rbscale \divide\dimen0 by 1000 \dimen1=\wd1 \ifdim\dimen0>\dimen1 \ifx\@@@@rboverhang\v!yes \rubywidth=\dimen1 \else \rubywidth=\dimen0 \fi \else \rubywidth=\dimen1 \fi \vbox {\hbox\!!to\rubywidth %{\hss\switchtobodyfont[\dimexpr\@@@@rbscale\bodyfontsize\relax]\box0\hss} {\hss\box0\hss}% \hbox\!!to\rubywidth{\hss\small\box1\hss}}% \egroup \hskip\rubysignal} \setupruby [align=middle, overhang=yes, scale=500] \protect \endinput [-- Attachment #2: wolf-jap.tex --] [-- Type: application/octet-stream, Size: 2281 bytes --] %D \module %D [ file=wolf-jap, %D version=20xx.xx.xx, %D title=\CONTEXT\ User Module, %D subtitle=Japanese, %D author=Wolfgang Schuster, %D date=\currentdate, %D copyright=Wolfgang Schuster] \writestatus{loading}{Context User Module / Japanese} \unprotect %D Systemvariable \def\????rb{@@@@rb} % RuBy %D Setup for rubyenvironment \def\setupruby% {\dosingleempty\dosetupruby} \def\dosetupruby[#1]% {\getparameters[\????rb][#1]} %D Ruby definition \def\ruby% {\dosingleempty\doruby} \def\doruby[#1]#2#3% Zeichen unter Rubybase im Moment nicht unterstützt {\dontleavehmode \bgroup \getparameters[\????rb][#1]% \offinterlineskip \edef\localstrut{\@@@@rbstrut}% \edef\rubysize {\switchtobodyfont[\the\dimexpr\@@@@rbscale\bodyfontsize\relax]}% \setbox0=\hbox{#2}\dimen0=\wd0 \setbox1=\hbox{\rubysize#3}\dimen1=\wd1 \ifdim\dimen0>\dimen1 \hbox to \dimen0 {\vbox {\hbox to \dimen0{\hss\ifx\localstrut\v!yes\strut\fi\box1\hss} \doifvalue{\@@@@rbdistance}{\vskip\@@@@rbdistance} \hbox{\ifx\localstrut\v!yes\strut\fi\box0}}}\space% \else %\hbox to \dimen1 % {\vbox % {\hbox{\box1} % \vskip-0.7ex % \hbox to \dimen1{\hss\ifx\localstrut\v!yes\strut\fi\box0\hss}}}% \hbox to \dimen0 {\vbox {\hbox to \dimen0{\rubysize\hss\ifx\localstrut\v!yes\strut\fi\box1\hss} \doifvalue{\@@@@rbdistance}{\vskip\@@@@rbdistance} \hbox{\ifx\localstrut\v!yes\strut\fi\box0}}}\space% \fi \egroup \ignorespaces} %D A few examples %D %D Text text text %D \ruby{ruby base}{ruby text} %D text text text %D \ruby[scale=0.7,strut=no,distance=]{ruby base}{ruby text} %D text text text %D %D Text text text %D \ruby{ruby base}{ruby text} %D text text text %D \ruby[strut=no]{ruby base}{ruby text} %D text text text %D %D Text text text %D \ruby{ruby base}{very long ruby text} %D text text text %D \ruby[scale=0.8,strut=no,distance=]{ruby base}{very long ruby text} %D text text text %D Default values \setupruby [\c!distance=-0.7ex, \c!scale=0.6, \c!strut=\v!yes] \protect \endinput [-- Attachment #3: js-ruby.tex --] [-- Type: application/octet-stream, Size: 601 bytes --] \def\rubyfont{\rm} \newtoks\rubybase \newtoks\rubytext \newdimen\rubywidth \def\startRUBY {\bgroup} \def\stopRUBY {\setbox0\hbox{\rubyfont\strut\the\rubytext\unskip}% \setbox1\hbox{\strut\the\rubybase\unskip}% \ifdim\wd0>\wd1 \rubywidth\wd0 \else \rubywidth\wd1 \fi \vbox {\offinterlineskip \hbox to\rubywidth{\hss\box0\hss}% \hbox to\rubywidth{\hss\box1\hss}}% \egroup} \def\startRB#1\stopRB{\rubybase{#1}} \def\startRT#1\stopRT{\rubytext{#1}} \def\ruby#1#2% {\startRUBY \startRB#1\stopRB \startRT#2\stopRT \stopRUBY} \endinput [-- Attachment #4: Type: text/plain, Size: 737 bytes --] Am 17.03.2009 um 22:22 schrieb Bill Long: > In fact, 2 features I need, > > 1. the easy way to support PinYin, both input and the format, As I > mentioned, I hope the pinyin can be placed over the Chinese > character it represented automatically with some environment or > so. I attached a few old files I used to simple ruby texts but none of them is a perfect solution, if you get a proper macro it should support complex and simple ruby. > 2. automatic convert/add pinyin to Chinese Character , now I use > sed to make, but I still hope there are some more easy way. Arthur list can be used for this but you still ned markup to show which characters need reading and then you could also use a ruby command. Wolfgang [-- Attachment #5: Type: text/plain, Size: 487 bytes --] ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-03-17 21:47 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-03-11 4:44 pinyin in context Bill Long 2009-03-11 5:08 ` Yue Wang 2009-03-12 4:48 ` Bill Long 2009-03-11 15:26 ` Arthur Reutenauer 2009-03-12 6:27 ` Bill Long 2009-03-15 3:23 ` Bill Long 2009-03-15 16:17 ` Hans Hagen 2009-03-15 17:20 ` Wolfgang Schuster 2009-03-16 16:17 ` Bill Long 2009-03-16 18:29 ` Arthur Reutenauer 2009-03-16 20:23 ` Wolfgang Schuster 2009-03-16 21:17 ` Arthur Reutenauer 2009-03-17 21:22 ` Bill Long 2009-03-17 21:47 ` Wolfgang Schuster
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).