Help with pronunciation modules

Jump to navigation Jump to search

Help with pronunciation modules

Hi. Can you look at why the ['кь'] = 'ḳ̍' rule is ignored in the headword line of ажакьа? The addition of a stress sign plays a role.

Vahag (talk)12:58, 28 June 2015

"к" is the third letter from the start. The mw.ustring.gsub(text, '..', tt) line takes successive pairs of characters and substitutes them according to the mapping; here, they are "аж", "ак", and "ьа". Since "кь" is on an odd position, it is not matched. I vaguely remember some other module being bitten by the same problem before.

My solution cheats a bit; it just restricts the pattern to pairs which start with consonants that have entries in the table. If you ever need to process overlapping pairs, or ones with some other consonant letters, it will no longer work.

Keφr13:46, 28 June 2015

I see, thanks.

Vahag (talk)14:01, 28 June 2015

Some languages are written in multiple scripts. Assume we have an automatic transliteration module for each script. Is there a way to make, for example, Ossetian to be transliterated with Module:os-translit when written in Cyrl and with Module:Geor-translit, when written in Geor? I understand that I can copy the content of the latter into the former, but that would lead to duplication and dis-synchronization over time.

Vahag (talk)09:23, 5 July 2015

That is what require is for. Just check whether the script is "Geor", and if so then return require("Module:Geor-translit").tr(text, lang, sc). Is that something you are actually trying to do?

Keφr09:55, 5 July 2015

Yes, I am trying to do it. I would like to start with Kipchak (Module:qwm-translit), which can be written in Latin and Armenian. How would the code look like if I want to skip transliteration if it's Latn, and forward to Module:Armn-translit, if it's Armn. There are many more languages in the pipeline.

Vahag (talk)11:03, 5 July 2015
function export.tr(text, lang, sc)
	if sc == "Latn" then
		return nil
	elseif sc == "Armn" then
		return require("Module:Armn-translit").tr(text, lang, sc)
	else
		error("Huệ nương!")
	end
end

It is that easy.

Keφr11:25, 5 July 2015

Thanks. What am I doing wrong? Remember, you are dealing with a module illiterate.

Vahag (talk)12:06, 5 July 2015

Forgot to return export at the end of the module.

And actually, it turns out you could have just plugged Module:Armn-translit directly as the module for qwm. Module:links already skips transliteration when the script is of the Latin family (Latn, xx-Latn or Latinx).

Keφr12:13, 5 July 2015

Thanks again. But let's keep Module:qwm-translit for a case where we have an entry in the Arabic script, but no manual transliteration. On a related note, can Module:Geor-translit change behaviour based on language? Namely, if lang=sva then ["ჳ"]="w", in all other cases ["ჳ"]="wi".

Vahag (talk)13:39, 5 July 2015

Module:Cyrs-Glag-translit does something like that, but I happen to dislike that approach. (It does work, though.)

Keφr15:20, 5 July 2015

Looks complicated. I'll probably create a separate module for Svan.

Vahag (talk)16:56, 5 July 2015