Content deleted Content added
Updated some comments near the top. This update mirrors that at Wiktionary. |
Uncaching the library functions, per User:Erutuon's performance analysis. |
||
Line 11:
local export = {}
local ASYLL = "̯"
Line 74 ⟶ 57:
return ""
else
local atLeft =
local atRight =
if atLeft then
if atRight then
return
else
return
end
elseif atRight then
return
else
return text
Line 92 ⟶ 75:
local function parseBoolean(text)
if type(text) == "string" then
text =
if text ~= "" and text ~= "0" and
return true
end
Line 103 ⟶ 86:
chars = chars or {}
local index = 1
for ch in
chars[index] = ch
index = index + 1
Line 109 ⟶ 92:
if index <= #chars then
if shorten then
else
repeat
Line 121 ⟶ 104:
local function string_gsub2(text, pattern, subst)
return
end
Line 147 ⟶ 130:
local function ZTBL(text, sep)
local tbl = {}
for key in
tbl[key] = true
end
Line 162 ⟶ 145:
local outSeq = {}
code =
code =
for text in
text = fastTrim(text)
if text ~= "" then
local temp =
if temp ~= "" then
error("'"..code.."' contains unsupported characters: "..temp)
Line 178 ⟶ 161:
["y"] = "0", ["h"] = "0h", ["w"] = "0w"
}
text =
text =
if
error("contains misplaced underscores: "..code)
end
-- a plain {i} protected from dialect-specific reflexes
text =
-- "yi'y" and "'yiy" sequences
text =
if aposA ~= "" then
-- "dwelling upon" i
Line 222 ⟶ 205:
["0w"] = "_W"
}
text =
if
error("contains g that is not part of ng: "..code)
end
Line 245 ⟶ 228:
["'"] = ""
}
text =
-- Enforce CVC, CVCVC, CVCCVC, etc. phonotactics,
-- but allow VC, CV at affix boundaries
-- where a vowel may link to another morpheme's consonant.
temp =
if
then
error("pseudo-glides may not neighbor a consonant")
end
if
error("pseudo-glides may only be at the beginning or end"..code)
end
if
error("vowels must be separated by a consonant: "..code)
end
if
error("each consonant cluster is limited to two: "..code)
end
if
error("may not end with a consonant cluster: "..code)
end
if consonX ~= consonY then
error("may only begin with single or geminated consonant: "
Line 350 ⟶ 333:
local version = args and args.version
local map = BENDER_MAPS[
type(version) == "string" and
] or BENDER_DEFAULT
local outSeq = {}
for _, text in pairs(inSeq) do
text =
addUnique(outSeq, text)
end
Line 372 ⟶ 355:
local function toMOD(text)
text =
return text
end
Line 412 ⟶ 395:
local outSeq = {}
for _, text in pairs(inSeq) do
text =
addUnique(outSeq, text)
end
Line 452 ⟶ 435:
local function maxF1(a, b)
if b then
return VOWEL[
else
return VOWEL[
end
end
Line 461 ⟶ 444:
-- Morphemes can begin with geminated consonants, but spoken words cannot.
text =
function(conson, _, __, vowel)
if conson == "hG" then
Line 482 ⟶ 465:
-- To block this in the template argument, use "'i" instead of "i".
text = " "..text
text =
"([ jGw])( *)(h[jw])( *)i( *)(h[jw])( *)("..VI..")",
function(nonVowel, _, consonX, __, ___, consonY, ____, vowel)
Line 506 ⟶ 489:
end
)
text =
-- Restore protected {i}, we won't be checking for it anymore.
text =
return text
Line 584 ⟶ 567:
["l"] = { ["j"] = "L" }
}
for primary in
local map2 = map[primary]
if not map2 then
Line 687 ⟶ 670:
map["Hj"] = map["Hj"] or map["i"]..map["^"]
local key
for primary in
for secondary in
key = primary..secondary
map[key] = map[key] or (map[primary]..map[secondary])
end
end
for vowel in
key = vowel.."@"
map[key] = map[key] or (map[vowel]..map["@"])
Line 712 ⟶ 695:
-- and no pseudo-glide, display phrase up to five times
-- with each of the different pseudo-glides and possible vowel reflexes.
if IS_VOWEL[
text = "_j"..code
toPhoneticRemainder(text, config, false, rightFlag)
Line 730 ⟶ 713:
return
end
if IS_VOWEL[
text = code.."_j"
toPhoneticRemainder(text, config, leftFlag, false)
Line 782 ⟶ 765:
end
toPhoneticRemainder(code, config)
addUnique(outSeq,
config.outSeq = outSeq
config.initialJ = initialJ
Line 793 ⟶ 776:
if not diphthongs then
-- {ww} always causes the second glide to surface.
text =
end
text =
text =
text =
text =
text =
-- Preserve these exceptionally stable clusters.
text =
-- Unstable consonant clusters trigger epenthesis.
-- Liquids before coronal obstruents.
text =
-- Nasals and liquids after coronal obstruents.
text =
-- Heterorganic clusters.
-- Labial consonants neighboring coronal or dorsal consonants.
text =
-- Coronal consonants neighboring labial or dorsal consonants.
text =
-- Dorsal consonants neighboring labial or coronal consonants.
text =
-- Organic speech involves certain consonant cluster assimilations.
Line 827 ⟶ 810:
-- Forward assimilation of rounded consonants.
-- There is no rounded coronal obstruent.
text =
-- Backward assimilation of remaining secondary articulations.
text =
-- Backward nasal assimilation of primary articulations.
text =
-- No longer need to protect exceptionally stable consonant clusters.
text =
-- Give a vowel height to all epenthetic vowels that still lack one.
Line 846 ⟶ 829:
-- Tag all vowels for next set of operations.
text =
-- There is no variation in the surface realizations of vowels
Line 885 ⟶ 868:
local f2
if flag then
f2 =
else
f2 =
end
return (
Line 895 ⟶ 878:
)
end
text =
function(a, b, c, d, e, f, g, h)
return subst(a, b, c, d, e, f, g, h, leftFlag)
end
)
text =
function(a, b, c, d, e, f, g, h)
return subst(a, b, c, d, e, f, g, h, rightFlag)
Line 920 ⟶ 903:
-- Exceptionally for the single word "rej".
text =
function(prefix, vowel, suffix)
return prefix..FRONT_VOWEL[vowel]..suffix
Line 928 ⟶ 911:
-- Vowels always claim the secondary articulation
-- of a neighboring back unrounded glide.
text =
return prefix..BACK_VOWEL[vowel]
end)
text =
return BACK_VOWEL[vowel]..suffix
end)
Line 937 ⟶ 920:
-- Unless already claimed, epenthetic vowels after a glide
-- always claim the secondary articulation to the left.
text =
function(primaryL, secondaryL, _, vowel)
return (
Line 948 ⟶ 931:
-- Unless already claimed, vowels before a glide
-- always claim the secondary articulation to the right.
text =
function(vowel, epenth, primaryR, secondaryR)
return (
Line 959 ⟶ 942:
-- For now, unless already claimed, vowels before a rounded consonant
-- claim the secondary articulation to the right.
text =
return ROUND_VOWEL[vowel]..suffix
end)
Line 965 ⟶ 948:
-- For now, unless already claimed, remaining vowels
-- claim the secondary articulation to the left.
text =
function(secondaryL, _, vowel)
return secondaryL.._..VOWEL[F1[vowel]][F2[secondaryL]]
Line 976 ⟶ 959:
return prefix..VOWEL[F1[vowel]][F2[secondaryR]]..infix..secondaryR
end
text =
-- Change certain vowels in a special environment from round to front.
Line 984 ⟶ 967:
end
)
text =
function(prefix, vowelL, _, conson, __, vowelR)
if conson ~= "hw" or F1[vowelL] ~= F1[vowelR] then
Line 991 ⟶ 974:
end
)
text =
function(prefix, vowel, suffix)
return prefix..FRONT_VOWEL[vowel]..suffix
end
)
text =
text =
-- Tag certain glide-vowel-non-glide sequences for special reflexes.
text =
text =
text =
text =
"([EeiAV7MOou]@? *h[jw] *)([aAQ] *[ptkmnNrl])", "%1/%2")
text =
"(hj *[aEei]@? *hw *)("..V.." *[ptkmnNrl])", "%1/%2")
-- Untag certain sequences, exempting them from special reflexes.
text =
-- Special reflexes.
text =
function(secondaryL, _, vowel, __, primaryR, secondaryR)
return secondaryL.._..
Line 1,024 ⟶ 1,007:
-- Temporarily cancel epenthetic {i} neighboring {yi'y}.
text =
-- {yi'y} neighboring {i} may now be demoted to {y}.
text =
text =
-- {'yiy} may now be demoted everywhere.
text =
text =
-- For the purposes of this template,
-- surface all glides pronounced in isolation.
text =
if not diphthongs then
-- Opportunistically front this vowel.
text =
-- Surface certain glides.
text =
text =
text =
text =
text =
"([ptkmnNrl].).@( *)h(j *[AV7MQOou])", "%1%2H%3")
text =
text =
function(vowelL, infix, _, vowelR)
if F1[vowelL] > F1[vowelR] then
Line 1,056 ⟶ 1,039:
end
)
text =
function(vowelL, infix, _, vowelR)
if F1[vowelL] > F1[vowelR] then
Line 1,063 ⟶ 1,046:
end
)
text =
function(vowelL, infix, _, vowelR)
if F1[vowelL] < F1[vowelR] then
Line 1,070 ⟶ 1,053:
end
)
text =
function(vowel, _, secondary)
if F2[vowel] ~= F2[secondary] then
Line 1,080 ⟶ 1,063:
-- Protect word-final epenthetic vowels after non-glides
-- from the next operation.
text =
-- De-epenthesize vowels if they still neighbor unsurfaced glides.
text =
text =
-- Adjust F1 of currently remaining epenthetic vowels.
Line 1,096 ⟶ 1,079:
)
text =
end
-- Delete all remaining unsurfaced glides.
text =
-- Surface realization for {yi'y}.
text =
if not diphthongs then
Line 1,131 ⟶ 1,114:
-- Turn this surfaced glide into an epenthetic vowel.
text =
end
if MERGED_VOWELS then
text =
return VOWEL[F1[vowel] + 1][F2[vowel]]
end)
Line 1,160 ⟶ 1,143:
index = index2
until index == 1
text =
end
-- Tweak remaining consonants, using offsets as a guide.
text =
function(
offsetL, primaryL, secondaryL, _, primaryR, secondaryR, offsetR
Line 1,263 ⟶ 1,246:
-- Elegantly connect long and epenthetic vowels across word gaps.
text =
text =
text =
text =
text =
if W_OFF_GLIDES then
Line 1,277 ⟶ 1,260:
end
if false and PHONETIC_DETAILS then
text =
function(primary, _, epenth)
if epenth == "" then
Line 1,285 ⟶ 1,268:
)
else
text =
end
text =
-- Remove [w] off-glides after certain consonants
-- when they occur after rounded vowels.
text =
text =
end
Line 1,298 ⟶ 1,281:
if IMPLIED_SECONDARIES then
if PARENTHETICAL_EPENTHESIS then
text =
if diphthongs then
text =
end
end
if PARENTHETICAL_EPENTHESIS then
text =
end
end
Line 1,311 ⟶ 1,294:
if PARENTHETICAL_EPENTHESIS then
if not diphthongs then
text =
end
text =
text =
end
-- Convert remaining word gaps to liaison.
text =
text =
text =
text =
addUnique(outSeq, text)
Line 1,338 ⟶ 1,321:
-- For other values, list both possible dialect reflexes where applicable.
local dialect = args and args.dialect and
if dialect == "rālik" then
dialect = "ralik"
Line 1,351 ⟶ 1,334:
-- Real-world pronunciation said to vary by sociological factors,
-- but all realizations may occur in free variation.
local modeJ = splitChars(args and args.J and
local initialJ = PHONETIC_ARG_J[modeJ[1] or ""] or "t"
local medialJ = PHONETIC_ARG_J[modeJ[2] or ""] or "s"
Line 1,380 ⟶ 1,363:
for _, str in pairs(inSeq) do
str =
str =
str =
local isRalik = dialect == "ralik"
if isRalik or dialect == "ratak" then
Line 1,411 ⟶ 1,394:
function export.bender(frame)
return
end
Line 1,419 ⟶ 1,402:
function export.parse(frame)
return
end
function export.phonemic(frame)
return
end
function export.phonetic(frame)
return
end
|