<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://youjo.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACompound</id>
	<title>Module:Compound - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://youjo.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACompound"/>
	<link rel="alternate" type="text/html" href="https://youjo.wiki/index.php?title=Module:Compound&amp;action=history"/>
	<updated>2026-10-17T18:51:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://youjo.wiki/index.php?title=Module:Compound&amp;diff=1478&amp;oldid=prev</id>
		<title>Chizu: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://youjo.wiki/index.php?title=Module:Compound&amp;diff=1478&amp;oldid=prev"/>
		<updated>2022-09-23T19:42:15Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:42, 23 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en-GB&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Chizu</name></author>
	</entry>
	<entry>
		<id>https://youjo.wiki/index.php?title=Module:Compound&amp;diff=1477&amp;oldid=prev</id>
		<title>Wiktionary&gt;Benwing2: &#039;words&#039; -&gt; &#039;terms&#039; in affix and compound categories (see Wiktionary:Beer parlour/2022/August)</title>
		<link rel="alternate" type="text/html" href="https://youjo.wiki/index.php?title=Module:Compound&amp;diff=1477&amp;oldid=prev"/>
		<updated>2022-09-02T01:30:50Z</updated>

		<summary type="html">&lt;p&gt;&amp;#039;words&amp;#039; -&amp;gt; &amp;#039;terms&amp;#039; in affix and compound categories (see &lt;a href=&quot;https://en.wiktionary.org/wiki/Beer_parlour/2022/August&quot; class=&quot;extiw&quot; title=&quot;wiktionary:Beer parlour/2022/August&quot;&gt;Wiktionary:Beer parlour/2022/August&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local m_links = require(&amp;quot;Module:links&amp;quot;)&lt;br /&gt;
