如何生成孟加拉语单词的音译?

如何生成孟加拉语单词的音译?

我需要将孟加拉语/孟加拉语单词音译为拉丁语。例如,一个新命令,

\generateTransliteration{আমার সোনার বাংলা}

将提供结果 = “寂静之声

据我所知,没有针对孟加拉语/孟加拉语的软件包或命令可以执行此操作。如果真的没有可用的命令,我该如何使用 newcommand 自己生成它。我认为,我必须将 ISO 15919 映射到拉丁字符。但是,我不知道该怎么做。[我读过几个关于梵文和梵语的 stackexchange 问题/答案,但它们并不是这个问题]。编译器:Xetex,语言:孟加拉语/孟加拉语。谢谢

答案1

我对孟加拉语一无所知,所以我不知道这些组合字形是否可以像我在这里所做的那样被普遍地逐个解码,或者是否需要将它们作为组合单元进行解码。

我的意思是,有些字形是复合的。例如,বাং经过分解后,会扩展为三个字符。在此分解中,根据我的指示,它会音译为bān。但是,我不知道 是否总是音译为 ,还是仅在遵循这些先前的字形时才会音译为n。我假设是一次总是音译,但是,我愿意听听情况可能并非如此。

我也不清楚孟加拉语中的字母大小写,因此我的映射遵循了 OP 的引导,尽管看起来该语言中实际上可能没有字母大小写。

我只显示了\tcmapto原帖表情中对应字符的 s。不过,我使用了https://unicode-table.com/en/blocks/bengali/帮助我进行映射(以及十六进制到十进制的转换器),了解每个字符对应的字符代码等。其他字形可以从那里添加到\tcmapto。我允许根据字形本身或 unicode 插槽进行映射\tcmapnumto(如 MWE 注释中所示)。

