Movatterモバイル変換


[0]ホーム

URL:


跳转到内容
维基词典自由的多语言词典
搜索

模組:Amf-utilities

維基詞典,自由的多語言詞典

此模块缺少說明文檔。請協助創建
相關連結:子頁面列表链入嵌入包含測試用例沙盒

localexport={}-- internal encoding using [a-zA-Z]export.encode={["ã"]="A",["ɓ"]="B",["cʼ"]="C",["ɗ"]="D",["ɛ"]="E",["ɠ"]="G",["ĩ"]="I",["ɲ"]="N",["ɔ"]="O",["sh"]="S",["tʼ"]="T",["ʔ"]="Q",}export.decode={A="ã",B="ɓ",C="cʼ",D="ɗ",E="ɛ",G="ɠ",I="ĩ",N="ɲ",O="ɔ",S="sh",T="tʼ",Q="ʔ",}export.sortkey={A="a",B="b",C="c",D="d",E="e",G="g",I="i",N="n",O="o",S="sh",T="t",Q="ʔ",}-- parse a word into syllables using the internal encoding-- returns a table with extra info, e.g. "Wucʼê" becomes:-- { "wu", "Ce", accent=2, cap=true, falling=true }functionexport.syllabify(word)word=mw.ustring.toNFD(word)locallowered=word:ulower()localcap=lowered~=wordword=loweredlocalaccent=word:match('\204[\129\130]')local_,count=word:gsub('\204[\129\130]','')ifcount>1thenerror("More than one diacritic found.")endword=word:gsub("[tc]ʼ",export.encode)ifword:match("ʼ")thenerror("Uncoupled ʼ found.")endword=word:gsub("sh","S")word=word:gsub("[\194-\223][\128-\191]",export.encode)word=word:gsub("[bBcCdDgGhjklmnNpqrsStwxyzQ][aeiouEO]",".%0"):gsub("([aeiouEO])([aeiouEO]\204[\129\130])","%1.%2")-- e.g. tiá -> ti.á:gsub("^%.",""):gsub("%.%.+",".")localsyllables=mw.text.split(word,".",true)localaccented=0fori,sylinipairs(syllables)dosyllables[i],count=syl:gsub("\204[\129\130]","")ifcount==1thenaccented=ibreakendendsyllables.accent=accentedsyllables.cap=capsyllables.falling=accent=="\204\130"returnsyllablesend-- inverse of export.syllabifyfunctionexport.combine(syllables)locala,c,f=syllables.accent,syllables.cap,syllables.fallinglocaldiacritic=fand"\204\130"or"\204\129"localword=""-- do not use table.concat to avoid modifying inputfori,sylinipairs(syllables)doifi==athensyl=syl:gsub("[aeiouEO]","%0"..diacritic,1)endword=word..sylendword=word:gsub("[BCDEGNOSTQ]",export.decode)ifcthenword=word:gsub("^[\1-\127\194-\255][\128-\191]*",string.uupper,1)endreturnmw.ustring.toNFC(word)end-- generates the sort key for categorization-- wucʼê --> wuce2'-- (2: accent on second syllable)-- (apostrophe at the end: falling tone)functionexport.makeSortKey(text,lang,sc)iflang~="amf"orsc~="Latn"thenrequire("Module:debug").track("amf-utilities/sort")returntextendwords=mw.text.split(text," ",true)fori,wordinipairs(words)dolocalsuccess,syllables=pcall(export.syllabify,word)ifsuccessthenwords[i]=table.concat(syllables):gsub("[BCDEGNOSTQ]",export.sortkey)..syllables.accent..(syllables.fallingand"'"or"")elserequire("Module:debug").track("amf-utilities/sort")endendreturntable.concat(words," ")endreturnexport
来自“https://zh.wiktionary.org/w/index.php?title=Module:Amf-utilities&oldid=8803084
分类:​

[8]ページ先頭

©2009-2025 Movatter.jp