local m_utilities = require(&amp;quot;Module:utilities&amp;quot;)&lt;br /&gt;
local m_lang = require(&amp;quot;Module:languages&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local export = {}&lt;br /&gt;
&lt;br /&gt;
local u = mw.ustring.char&lt;br /&gt;
local rsub = mw.ustring.gsub&lt;br /&gt;
local usub = mw.ustring.sub&lt;br /&gt;
local ulen = mw.ustring.len&lt;br /&gt;
local rfind = mw.ustring.find&lt;br /&gt;
local rmatch = mw.ustring.match&lt;br /&gt;
&lt;br /&gt;
local debug_force_cat = false -- if set to true, always display categories even on userspace pages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local default_pos = &amp;quot;term&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- ABOUT TEMPLATE AND DISPLAY HYPHENS:&lt;br /&gt;
--&lt;br /&gt;
-- The &amp;quot;template hyphen&amp;quot; is the per-script hyphen character that is used in&lt;br /&gt;
-- template calls to indicate that a term is an affix. This is always a single&lt;br /&gt;
-- Unicode char, but there may be multiple possible hyphens for a given script.&lt;br /&gt;
-- Normally this is just the regular hyphen character &amp;quot;-&amp;quot;, but for some&lt;br /&gt;
-- non-Latin-script languages (currently only right-to-left languages), it&lt;br /&gt;
-- is different.&lt;br /&gt;
--&lt;br /&gt;
-- The &amp;quot;display hyphen&amp;quot; is the string (which might be an empty string) that&lt;br /&gt;
-- is added onto a term as displayed (and linked), to indicate that a term&lt;br /&gt;
-- is an affix. Currently this is always either the same as the template&lt;br /&gt;
-- hyphen or an empty string, but the code below is written generally enough&lt;br /&gt;
-- to handle arbitrary display hyphens. Specifically:&lt;br /&gt;
--&lt;br /&gt;
-- (1) For East Asian languages, the display hyphen is always blank.&lt;br /&gt;
-- (2) For Arabic-script languages, either tatweel (ـ) or ZWNJ (zero-width&lt;br /&gt;
--     non-joiner) are allowed as template hyphens, where ZWNJ is supported&lt;br /&gt;
--     primarily for Farsi, because some suffixes have non-joining behavior.&lt;br /&gt;
--     The display hyphen corresponding to tatweel is also tatweel, but the&lt;br /&gt;
--     display hyphen corresponding to ZWNJ is blank (tatweel is also the&lt;br /&gt;
--     default display hyphen, for calls to {{prefix}}/{{suffix}}/etc. that&lt;br /&gt;
--     don&amp;#039;t include an explicit hyphen).&lt;br /&gt;
&lt;br /&gt;
-- List of all Arabic scripts.&lt;br /&gt;
local arab_scripts = {&lt;br /&gt;
	&amp;quot;Arab&amp;quot;,&lt;br /&gt;
	-- WTF? Why are there a zillion language-specific variants of the&lt;br /&gt;
	-- Arabic script?&lt;br /&gt;
	&amp;quot;fa-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;kk-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ks-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ku-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ms-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;mzn-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ota-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;pa-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ps-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;sd-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;tt-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ug-Arab&amp;quot;,&lt;br /&gt;
	&amp;quot;ur-Arab&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Per-script template hyphens. The template hyphen is what appears in the&lt;br /&gt;
-- {{affix}}/{{prefix}}/{{suffix}}/etc. template (in the wikicode). See below.&lt;br /&gt;
--&lt;br /&gt;
-- The value below is a string consisting of one or more hyphen characters.&lt;br /&gt;
-- If there is more than one character, a non-default function must be&lt;br /&gt;
-- specified for the script in display_hyphens[] so the correct display&lt;br /&gt;
-- hyphen will be specified when no template hyphen is given (in {{suffix}}/&lt;br /&gt;
-- {{prefix}}/etc.).&lt;br /&gt;
--&lt;br /&gt;
-- Script detection is normally done when linking, but we need to do it&lt;br /&gt;
-- earlier. However, under most circumstances we don&amp;#039;t need to do script&lt;br /&gt;
-- detection. Specifically, we only need to do script detection for a given&lt;br /&gt;
-- language if&lt;br /&gt;
--&lt;br /&gt;
-- (a) the language has multiple scripts; and&lt;br /&gt;
-- (b) at least one of those scripts is listed below or in display_hyphens.&lt;br /&gt;
&lt;br /&gt;
local ZWNJ = u(0x200C) -- zero-width non-joiner&lt;br /&gt;
local arab_hyphens = &amp;quot;ـ&amp;quot; .. ZWNJ .. &amp;quot;-&amp;quot;&lt;br /&gt;
local template_hyphens = {&lt;br /&gt;
	-- Arabic scripts get added below&lt;br /&gt;
	[&amp;quot;Hebr&amp;quot;] = &amp;quot;־&amp;quot;,&lt;br /&gt;
	-- FIXME! What about the following right-to-left scripts?&lt;br /&gt;
	-- Adlm (Adlam)&lt;br /&gt;
	-- Armi (Imperial Aramaic)&lt;br /&gt;
	-- Avst (Avestan)&lt;br /&gt;
	-- Cprt (Cypriot)&lt;br /&gt;
	-- Khar (Kharoshthi)&lt;br /&gt;
	-- Mand (Mandaic/Mandaean)&lt;br /&gt;
	-- Mani (Manichaean)&lt;br /&gt;
	-- Mend (Mende/Mende Kikakui)&lt;br /&gt;
	-- Narb (Old North Arabian)&lt;br /&gt;
	-- Nbat (Nabataean/Nabatean)&lt;br /&gt;
	-- Nkoo (N&amp;#039;Ko)&lt;br /&gt;
	-- Orkh (Orkhon runes)&lt;br /&gt;
	-- Phli (Inscriptional Pahlavi)&lt;br /&gt;
	-- Phlp (Psalter Pahlavi)&lt;br /&gt;
	-- Phlv (Book Pahlavi)&lt;br /&gt;
	-- Phnx (Phoenician)&lt;br /&gt;
	-- Prti (Inscriptional Parthian)&lt;br /&gt;
	-- Rohg (Hanifi Rohingya)&lt;br /&gt;
	-- Samr (Samaritan)&lt;br /&gt;
	-- Sarb (Old South Arabian)&lt;br /&gt;
	-- Sogd (Sogdian)&lt;br /&gt;
	-- Sogo (Old Sogdian)&lt;br /&gt;
	-- Syrc (Syriac)&lt;br /&gt;
	-- Thaa (Thaana)&lt;br /&gt;
}&lt;br /&gt;
for _, script in ipairs(arab_scripts) do&lt;br /&gt;
	template_hyphens[script] = arab_hyphens&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Default display-hyphen funct&lt;br /&gt;
local function default_display_hyphen(script, hyph)&lt;br /&gt;
	if not hyph then&lt;br /&gt;
		return template_hyphens[script] or &amp;quot;-&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return hyph&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function no_display_hyphen(script, hyph)&lt;br /&gt;
	return &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function arab_get_display_hyphen(script, hyph)&lt;br /&gt;
	if not hyph then&lt;br /&gt;
		return &amp;quot;ـ&amp;quot; -- tatweel&lt;br /&gt;
	elseif hyph == ZWNJ then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return hyph&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Per-script function to return the correct display hyphen given the&lt;br /&gt;
-- script and template hyphen. The function should also handle the case&lt;br /&gt;
-- where the passed-in template hyphen is nil, corresponding to the&lt;br /&gt;
-- situation in {{prefix}}/{{suffix}}/etc. where no template hyphen is&lt;br /&gt;
-- specified.&lt;br /&gt;
local display_hyphens = {&lt;br /&gt;
	-- Arabic scripts get added below&lt;br /&gt;
	[&amp;quot;Hani&amp;quot;] = no_display_hyphen,&lt;br /&gt;
	-- The following is a mixture of several scripts. Hopefully&lt;br /&gt;
	-- the specs here are correct!&lt;br /&gt;
	[&amp;quot;Jpan&amp;quot;] = no_display_hyphen,&lt;br /&gt;
	[&amp;quot;Laoo&amp;quot;] = no_display_hyphen,&lt;br /&gt;
	[&amp;quot;Nshu&amp;quot;] = no_display_hyphen,&lt;br /&gt;
	[&amp;quot;Thaa&amp;quot;] = no_display_hyphen,&lt;br /&gt;
	[&amp;quot;Thai&amp;quot;] = no_display_hyphen,&lt;br /&gt;
}&lt;br /&gt;
for _, script in ipairs(arab_scripts) do&lt;br /&gt;
	display_hyphens[script] = arab_get_display_hyphen&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function glossary_link(entry, text)&lt;br /&gt;
	text = text or entry&lt;br /&gt;
	return &amp;quot;[[Appendix:Glossary#&amp;quot; .. entry .. &amp;quot;|&amp;quot; .. text .. &amp;quot;]]&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function make_compound_type(typ, alttext)&lt;br /&gt;
	return {&lt;br /&gt;
		text = glossary_link(typ, alttext) .. &amp;quot; compound&amp;quot;,&lt;br /&gt;
		cat = typ .. &amp;quot; compounds&amp;quot;,&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Make a compound type entry with a simple rather than glossary link.&lt;br /&gt;
-- These should be replaced with a glossary link when the entry in the glossary&lt;br /&gt;
-- is created.&lt;br /&gt;
local function make_non_glossary_compound_type(typ, alttext)&lt;br /&gt;
	local link = alttext and &amp;quot;[[&amp;quot; .. typ .. &amp;quot;|&amp;quot; .. alttext .. &amp;quot;]]&amp;quot; or &amp;quot;[[&amp;quot; .. typ .. &amp;quot;]]&amp;quot;&lt;br /&gt;
	return {&lt;br /&gt;
		text = link .. &amp;quot; compound&amp;quot;,&lt;br /&gt;
		cat = typ .. &amp;quot; compounds&amp;quot;,&lt;br /&gt;
	}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
export.compound_types = {&lt;br /&gt;
	[&amp;quot;alliterative&amp;quot;] = make_non_glossary_compound_type(&amp;quot;alliterative&amp;quot;),&lt;br /&gt;
	[&amp;quot;allit&amp;quot;] = &amp;quot;alliterative&amp;quot;,&lt;br /&gt;
	[&amp;quot;antonymous&amp;quot;] = make_non_glossary_compound_type(&amp;quot;antonymous&amp;quot;),&lt;br /&gt;
	[&amp;quot;ant&amp;quot;] = &amp;quot;antonymous&amp;quot;,&lt;br /&gt;
	[&amp;quot;bahuvrihi&amp;quot;] = make_compound_type(&amp;quot;bahuvrihi&amp;quot;, &amp;quot;bahuvrīhi&amp;quot;),&lt;br /&gt;
	[&amp;quot;bahu&amp;quot;] = &amp;quot;bahuvrihi&amp;quot;,&lt;br /&gt;
	[&amp;quot;bv&amp;quot;] = &amp;quot;bahuvrihi&amp;quot;,&lt;br /&gt;
	[&amp;quot;coordinative&amp;quot;] = make_compound_type(&amp;quot;coordinative&amp;quot;),&lt;br /&gt;
	[&amp;quot;coord&amp;quot;] = &amp;quot;coordinative&amp;quot;,&lt;br /&gt;
	[&amp;quot;descriptive&amp;quot;] = make_compound_type(&amp;quot;descriptive&amp;quot;),&lt;br /&gt;
	[&amp;quot;desc&amp;quot;] = &amp;quot;descriptive&amp;quot;,&lt;br /&gt;
	[&amp;quot;determinative&amp;quot;] = make_compound_type(&amp;quot;determinative&amp;quot;),&lt;br /&gt;
	[&amp;quot;det&amp;quot;] = &amp;quot;determinative&amp;quot;,&lt;br /&gt;
	[&amp;quot;dvandva&amp;quot;] = make_compound_type(&amp;quot;dvandva&amp;quot;),&lt;br /&gt;
	[&amp;quot;dva&amp;quot;] = &amp;quot;dvandva&amp;quot;,&lt;br /&gt;
	[&amp;quot;endocentric&amp;quot;] = make_compound_type(&amp;quot;endocentric&amp;quot;),&lt;br /&gt;
	[&amp;quot;endo&amp;quot;] = &amp;quot;endocentric&amp;quot;,&lt;br /&gt;
	[&amp;quot;exocentric&amp;quot;] = make_compound_type(&amp;quot;exocentric&amp;quot;),&lt;br /&gt;
	[&amp;quot;exo&amp;quot;] = &amp;quot;exocentric&amp;quot;,&lt;br /&gt;
	[&amp;quot;karmadharaya&amp;quot;] = make_compound_type(&amp;quot;karmadharaya&amp;quot;, &amp;quot;karmadhāraya&amp;quot;),&lt;br /&gt;
	[&amp;quot;karma&amp;quot;] = &amp;quot;karmadharaya&amp;quot;,&lt;br /&gt;
	[&amp;quot;kd&amp;quot;] = &amp;quot;karmadharaya&amp;quot;,&lt;br /&gt;
	[&amp;quot;rhyming&amp;quot;] = make_non_glossary_compound_type(&amp;quot;rhyming&amp;quot;),&lt;br /&gt;
	[&amp;quot;rhy&amp;quot;] = &amp;quot;rhyming&amp;quot;,&lt;br /&gt;
	[&amp;quot;synonymous&amp;quot;] = make_non_glossary_compound_type(&amp;quot;synonymous&amp;quot;),&lt;br /&gt;
	[&amp;quot;syn&amp;quot;] = &amp;quot;synonymous&amp;quot;,&lt;br /&gt;
	[&amp;quot;tatpurusa&amp;quot;] = make_compound_type(&amp;quot;tatpurusa&amp;quot;, &amp;quot;tatpuruṣa&amp;quot;),&lt;br /&gt;
	[&amp;quot;tat&amp;quot;] = &amp;quot;tatpurusa&amp;quot;,&lt;br /&gt;
	[&amp;quot;tp&amp;quot;] = &amp;quot;tatpurusa&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function pluralize(pos)&lt;br /&gt;
	if pos ~= &amp;quot;nouns&amp;quot; and usub(pos, -5) ~= &amp;quot;verbs&amp;quot; and usub(pos, -4) ~= &amp;quot;ives&amp;quot; then&lt;br /&gt;
		if pos:find(&amp;quot;[sx]$&amp;quot;) then&lt;br /&gt;
			pos = pos .. &amp;quot;es&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			pos = pos .. &amp;quot;s&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return pos&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function make_entry_name_no_links(lang, term)&lt;br /&gt;
	-- Remove links and call lang:makeEntryName(term).&lt;br /&gt;
	return m_lang.getNonEtymological(lang):makeEntryName(m_links.remove_links(term))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.link_term(terminfo, display_term, lang, sc, sort_key, force_cat, nocat)&lt;br /&gt;
	local terminfo_new = require(&amp;quot;Module:table&amp;quot;).shallowcopy(terminfo)&lt;br /&gt;
	local result&lt;br /&gt;
&lt;br /&gt;
	terminfo_new.term = display_term&lt;br /&gt;
	terminfo_new.sc = terminfo_new.sc or sc&lt;br /&gt;
	if terminfo_new.lang then&lt;br /&gt;
		result = require(&amp;quot;Module:etymology&amp;quot;).format_derived(lang, terminfo_new, sort_key, nocat,&lt;br /&gt;
			force_cat or debug_force_cat)&lt;br /&gt;
	else&lt;br /&gt;
		terminfo_new.lang = lang&lt;br /&gt;
		result = m_links.full_link(terminfo_new, &amp;quot;term&amp;quot;, false)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if terminfo_new.q then&lt;br /&gt;
		result = result .. &amp;quot; &amp;quot; .. require(&amp;quot;Module:qualifier&amp;quot;).format_qualifier(terminfo_new.q)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Figure out the appropriate script for the given affix and language (unless&lt;br /&gt;
-- the script is explicitly passed in), and return the values of&lt;br /&gt;
-- template_hyphens[] and display_hyphens[] for that script, substituting&lt;br /&gt;
-- default values as appropriate. Three values are returned:&lt;br /&gt;
--	DETECTED_SCRIPT, TEMPLATE_HYPHEN, DISPLAY_HYPHEN&lt;br /&gt;
local function get_template_and_display_hyphens(text, lang, sc)&lt;br /&gt;
	local scode&lt;br /&gt;
	-- 1. If the script is explicitly passed in, use it.&lt;br /&gt;
	if sc then&lt;br /&gt;
		scode = sc:getCode()&lt;br /&gt;
	else&lt;br /&gt;
		lang = m_lang.getNonEtymological(lang)&lt;br /&gt;
		-- If we don&amp;#039;t call shallowClone here, #possible_scripts always == 0.&lt;br /&gt;
		-- Something weird to do with the metatable that&amp;#039;s set on the table,&lt;br /&gt;
		-- coming from loadData.&lt;br /&gt;
		local possible_scripts = require(&amp;quot;Module:table&amp;quot;).shallowClone(lang:getScriptCodes())&lt;br /&gt;
		if #possible_scripts == 0 then&lt;br /&gt;
			-- This shouldn&amp;#039;t happen; if the language has no script codes,&lt;br /&gt;
			-- the list {&amp;quot;None&amp;quot;} should be returned.&lt;br /&gt;
			error(&amp;quot;Something is majorly wrong! Language &amp;quot; .. lang:getCanonicalName() .. &amp;quot; has no script codes.&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		if #possible_scripts == 1 then&lt;br /&gt;
			-- 2. If the language has only one possible script, use it.&lt;br /&gt;
			scode = possible_scripts[1]&lt;br /&gt;
		else&lt;br /&gt;
			-- 3. Check if any of the possible scripts for the language have&lt;br /&gt;
			--    non-default values for template_hyphens[] or&lt;br /&gt;
			--    display_hyphens[]. If so, we need to do script detection on&lt;br /&gt;
			--    the text. If not, just use &amp;quot;Latn&amp;quot;, which may not be&lt;br /&gt;
			--    technically correct but produces the right results because&lt;br /&gt;
			--    Latn has all default values for template_hyphens[] and&lt;br /&gt;
			--    display_hyphens[].&lt;br /&gt;
			local may_have_nondefault_hyphen = false&lt;br /&gt;
			for _, script in ipairs(possible_scripts) do&lt;br /&gt;
				if template_hyphens[script] or display_hyphens[script] then&lt;br /&gt;
					may_have_nondefault_hyphen = true&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if not may_have_nondefault_hyphen then&lt;br /&gt;
				scode = &amp;quot;Latn&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				scode = require(&amp;quot;Module:scripts&amp;quot;).findBestScript(text, lang):getCode()&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local template_hyphen = template_hyphens[scode] or &amp;quot;-&amp;quot;&lt;br /&gt;
	local display_hyphen = display_hyphens[scode] or default_display_hyphen&lt;br /&gt;
	return scode, template_hyphen, display_hyphen&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Find the type of affix (&amp;quot;prefix&amp;quot;, &amp;quot;infix&amp;quot;, &amp;quot;suffix&amp;quot;, &amp;quot;circumfix&amp;quot; or nil&lt;br /&gt;
-- for non-affix). Return the affix type and the displayed/linked equivalent&lt;br /&gt;
-- of the part (normally the same as the part but will be different for some&lt;br /&gt;
-- East Asian languages that use a regular hyphen as an affix-signaling&lt;br /&gt;
-- hyphen but have no display hyphen).&lt;br /&gt;
local function get_affix_type(lang, sc, part)&lt;br /&gt;
	if not part then&lt;br /&gt;
		return nil, nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local scode, thyph, dhyph = get_template_and_display_hyphens(part, lang, sc)&lt;br /&gt;
	thyph = &amp;quot;([&amp;quot; .. thyph .. &amp;quot;])&amp;quot;&lt;br /&gt;
	local hyphen_space_hyphen = thyph .. &amp;quot; &amp;quot; .. thyph&lt;br /&gt;
&lt;br /&gt;
	if part:find(&amp;quot;^%^&amp;quot;) then&lt;br /&gt;
		-- If part begins with ^, it&amp;#039;s not an affix no matter what.&lt;br /&gt;
		-- Strip off the ^ and return &amp;quot;no affix&amp;quot;.&lt;br /&gt;
		return nil, usub(part, 2)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Remove an asterisk if the morpheme is reconstructed and add it in the end.&lt;br /&gt;
	local reconstructed = &amp;quot;&amp;quot;&lt;br /&gt;
	if part:find(&amp;quot;^%*&amp;quot;) then &lt;br /&gt;
		reconstructed = &amp;quot;*&amp;quot;&lt;br /&gt;
		part = part:gsub(&amp;quot;^%*&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local affix_type = nil&lt;br /&gt;
&lt;br /&gt;
	local beginning_hyphen = rmatch(part, &amp;quot;^&amp;quot; .. thyph .. &amp;quot;.*$&amp;quot;)&lt;br /&gt;
	local ending_hyphen = rmatch(part, &amp;quot;^.*&amp;quot; .. thyph .. &amp;quot;$&amp;quot;)&lt;br /&gt;
	local beginning_dhyph = dhyph(scode, beginning_hyphen)&lt;br /&gt;
	local ending_dhyph = dhyph(scode, ending_hyphen)&lt;br /&gt;
&lt;br /&gt;
	if rfind(part, hyphen_space_hyphen) then&lt;br /&gt;
		affix_type = &amp;quot;circumfix&amp;quot;&lt;br /&gt;
		-- FIXME! Change to display hyphens?&lt;br /&gt;
	elseif beginning_hyphen and ending_hyphen then&lt;br /&gt;
		affix_type = &amp;quot;infix&amp;quot;&lt;br /&gt;
		-- Don&amp;#039;t do anything if the part is a single hyphen.&lt;br /&gt;
		-- This is probably correct.&lt;br /&gt;
		if (beginning_hyphen ~= beginning_dhyph or&lt;br /&gt;
			ending_hyphen ~= ending_dhyph) and ulen(part) &amp;gt; 1 then&lt;br /&gt;
			part = beginning_dhyph .. rsub(part, &amp;quot;^.(.-).$&amp;quot;, &amp;quot;%1&amp;quot;) .. ending_dhyph&lt;br /&gt;
		end&lt;br /&gt;
	elseif ending_hyphen then&lt;br /&gt;
		affix_type = &amp;quot;prefix&amp;quot;&lt;br /&gt;
		if ending_hyphen ~= ending_dhyph then&lt;br /&gt;
			part = rsub(part, &amp;quot;^(.-).$&amp;quot;, &amp;quot;%1&amp;quot;) .. ending_dhyph&lt;br /&gt;
		end&lt;br /&gt;
	elseif beginning_hyphen then&lt;br /&gt;
		affix_type = &amp;quot;suffix&amp;quot;&lt;br /&gt;
		if beginning_hyphen ~= beginning_dhyph then&lt;br /&gt;
			part = beginning_dhyph .. usub(part, 2)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	part = reconstructed .. part&lt;br /&gt;
	return affix_type, part&lt;br /&gt;
end&lt;br /&gt;
export.get_affix_type = get_affix_type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Iterate an array up to the greatest integer index found.&lt;br /&gt;
local function ipairs_with_gaps(t)&lt;br /&gt;
	local indices = require(&amp;quot;Module:table&amp;quot;).numKeys(t)&lt;br /&gt;
	local max_index = #indices &amp;gt; 0 and math.max(unpack(indices)) or 0&lt;br /&gt;
	local i = 0&lt;br /&gt;
	return function()&lt;br /&gt;
		while i &amp;lt; max_index do&lt;br /&gt;
			i = i + 1&lt;br /&gt;
			return i, t[i]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
export.ipairs_with_gaps = ipairs_with_gaps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Concatenate formatted parts together with any overall lit= spec plus categories, which are formatted&lt;br /&gt;
-- by prepending the language name. The value of an entry in CATEGORIES can be either a string&lt;br /&gt;
-- (which is formatted using SORT_KEY) or a table of the form {cat=CATEGORY, sort_key=SORT_KEY, sort_base=SORT_BASE},&lt;br /&gt;
-- specifying the sort key and sort base to use when formatting the category. If NOCAT is given, no&lt;br /&gt;
-- categories are added.&lt;br /&gt;
function export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
	local cattext&lt;br /&gt;
	if nocat then&lt;br /&gt;
		cattext = &amp;quot;&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		for i, cat in ipairs(categories) do&lt;br /&gt;
			if type(cat) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				categories[i] = m_utilities.format_categories({lang:getCanonicalName() .. &amp;quot; &amp;quot; .. cat.cat}, lang,&lt;br /&gt;
					cat.sort_key, cat.sort_base, force_cat or debug_force_cat)&lt;br /&gt;
			else&lt;br /&gt;
				categories[i] = m_utilities.format_categories({lang:getCanonicalName() .. &amp;quot; &amp;quot; .. cat}, lang,&lt;br /&gt;
					sort_key, nil, force_cat or debug_force_cat)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		cattext = table.concat(categories)&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(parts_formatted, &amp;quot; +&amp;amp;lrm; &amp;quot;) .. (lit and &amp;quot;, literally &amp;quot; .. m_links.mark(lit, &amp;quot;gloss&amp;quot;) or &amp;quot;&amp;quot;) .. cattext&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function process_compound_type(typ, nocap, notext, has_parts)&lt;br /&gt;
	local text_sections = {}&lt;br /&gt;
	local categories = {}&lt;br /&gt;
&lt;br /&gt;
	if typ then&lt;br /&gt;
		local typdata = export.compound_types[typ]&lt;br /&gt;
		if type(typdata) == &amp;quot;string&amp;quot; then&lt;br /&gt;
			typdata = export.compound_types[typdata]&lt;br /&gt;
		end&lt;br /&gt;
		if not typdata then&lt;br /&gt;
			error(&amp;quot;Internal error: Unrecognized type &amp;#039;&amp;quot; .. typ .. &amp;quot;&amp;#039;&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		local text = typdata.text&lt;br /&gt;
		if not nocap then&lt;br /&gt;
			text = require(&amp;quot;Module:string utilities&amp;quot;).ucfirst(text)&lt;br /&gt;
		end&lt;br /&gt;
		local cat = typdata.cat&lt;br /&gt;
		local oftext = typdata.oftext or &amp;quot;of&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
		if not notext then&lt;br /&gt;
			table.insert(text_sections, text)&lt;br /&gt;
			if has_parts then&lt;br /&gt;
				table.insert(text_sections, &amp;quot; &amp;quot;)&lt;br /&gt;
				table.insert(text_sections, oftext)&lt;br /&gt;
				table.insert(text_sections, &amp;quot; &amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		table.insert(categories, cat)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return text_sections, categories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_affixes(lang, sc, parts, pos, sort_key, typ, nocap, notext, nocat, lit, force_cat)&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	local text_sections, categories = process_compound_type(typ, nocap, notext, #parts &amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
	-- Process each part&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
	local whole_words = 0&lt;br /&gt;
&lt;br /&gt;
	for i, part in ipairs_with_gaps(parts) do&lt;br /&gt;
		part = part or {}&lt;br /&gt;
		local part_lang = part.lang or lang&lt;br /&gt;
		local part_sc = part.sc or sc&lt;br /&gt;
&lt;br /&gt;
		-- Is it an affix, and if so, what type of affix?&lt;br /&gt;
		local affix_type, display_term = get_affix_type(part_lang, part_sc, part.term)&lt;br /&gt;
&lt;br /&gt;
		-- Make a link for the part&lt;br /&gt;
		if display_term == &amp;quot;&amp;quot; then&lt;br /&gt;
			-- If a bare ^ was specified, then insert a blank string. A + will still&lt;br /&gt;
			-- appear next to it. This lets us directly convert things such as&lt;br /&gt;
			-- {{suffix|mul||idae}} to {{affix|mul|^|-idae}}.&lt;br /&gt;
			table.insert(parts_formatted, &amp;quot;&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			table.insert(parts_formatted, export.link_term(part, display_term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if affix_type then&lt;br /&gt;
			-- Make a sort key&lt;br /&gt;
			-- For the first part, use the second part as the sort key&lt;br /&gt;
			local part_sort_base = nil&lt;br /&gt;
			local part_sort = part.sort or sort_key&lt;br /&gt;
&lt;br /&gt;
			if i == 1 and parts[2] and parts[2].term then&lt;br /&gt;
				local part2_lang = parts[2].lang or lang&lt;br /&gt;
				local part2_sc = parts[2].sc or sc&lt;br /&gt;
				local part2_affix_type, part2_display_term = get_affix_type(part2_lang, part2_sc, parts[2].term)&lt;br /&gt;
				part_sort_base = make_entry_name_no_links(part2_lang, part2_display_term)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if affix_type == &amp;quot;infix&amp;quot; then affix_type = &amp;quot;interfix&amp;quot; end&lt;br /&gt;
&lt;br /&gt;
			if part.pos and rfind(part.pos, &amp;quot;patronym&amp;quot;) then&lt;br /&gt;
				table.insert(categories, {cat=&amp;quot;patronymics&amp;quot;, sort_key=part_sort, sort_base=part_sort_base})&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if pos ~= &amp;quot;terms&amp;quot; and part.pos and rfind(part.pos, &amp;quot;diminutive&amp;quot;) then&lt;br /&gt;
				table.insert(categories, {cat=&amp;quot;diminutive &amp;quot; .. pos, sort_key=part_sort, sort_base=part_sort_base})&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			table.insert(categories, {cat=pos .. &amp;quot; &amp;quot; .. affix_type .. &amp;quot;ed with &amp;quot; .. make_entry_name_no_links(part_lang, display_term) .. (part.id and &amp;quot; (&amp;quot; .. part.id .. &amp;quot;)&amp;quot; or &amp;quot;&amp;quot;), sort_key=part_sort, sort_base=part_sort_base})&lt;br /&gt;
		else&lt;br /&gt;
			whole_words = whole_words + 1&lt;br /&gt;
&lt;br /&gt;
			if whole_words == 2 then&lt;br /&gt;
				table.insert(categories, &amp;quot;compound &amp;quot; .. pos)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If there are no categories, then there were no actual affixes, only a single regular term.&lt;br /&gt;
	if #categories == 0 then&lt;br /&gt;
		error(&amp;quot;The parameters did not include any affixes, and the term is not a compound. Please provide at least one affix.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert(text_sections, export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat))&lt;br /&gt;
	return table.concat(text_sections)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_compound(lang, sc, parts, pos, sort_key, typ, nocap, notext, nocat, lit, force_cat)&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	local text_sections, categories = process_compound_type(typ, nocap, notext, #parts &amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
	table.insert(categories, &amp;quot;compound &amp;quot; .. pos)&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local whole_words = 0&lt;br /&gt;
	for i, part in ipairs(parts) do&lt;br /&gt;
		local part_lang = part.lang or lang&lt;br /&gt;
		local part_sc = part.sc or sc&lt;br /&gt;
		local affix_type, display_term = get_affix_type(part_lang, part_sc, part.term)&lt;br /&gt;
&lt;br /&gt;
		-- If the term is an infix, recognize it as such (which means e.g. that we will display the term without hyphens for&lt;br /&gt;
		-- East Asian languages). Otherwise, ignore the fact that it looks like an affix and display as specified in the&lt;br /&gt;
		-- template (but pay attention to the detected affix type for certain tracking purposes)&lt;br /&gt;
		if affix_type == &amp;quot;infix&amp;quot; then&lt;br /&gt;
			table.insert(categories, {cat=pos .. &amp;quot; interfixed with &amp;quot; .. make_entry_name_no_links(part_lang, display_term), sort_key=part.sort or sort_key})&lt;br /&gt;
		else&lt;br /&gt;
			display_term = part.term&lt;br /&gt;
			if affix_type then&lt;br /&gt;
				require(&amp;quot;Module:debug&amp;quot;).track{&lt;br /&gt;
					&amp;quot;compound&amp;quot;,&lt;br /&gt;
					&amp;quot;compound/&amp;quot; .. affix_type,&lt;br /&gt;
					&amp;quot;compound/&amp;quot; .. affix_type .. &amp;quot;/lang/&amp;quot; .. lang:getCode()&lt;br /&gt;
				}&lt;br /&gt;
			else&lt;br /&gt;
				whole_words = whole_words + 1&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(part, display_term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if whole_words == 1 then&lt;br /&gt;
		require(&amp;quot;Module:debug&amp;quot;).track(&amp;quot;compound/one whole word&amp;quot;)&lt;br /&gt;
	elseif whole_words == 0 then&lt;br /&gt;
		require(&amp;quot;Module:debug&amp;quot;).track(&amp;quot;compound/looks like confix&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert(text_sections, export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat))&lt;br /&gt;
	return table.concat(text_sections)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_compound_like(lang, sc, parts, sort_key, text, oftext, cat, nocat, lit, force_cat)&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
	local categories = {}&lt;br /&gt;
&lt;br /&gt;
	if cat then&lt;br /&gt;
		table.insert(categories, cat)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	for i, part in ipairs(parts) do&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(part, part.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local text_sections = {}&lt;br /&gt;
	if text then&lt;br /&gt;
		table.insert(text_sections, text)&lt;br /&gt;
	end&lt;br /&gt;
	if #parts &amp;gt; 0 and oftext then&lt;br /&gt;
		table.insert(text_sections, &amp;quot; &amp;quot;)&lt;br /&gt;
		table.insert(text_sections, oftext)&lt;br /&gt;
		table.insert(text_sections, &amp;quot; &amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	table.insert(text_sections, export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat))&lt;br /&gt;
	return table.concat(text_sections)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Make a given part into an affix of a specific type. For example, if the desired affix type&lt;br /&gt;
-- is &amp;quot;suffix&amp;quot;, this will (in general) add a hyphen onto the beginning of the term, alt, tr and ts&lt;br /&gt;
-- components of the part if not already present. The hyphen that&amp;#039;s added is the &amp;quot;display hyphen&amp;quot;&lt;br /&gt;
-- (see above) and may be language-specific. In the case of East Asian languages, the display&lt;br /&gt;
-- hyphen is an empty string whereas the template hyphen is the regular hyphen, meaning that any&lt;br /&gt;
-- regular hyphen at the beginning of the part will be effectively removed.&lt;br /&gt;
local function make_part_affix(part, lang, sc, affix_type)&lt;br /&gt;
	local part_lang = part.lang or lang&lt;br /&gt;
	local part_sc = part.sc or sc&lt;br /&gt;
&lt;br /&gt;
	part.term = export.make_affix(part.term, part_lang, part_sc, affix_type)&lt;br /&gt;
	part.alt = export.make_affix(part.alt, part_lang, part_sc, affix_type)&lt;br /&gt;
	local Latn = require(&amp;quot;Module:scripts&amp;quot;).getByCode(&amp;quot;Latn&amp;quot;)&lt;br /&gt;
	part.tr = export.make_affix(part.tr, part_lang, Latn, affix_type)&lt;br /&gt;
	part.ts = export.make_affix(part.ts, part_lang, Latn, affix_type)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function track_wrong_affix_type(template, part, lang, sc, expected_affix_type, part_name)&lt;br /&gt;
	if part then&lt;br /&gt;
		local affix_type = get_affix_type(part.lang or lang, part.sc or sc, part.term)&lt;br /&gt;
		if affix_type ~= expected_affix_type then&lt;br /&gt;
			require(&amp;quot;Module:debug&amp;quot;).track{&lt;br /&gt;
				template,&lt;br /&gt;
				template .. &amp;quot;/&amp;quot; .. part_name,&lt;br /&gt;
				template .. &amp;quot;/&amp;quot; .. part_name .. &amp;quot;/&amp;quot; .. (affix_type or &amp;quot;none&amp;quot;),&lt;br /&gt;
				template .. &amp;quot;/&amp;quot; .. part_name .. &amp;quot;/&amp;quot; .. (affix_type or &amp;quot;none&amp;quot;) .. &amp;quot;/lang/&amp;quot; .. lang:getCode()&lt;br /&gt;
			}&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function insert_affix_category(categories, lang, pos, affix_type, part, sort_key, sort_base)&lt;br /&gt;
	if part.term then&lt;br /&gt;
		local part_lang = part.lang or lang&lt;br /&gt;
		local cat = pos .. &amp;quot; &amp;quot; .. affix_type .. &amp;quot;ed with &amp;quot; .. make_entry_name_no_links(part_lang, part.term) .. (part.id and &amp;quot; (&amp;quot; .. part.id .. &amp;quot;)&amp;quot; or &amp;quot;&amp;quot;)&lt;br /&gt;
		if sort_key or sort_base then&lt;br /&gt;
			table.insert(categories, {cat=cat, sort_key=sort_key, sort_base=sort_base})&lt;br /&gt;
		else&lt;br /&gt;
			table.insert(categories, cat)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_circumfix(lang, sc, prefix, base, suffix, pos, sort_key, nocat, lit, force_cat)&lt;br /&gt;
	local categories = {}&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	-- Hyphenate the affixes&lt;br /&gt;
	make_part_affix(prefix, lang, sc, &amp;quot;prefix&amp;quot;)&lt;br /&gt;
	make_part_affix(suffix, lang, sc, &amp;quot;suffix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;circumfix&amp;quot;, prefix, lang, sc, &amp;quot;prefix&amp;quot;, &amp;quot;prefix&amp;quot;)&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;circumfix&amp;quot;, base, lang, sc, nil, &amp;quot;base&amp;quot;)&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;circumfix&amp;quot;, suffix, lang, sc, &amp;quot;suffix&amp;quot;, &amp;quot;suffix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Create circumfix term&lt;br /&gt;
	local circumfix = nil&lt;br /&gt;
&lt;br /&gt;
	if prefix.term and suffix.term then&lt;br /&gt;
		circumfix = prefix.term .. &amp;quot; &amp;quot; .. suffix.term&lt;br /&gt;
		prefix.alt = prefix.alt or prefix.term&lt;br /&gt;
		suffix.alt = suffix.alt or suffix.term&lt;br /&gt;
		prefix.term = circumfix&lt;br /&gt;
		suffix.term = circumfix&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
	local sort_base&lt;br /&gt;
	if base.term then&lt;br /&gt;
		sort_base = make_entry_name_no_links(base.lang or lang, base.term)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(prefix, prefix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(base, base.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(suffix, suffix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
&lt;br /&gt;
	-- Insert the categories&lt;br /&gt;
	table.insert(categories, {cat=pos .. &amp;quot; circumfixed with &amp;quot; .. make_entry_name_no_links(prefix.lang or lang, circumfix), sort_key=sort_key, sort_base=sort_base})&lt;br /&gt;
&lt;br /&gt;
	return export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_confix(lang, sc, prefix, base, suffix, pos, sort_key, nocat, lit, force_cat)&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	-- Hyphenate the affixes&lt;br /&gt;
	make_part_affix(prefix, lang, sc, &amp;quot;prefix&amp;quot;)&lt;br /&gt;
	make_part_affix(suffix, lang, sc, &amp;quot;suffix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;confix&amp;quot;, prefix, lang, sc, &amp;quot;prefix&amp;quot;, &amp;quot;prefix&amp;quot;)&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;confix&amp;quot;, base, lang, sc, nil, &amp;quot;base&amp;quot;)&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;confix&amp;quot;, suffix, lang, sc, &amp;quot;suffix&amp;quot;, &amp;quot;suffix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
	local prefix_sort_base&lt;br /&gt;
	if base and base.term then&lt;br /&gt;
		prefix_sort_base = make_entry_name_no_links(base.lang or lang, base.term)&lt;br /&gt;
	elseif suffix.term then&lt;br /&gt;
		prefix_sort_base = make_entry_name_no_links(suffix.lang or lang, suffix.term)&lt;br /&gt;
	end&lt;br /&gt;
	local categories = {}&lt;br /&gt;
&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(prefix, prefix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	insert_affix_category(categories, lang, pos, &amp;quot;prefix&amp;quot;, prefix, sort_key, prefix_sort_base)&lt;br /&gt;
&lt;br /&gt;
	if base then&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(base, base.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(suffix, suffix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	insert_affix_category(categories, lang, pos, &amp;quot;suffix&amp;quot;, suffix)&lt;br /&gt;
&lt;br /&gt;
	return export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_infix(lang, sc, base, infix, pos, sort_key, nocat, lit, force_cat)&lt;br /&gt;
	local categories = {}&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	-- Hyphenate the affixes&lt;br /&gt;
	make_part_affix(infix, lang, sc, &amp;quot;infix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;infix&amp;quot;, base, lang, sc, nil, &amp;quot;base&amp;quot;)&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;infix&amp;quot;, infix, lang, sc, &amp;quot;infix&amp;quot;, &amp;quot;infix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(base, base.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(infix, infix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
&lt;br /&gt;
	-- Insert the categories&lt;br /&gt;
	insert_affix_category(categories, lang, pos, &amp;quot;infix&amp;quot;, infix)&lt;br /&gt;
&lt;br /&gt;
	return export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_prefixes(lang, sc, prefixes, base, pos, sort_key, nocat, lit, force_cat)&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	-- Hyphenate the affixes&lt;br /&gt;
	for i, prefix in ipairs(prefixes) do&lt;br /&gt;
		make_part_affix(prefix, lang, sc, &amp;quot;prefix&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for i, prefix in ipairs(prefixes) do&lt;br /&gt;
		track_wrong_affix_type(&amp;quot;prefix&amp;quot;, prefix, lang, sc, &amp;quot;prefix&amp;quot;, &amp;quot;prefix&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;prefix&amp;quot;, base, lang, sc, nil, &amp;quot;base&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
	local first_sort_base = nil&lt;br /&gt;
	local categories = {}&lt;br /&gt;
&lt;br /&gt;
	if prefixes[2] then&lt;br /&gt;
		first_sort_base = make_entry_name_no_links(prefixes[2].lang or lang, prefixes[2].term)&lt;br /&gt;
	elseif base then&lt;br /&gt;
		first_sort_base = make_entry_name_no_links(base.lang or lang, base.term)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for i, prefix in ipairs(prefixes) do&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(prefix, prefix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
		insert_affix_category(categories, lang, pos, &amp;quot;prefix&amp;quot;, prefix, sort_key, i == 1 and first_sort_base or nil)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if base then&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(base, base.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	else&lt;br /&gt;
		table.insert(parts_formatted, &amp;quot;&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_suffixes(lang, sc, base, suffixes, pos, sort_key, nocat, lit, force_cat)&lt;br /&gt;
	local categories = {}&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	-- Hyphenate the affixes&lt;br /&gt;
	for i, suffix in ipairs(suffixes) do&lt;br /&gt;
		make_part_affix(suffix, lang, sc, &amp;quot;suffix&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	track_wrong_affix_type(&amp;quot;suffix&amp;quot;, base, lang, sc, nil, &amp;quot;base&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	for i, suffix in ipairs(suffixes) do&lt;br /&gt;
		track_wrong_affix_type(&amp;quot;suffix&amp;quot;, suffix, lang, sc, &amp;quot;suffix&amp;quot;, &amp;quot;suffix&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
&lt;br /&gt;
	if base then&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(base, base.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	else&lt;br /&gt;
		table.insert(parts_formatted, &amp;quot;&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for i, suffix in ipairs(suffixes) do&lt;br /&gt;
		table.insert(parts_formatted, export.link_term(suffix, suffix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Insert the categories&lt;br /&gt;
	for i, suffix in ipairs(suffixes) do&lt;br /&gt;
		if suffix.term then&lt;br /&gt;
			insert_affix_category(categories, lang, pos, &amp;quot;suffix&amp;quot;, suffix)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if suffix.pos and rfind(suffix.pos, &amp;quot;patronym&amp;quot;) then&lt;br /&gt;
			table.insert(categories, &amp;quot;patronymics&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.show_transfix(lang, sc, base, transfix, pos, sort_key, nocat, lit, force_cat)&lt;br /&gt;
	local categories = {}&lt;br /&gt;
	pos = pos or default_pos&lt;br /&gt;
&lt;br /&gt;
	pos = pluralize(pos)&lt;br /&gt;
&lt;br /&gt;
	-- Hyphenate the affixes&lt;br /&gt;
	make_part_affix(transfix, lang, sc, &amp;quot;transfix&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- Make links out of all the parts&lt;br /&gt;
	local parts_formatted = {}&lt;br /&gt;
&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(base, base.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
	table.insert(parts_formatted, export.link_term(transfix, transfix.term, lang, sc, sort_key, force_cat, nocat))&lt;br /&gt;
&lt;br /&gt;
	-- Insert the categories&lt;br /&gt;
	insert_affix_category(categories, lang, pos, &amp;quot;transfix&amp;quot;, transfix)&lt;br /&gt;
&lt;br /&gt;
	return export.concat_parts(lang, parts_formatted, categories, nocat, sort_key, lit, force_cat)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Add a hyphen to a term in the appropriate place, based on the specified affix type. For example, if `affix_type` ==&lt;br /&gt;
-- &amp;quot;prefix&amp;quot;, we&amp;#039;ll add a hyphen onto the end if it&amp;#039;s not already there. In general, if the template and display hyphens&lt;br /&gt;
-- are the same and the appropriate hyphen is already present, we leave it, else we strip off the template hyphen if&lt;br /&gt;
-- present and add the display hyphen.&lt;br /&gt;
function export.make_affix(term, lang, sc, affix_type)&lt;br /&gt;
	if not (affix_type == &amp;quot;prefix&amp;quot; or affix_type == &amp;quot;suffix&amp;quot; or&lt;br /&gt;
		affix_type == &amp;quot;circumfix&amp;quot; or affix_type == &amp;quot;infix&amp;quot; or&lt;br /&gt;
		affix_type == &amp;quot;interfix&amp;quot; or affix_type == &amp;quot;transfix&amp;quot;) then&lt;br /&gt;
		error(&amp;quot;Internal error: Invalid affix type &amp;quot; .. (affix_type or &amp;quot;(nil)&amp;quot;))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not term then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If the term begins with ^, leave it exactly as-is except for removing the ^.&lt;br /&gt;
	if usub(term, 1, 1) == &amp;quot;^&amp;quot; then&lt;br /&gt;
		return usub(term, 2)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if affix_type == &amp;quot;circumfix&amp;quot; or affix_type == &amp;quot;transfix&amp;quot; then&lt;br /&gt;
		return term&lt;br /&gt;
	elseif affix_type == &amp;quot;interfix&amp;quot; then&lt;br /&gt;
		affix_type = &amp;quot;infix&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local scode, thyph, dhyph = get_template_and_display_hyphens(term, lang, sc)&lt;br /&gt;
	thyph = &amp;quot;([&amp;quot; .. thyph .. &amp;quot;])&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- Remove an asterisk if the morpheme is reconstructed and add it in the end.&lt;br /&gt;
	local reconstructed = &amp;quot;&amp;quot;&lt;br /&gt;
	if term:find(&amp;quot;^%*&amp;quot;) then &lt;br /&gt;
		reconstructed = &amp;quot;*&amp;quot;&lt;br /&gt;
		term = term:gsub(&amp;quot;^%*&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local beginning_hyphen = rmatch(term, &amp;quot;^&amp;quot; .. thyph .. &amp;quot;.*$&amp;quot;)&lt;br /&gt;
	local ending_hyphen = rmatch(term, &amp;quot;^.*&amp;quot; .. thyph .. &amp;quot;$&amp;quot;)&lt;br /&gt;
	local beginning_dhyph = dhyph(scode, beginning_hyphen)&lt;br /&gt;
	local ending_dhyph = dhyph(scode, ending_hyphen)&lt;br /&gt;
&lt;br /&gt;
	if affix_type == &amp;quot;suffix&amp;quot; then&lt;br /&gt;
		if beginning_hyphen and beginning_hyphen == beginning_dhyph then&lt;br /&gt;
			-- leave term alone&lt;br /&gt;
		else&lt;br /&gt;
			local term_no_hyphen = beginning_hyphen and usub(term, 2) or term&lt;br /&gt;
			term = beginning_dhyph .. term_no_hyphen&lt;br /&gt;
		end&lt;br /&gt;
	elseif affix_type == &amp;quot;prefix&amp;quot; then&lt;br /&gt;
		if ending_hyphen and ending_hyphen == ending_dhyph then&lt;br /&gt;
			-- leave term alone&lt;br /&gt;
		else&lt;br /&gt;
			local term_no_hyphen = ending_hyphen and rsub(term, &amp;quot;^(.-).$&amp;quot;, &amp;quot;%1&amp;quot;) or term&lt;br /&gt;
			term = term_no_hyphen .. ending_dhyph&lt;br /&gt;
		end&lt;br /&gt;
	elseif affix_type == &amp;quot;infix&amp;quot; then&lt;br /&gt;
		if (beginning_hyphen and ending_hyphen and&lt;br /&gt;
			beginning_hyphen == beginning_dhyph and&lt;br /&gt;
			ending_hyphen == ending_dhyph) then&lt;br /&gt;
			-- leave term alone&lt;br /&gt;
		elseif term == beginning_hyphen or term == ending_hyphen then&lt;br /&gt;
			-- term is a single hyphen; should probably leave alone&lt;br /&gt;
		else&lt;br /&gt;
			local term_no_hyphen = beginning_hyphen and usub(term, 2) or term&lt;br /&gt;
			term_no_hyphen = ending_hyphen and rsub(term_no_hyphen, &amp;quot;^(.-).$&amp;quot;, &amp;quot;%1&amp;quot;) or term_no_hyphen&lt;br /&gt;
			term = beginning_dhyph .. term_no_hyphen .. ending_dhyph&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		error(&amp;quot;Internal error: Bad affix type &amp;quot; .. affix_type)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return reconstructed .. term&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Wiktionary&gt;Benwing2</name></author>
	</entry>
</feed>