\documentclass{article}
\usepackage{tokcycle}
\def\tcmapto#1#2{\expandafter\def\csname tcmapto\number`#1\endcsname{#2}}
\def\tcmapnumto#1#2{\expandafter\def\csname tcmapto#1\endcsname{#2}}
\def\tcremap#1{\ifcsname tcmapto\number`#1\endcsname
                 \csname tcmapto\number`#1\endcsname\else#1\fi}

\tcmapto{ং}{n}% OR \tcmapnumto{2434}{n}
\tcmapto{আ}{Ā}% OR \tcmapnumto{2438}{Ā}
\tcmapto{ন}{n}% OR \tcmapnumto{2472}{n}
\tcmapto{ব}{b}% OR \tcmapnumto{2476}{b}
\tcmapto{ম}{m}% OR \tcmapnumto{2478}{m}
\tcmapto{র}{ra}% OR \tcmapnumto{2480}{ra}
\tcmapto{ল}{l}% OR \tcmapnumto{2482}{l}
\tcmapto{স}{s}% OR \tcmapnumto{2488}{s}
\tcmapto{া}{ā}% OR \tcmapnumto{2494}{ā}
\tcmapto{ো}{ō}% OR \tcmapnumto{2507}{ō}

\begin{document}
\Characterdirective{\addcytoks[x]{\tcremap{#1}}}
\tokencyclexpress
আমার সোনার বাংলা

আ-মা-র  সো-না-র  বাং-লা
\endtokencyclexpress
\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

获取数据https://en.wikipedia.org/wiki/ISO_15919 制作映射表b-map.tex

就像这样b-map.tex

\zztable{
\zzrow{.}{।}
\zzrow{ā}{া}
\zzrow{i}{ি}
\zzrow{ī}{ী}
\zzrow{u}{ু}
\zzrow{ū}{ূ}
\zzrow{ō}{ো}
\zzrow{ē}{ে}
\zzrow{ai}{ৈ}
\zzrow{au}{ৌ}
\zzrow{a}{অ}
\zzrow{ā}{আ}
\zzrow{i}{ই}
\zzrow{ī}{ঈ}
\zzrow{u}{উ}
\zzrow{ū}{ঊ}
\zzrow{r̥}{ঋ}
\zzrow{r̥̄}{ৠ}
\zzrow{l̥}{ঌ}
\zzrow{l̥̄}{ৡ}
\zzrow{ē}{এ}
\zzrow{ai}{ঐ}
\zzrow{ō}{ও}
\zzrow{au}{ঔ}
\zzrow{n}{ং}
\zzrow{m̐}{ঁ}
\zzrow{ḥ}{ঃ}
\zzrow{k}{ক}
\zzrow{kh}{খ}
\zzrow{g}{গ}
\zzrow{gh}{ঘ}
\zzrow{ṅ}{ঙ}
\zzrow{c}{চ}
\zzrow{ch}{ছ}
\zzrow{j}{জ}
\zzrow{jh}{ঝ}
\zzrow{ñ}{ঞ}
\zzrow{ṭ}{ট}
\zzrow{ṭh}{ঠ}
\zzrow{ḍ}{ড}
\zzrow{ḍh}{ঢ}
\zzrow{ṛ}{ড়}
\zzrow{ṛh}{ঢ়}
\zzrow{ṇ}{ণ}
\zzrow{t}{ত}
\zzrow{th}{থ}
\zzrow{d}{দ}
\zzrow{dh}{ধ}
\zzrow{n}{ন}
\zzrow{p}{প}
\zzrow{ph}{ফ}
\zzrow{b}{ব}
\zzrow{bh}{ভ}
\zzrow{m}{ম}
\zzrow{y}{য} 
\zzrow{ẏ}{য়}\zzrow{ẏ}{য়}
\zzrow{r}{র}
\zzrow{l}{ল}
\zzrow{ś}{শ}
\zzrow{ṣ}{ষ}
\zzrow{s}{স}
\zzrow{h}{হ}
\zzrow{’}{ঽ}
\zzrow{q}{ক়}
\zzrow{k͟h}{খ়}
\zzrow{ġ}{গ়}
\zzrow{z}{জ়}
\zzrow{f}{ফ়}
}

然后你可以让 xetex 将其读取为

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Times New Roman}
\tracinglostchars2
\makeatletter
\def\zztable#1{#1}
\def\zzrow#1#2{\expandafter\gdef\csname B-#2\endcsname{#1}}
\def\generateTransliteration#1{\xgenerateTransliteration#1@}
\def\xgenerateTransliteration{\futurelet\tmp\xxgenerateTransliteration}
\def\xxgenerateTransliteration{%
\ifx\tmp\@sptoken\space\fi
\xxxgenerateTransliteration
}
\def\xxxgenerateTransliteration#1{%
\expandafter\ifx\csname B-#1\endcsname\relax?%
\expandafter\show\csname B-#1\endcsname
\fi
\csname B-#1\endcsname
\xgenerateTransliteration}
\expandafter\def\csname B-@\endcsname#1{}
\makeatother

\input{b-map}
\begin{document}


Here: \generateTransliteration{আমার সোনার বাংলা}

\end{document}

表中缺少一些字母,导致\show日志和排版出现错误?希望您可以扩展表格,因为我看不懂脚本,我无法检查维基百科中是否缺少数据,或者在将表格编辑为 tex 语法时是否丢失了数据。

如果它们是自己音译的话,您可能还需要添加标点符号。

注意拉丁现代没有 U+1E41(带点重音的 m),因此我在这里使用了 Times New Roman,另一种方法是将该字符设置为使用 cinstructed 重音)

答案3

另一种方法是使用正则表达式和replace函数,带expl3语法。它可以在xelatex或lualatex下运行。

例子

映射可以轻松更新。

必须首先替换最长的子字符串,就像查找/替换一样。

第一次迭代:

太阳系

来自维基百科的文章:太阳系。

平均能量损失

\documentclass{article}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{fontspec}
\usepackage{multicol}
\newfontface\translitfont{Noto Serif}
\newfontface\bengalifont{Noto Sans Bengali}[Script=Bengali,Renderer=HarfBuzz,Colour=blue]

\ExplSyntaxOn
\tl_new:N \l_mytrans_tl

% transliteration
\NewDocumentCommand{\indictrans}{ m }
{
\tl_set:Nn \l_mytrans_tl { #1 }
\doindictrans
    { \translitfont
                    \tl_use:N \l_mytrans_tl
        }
}

% text (transliteration)
\NewDocumentCommand{\indictransg}{ m }
{
    #1 ~ (
\tl_set:Nn \l_mytrans_tl { #1 }
\doindictrans
    { \translitfont
                    \tl_use:N \l_mytrans_tl
        } )
}

% multi-line environment
\NewDocumentEnvironment{isoindictranse}{ +b }
{
\tl_set:Nn \l_mytrans_tl { #1 }
\doindictrans
%\bengalifont
    { \translitfont
                    \tl_use:N \l_mytrans_tl
        }
}
{ }

% the mapping
\newcommand\doindictrans{
\tl_replace_all:Nnn \l_mytrans_tl { ড় } { r^^^^0323a } 
\tl_replace_all:Nnn \l_mytrans_tl { ঢ় } { r^^^^0323ha } 
\tl_replace_all:Nnn \l_mytrans_tl { য় } { y^^^^0307a } 
\tl_replace_all:Nnn \l_mytrans_tl { ক় } { qa } 
\tl_replace_all:Nnn \l_mytrans_tl { খ় } { k͟ha } 
\tl_replace_all:Nnn \l_mytrans_tl { গ় } { g^^^^0307a } 
\tl_replace_all:Nnn \l_mytrans_tl { জ় } { za } 
\tl_replace_all:Nnn \l_mytrans_tl { ফ় } { fa } 
\tl_replace_all:Nnn \l_mytrans_tl { অ } { a } 
\tl_replace_all:Nnn \l_mytrans_tl { আ } { ā } 
\tl_replace_all:Nnn \l_mytrans_tl { ই } { i } 
\tl_replace_all:Nnn \l_mytrans_tl { ঈ } { ī } 
\tl_replace_all:Nnn \l_mytrans_tl { উ } { u } 
\tl_replace_all:Nnn \l_mytrans_tl { ঊ } { ū } 
\tl_replace_all:Nnn \l_mytrans_tl { ঋ } { r̥ } 
\tl_replace_all:Nnn \l_mytrans_tl { ৠ } { r̥̄ } 
\tl_replace_all:Nnn \l_mytrans_tl { ঌ } { l̥ } 
\tl_replace_all:Nnn \l_mytrans_tl { ৡ } { l̥̄ } 
\tl_replace_all:Nnn \l_mytrans_tl { এ } { ē } 
\tl_replace_all:Nnn \l_mytrans_tl { ঐ } { ai } 
\tl_replace_all:Nnn \l_mytrans_tl { ও } { ō } 
\tl_replace_all:Nnn \l_mytrans_tl { ঔ } { au } 
\tl_replace_all:Nnn \l_mytrans_tl { ং } { ṁ } 
\tl_replace_all:Nnn \l_mytrans_tl { ঁ } { m̐ } 
\tl_replace_all:Nnn \l_mytrans_tl { ঃ } { ḥ } 
\tl_replace_all:Nnn \l_mytrans_tl { ক } { ka } 
\tl_replace_all:Nnn \l_mytrans_tl { খ } { kha } 
\tl_replace_all:Nnn \l_mytrans_tl { গ } { ga } 
\tl_replace_all:Nnn \l_mytrans_tl { ঘ } { gha } 
\tl_replace_all:Nnn \l_mytrans_tl { ঙ } { ṅa } 
\tl_replace_all:Nnn \l_mytrans_tl { চ } { ca } 
\tl_replace_all:Nnn \l_mytrans_tl { ছ } { cha } 
\tl_replace_all:Nnn \l_mytrans_tl { জ } { ja } 
\tl_replace_all:Nnn \l_mytrans_tl { ঝ } { jha } 
\tl_replace_all:Nnn \l_mytrans_tl { ঞ } { ña } 
\tl_replace_all:Nnn \l_mytrans_tl { ট } { ṭa } 
\tl_replace_all:Nnn \l_mytrans_tl { ঠ } { ṭha } 
\tl_replace_all:Nnn \l_mytrans_tl { ড } { ḍa } 
\tl_replace_all:Nnn \l_mytrans_tl { ঢ } { ḍha } 
\tl_replace_all:Nnn \l_mytrans_tl { ণ } { ṇa } 
\tl_replace_all:Nnn \l_mytrans_tl { ত } { ta } 
\tl_replace_all:Nnn \l_mytrans_tl { থ } { tha } 
\tl_replace_all:Nnn \l_mytrans_tl { দ } { da } 
\tl_replace_all:Nnn \l_mytrans_tl { ধ } { dha } 
\tl_replace_all:Nnn \l_mytrans_tl { ন } { na } 
\tl_replace_all:Nnn \l_mytrans_tl { প } { pa } 
\tl_replace_all:Nnn \l_mytrans_tl { ফ } { pha } 
\tl_replace_all:Nnn \l_mytrans_tl { ব } { ba } 
\tl_replace_all:Nnn \l_mytrans_tl { ভ } { bha } 
\tl_replace_all:Nnn \l_mytrans_tl { ম } { ma } 
\tl_replace_all:Nnn \l_mytrans_tl { য } { ya } 
\tl_replace_all:Nnn \l_mytrans_tl { র } { ra } 
\tl_replace_all:Nnn \l_mytrans_tl { ৰ } { ra } 
\tl_replace_all:Nnn \l_mytrans_tl { ল } { la } 
\tl_replace_all:Nnn \l_mytrans_tl { ৱ } { va } 
\tl_replace_all:Nnn \l_mytrans_tl { শ } { śa } 
\tl_replace_all:Nnn \l_mytrans_tl { ষ } { ṣa } 
\tl_replace_all:Nnn \l_mytrans_tl { স } { sa } 
\tl_replace_all:Nnn \l_mytrans_tl { হ } { ha } 
\tl_replace_all:Nnn \l_mytrans_tl { ঽ } { ’ } 
\tl_replace_all:Nnn \l_mytrans_tl { । } { . } 
\tl_replace_all:Nnn \l_mytrans_tl { া } { -ā } 
\tl_replace_all:Nnn \l_mytrans_tl { ি } { -i } 
\tl_replace_all:Nnn \l_mytrans_tl { ী } { -ī } 
\tl_replace_all:Nnn \l_mytrans_tl { ু } { -u } 
\tl_replace_all:Nnn \l_mytrans_tl { ূ } { -ū } 
\tl_replace_all:Nnn \l_mytrans_tl { ৃ } { -r } 
\tl_replace_all:Nnn \l_mytrans_tl { ৄ } { -rr } 
\tl_replace_all:Nnn \l_mytrans_tl { ে } { -e } 
\tl_replace_all:Nnn \l_mytrans_tl { ৈ } { -ai } 
\tl_replace_all:Nnn \l_mytrans_tl { ো } { -o } 
\tl_replace_all:Nnn \l_mytrans_tl { ৌ } { -au } 
\tl_replace_all:Nnn \l_mytrans_tl { ্ } {  virama } 
\tl_replace_all:Nnn \l_mytrans_tl { ৎ } { t } 
\tl_replace_all:Nnn \l_mytrans_tl { ৗ } { - } 
\tl_replace_all:Nnn \l_mytrans_tl { ০ } { 0 } 
\tl_replace_all:Nnn \l_mytrans_tl { ১ } { 1 } 
\tl_replace_all:Nnn \l_mytrans_tl { ২ } { 2 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৩ } { 3 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৪ } { 4 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৫ } { 5 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৬ } { 6 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৭ } { 7 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৮ } { 8 } 
\tl_replace_all:Nnn \l_mytrans_tl { ৯ } { 9 } 


% tidy-up: inherent a, etc
\regex_replace_all:nnN { a\-(ai) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-(au) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-([āiueoīū]{1}) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-(rr) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-(r) } { \1 } \l_mytrans_tl
\tl_replace_all:Nnn \l_mytrans_tl { avirama } { } 
\tl_replace_all:Nnn \l_mytrans_tl { ṁ } { ng } 
\regex_replace_all:nnN { \-([āiueoīū]{1}) } { \1 } \l_mytrans_tl
%...
}
 


\ExplSyntaxOff


\begin{document}

\bengalifont
\begin{multicols}{5}
\noindent অ (\indictrans{অ})\par
\noindent আ (\indictrans{আ})\par
\noindent ই (\indictrans{ই})\par
\noindent ঈ (\indictrans{ঈ})\par
\noindent উ (\indictrans{উ})\par
\noindent ঊ (\indictrans{ঊ})\par
\noindent ঋ (\indictrans{ঋ})\par
\noindent ৠ (\indictrans{ৠ})\par
\noindent ঌ (\indictrans{ঌ})\par
\noindent ৡ (\indictrans{ৡ})\par
\noindent এ (\indictrans{এ})\par
\noindent ঐ (\indictrans{ঐ})\par
\noindent ও (\indictrans{ও})\par
\noindent ঔ (\indictrans{ঔ})\par
\noindent ং (\indictrans{ং})\par
\noindent ঁ (\indictrans{ঁ})\par
\noindent ঃ (\indictrans{ঃ})\par
\noindent ক (\indictrans{ক})\par
\noindent খ (\indictrans{খ})\par
\noindent গ (\indictrans{গ})\par
\noindent ঘ (\indictrans{ঘ})\par
\noindent ঙ (\indictrans{ঙ})\par
\noindent চ (\indictrans{চ})\par
\noindent ছ (\indictrans{ছ})\par
\noindent জ (\indictrans{জ})\par
\noindent ঝ (\indictrans{ঝ})\par
\noindent ঞ (\indictrans{ঞ})\par
\noindent ট (\indictrans{ট})\par
\noindent ঠ (\indictrans{ঠ})\par
\noindent ড (\indictrans{ড})\par
\noindent ঢ (\indictrans{ঢ})\par
\noindent ড় (\indictrans{ড়})\par
\noindent ঢ় (\indictrans{ঢ়})\par
\noindent ণ (\indictrans{ণ})\par
\noindent ত (\indictrans{ত})\par
\noindent থ (\indictrans{থ})\par
\noindent দ (\indictrans{দ})\par
\noindent ধ (\indictrans{ধ})\par
\noindent ন (\indictrans{ন})\par
\noindent প (\indictrans{প})\par
\noindent ফ (\indictrans{ফ})\par
\noindent ব (\indictrans{ব})\par
\noindent ভ (\indictrans{ভ})\par
\noindent ম (\indictrans{ম})\par
\noindent য (\indictrans{য})\par
\noindent য় (\indictrans{য়})\par
\noindent র (\indictrans{র})\par
\noindent ৰ (\indictrans{ৰ})\par
\noindent ল (\indictrans{ল})\par
\noindent ৱ (\indictrans{ৱ})\par
\noindent শ (\indictrans{শ})\par
\noindent ষ (\indictrans{ষ})\par
\noindent স (\indictrans{স})\par
\noindent হ (\indictrans{হ})\par
\noindent ঽ (\indictrans{ঽ})\par
\noindent ক় (\indictrans{ক়})\par
\noindent খ় (\indictrans{খ়})\par
\noindent গ় (\indictrans{গ়})\par
\noindent জ় (\indictrans{জ়})\par
\noindent ফ় (\indictrans{ফ়})\par
\noindent । (\indictrans{।})\par
\noindent া (\indictrans{া})\par
\noindent ি (\indictrans{ি})\par
\noindent ী (\indictrans{ী})\par
\noindent ু (\indictrans{ু})\par
\noindent ূ (\indictrans{ূ})\par
\noindent ৃ (\indictrans{ৃ})\par
\noindent ৄ (\indictrans{ৄ})\par
\noindent ে (\indictrans{ে})\par
\noindent ৈ (\indictrans{ৈ})\par
\noindent ো (\indictrans{ো})\par
\noindent ৌ (\indictrans{ৌ})\par
\noindent ্ (\indictrans{্})\par
\noindent ৎ (\indictrans{ৎ})\par
\noindent ৗ (\indictrans{ৗ})\par
\noindent ০ (\indictrans{০})\par
\noindent ১ (\indictrans{১})\par
\noindent ২ (\indictrans{২})\par
\noindent ৩ (\indictrans{৩})\par
\noindent ৪ (\indictrans{৪})\par
\noindent ৫ (\indictrans{৫})\par
\noindent ৬ (\indictrans{৬})\par
\noindent ৭ (\indictrans{৭})\par
\noindent ৮ (\indictrans{৮})\par
\noindent ৯ (\indictrans{৯})\par
\end{multicols}

\indictransg{আমার সোনার বাংলা}

\indictransg{সৌরজগৎ}

\begin{isoindictranse}


সৌরজগৎ হল সূর্য ও প্রত্যক্ষ বা পরোক্ষভাবে[ক] সূর্য-প্রদক্ষিণকারী তথা পরস্পরের প্রতি অভিকর্ষজ টানে আবদ্ধ মহাজাগতিক বস্তুগুলিকে নিয়ে গড়ে একটি ব্যবস্থা। আকাশগঙ্গা ছায়াপথের কেন্দ্রস্থল থেকে ২৬,০০০ আলোকবর্ষ দূরে কালপুরুষ বাহুতে এই গ্রহ ব্যবস্থাটি অবস্থিত। সৌরজগতে প্রত্যক্ষভাবে সূর্য-প্রদক্ষিণকারী বস্তুগুলির মধ্যে আটটি গ্রহই বৃহত্তম।[খ] অন্য ক্ষুদ্রতর বস্তুগুলির মধ্যে রয়েছে বামন গ্রহ ও সৌরজগতের ক্ষুদ্র বস্তুসমূহ। পরোক্ষভাবে সূর্য-প্রদক্ষিণকারী বস্তুগুলির মধ্যে দু’টি প্রাকৃতিক উপগ্রহ ক্ষুদ্রতম গ্রহ বুধের থেকেও আকারে বড়ো।[গ] 
\end{isoindictranse}


\end{document}

答案4

使用 \banglatranslit 命令。

\documentclass{article}
\usepackage{bangla}

\begin{document}
    \banglatranslit{আমার সোনার বাংলা}
\end{document} 

相关内容