<spanid="evennia-contrib-rplanguage"></span><h1>evennia.contrib.rplanguage<aclass="headerlink"href="#module-evennia.contrib.rplanguage"title="Permalink to this headline">¶</a></h1>
<p>Language and whisper obfuscation system</p>
<p>Evennia contrib - Griatch 2015</p>
<p>This module is intented to be used with an emoting system (such as
contrib/rpsystem.py). It offers the ability to obfuscate spoken words
in the game in various ways:</p>
<ulclass="simple">
<li><dlclass="simple">
<dt>Language: The language functionality defines a pseudo-language map</dt><dd><p>to any number of languages. The string will be obfuscated depending
on a scaling that (most likely) will be input as a weighted average of
the language skill of the speaker and listener.</p>
</dd>
</dl>
</li>
<li><dlclass="simple">
<dt>Whisper: The whisper functionality will gradually “fade out” a</dt><dd><p>whisper along as scale 0-1, where the fading is based on gradually
removing sections of the whisper that is (supposedly) easier to
overhear (for example “s” sounds tend to be audible even when no other
<spanclass="c1"># you need a representative of all of the minimal grammars here, so if a</span>
<spanclass="c1"># grammar v exists, there must be atleast one phoneme available with only</span>
<spanclass="c1"># one vowel in it</span>
<spanclass="n">phonemes</span><spanclass="o">=</span><spanclass="p">(</span><spanclass="s2">"oi oh ee ae aa eh ah ao aw ay er ey ow ia ih iy "</span>
<spanclass="s2">"oy ua uh uw y p b t d f v t dh s z sh zh ch jh k "</span>
<spanclass="s2">"ng g m n l r w"</span><spanclass="p">)</span>
<spanclass="c1"># how much the translation varies in length compared to the original. 0 is</span>
<spanclass="c1"># smallest, higher values give ever bigger randomness (including removing</span>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">LanguageError</code><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#LanguageError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageError"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">LanguageExistsError</code><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#LanguageExistsError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageExistsError"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">LanguageHandler</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#LanguageHandler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_script_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#LanguageHandler.at_script_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.at_script_creation"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">add</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span><spanclass="o">=</span><spanclass="default_value">'default'</span></em>, <emclass="sig-param"><spanclass="n">phonemes</span><spanclass="o">=</span><spanclass="default_value">'ea oh ae aa eh ah ao aw ai er ey ow ia ih iy oy ua uh uw a e i u y p b t d f v t dh s z sh zh ch jh k ng g m n l r w'</span></em>, <emclass="sig-param"><spanclass="n">grammar</span><spanclass="o">=</span><spanclass="default_value">'v cv vc cvv vcc vcv cvcc vccv cvccv cvcvcc cvccvcv vccvccvc cvcvccvv cvcvcvcvv'</span></em>, <emclass="sig-param"><spanclass="n">word_length_variance</span><spanclass="o">=</span><spanclass="default_value">0</span></em>, <emclass="sig-param"><spanclass="n">noun_translate</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="n">noun_prefix</span><spanclass="o">=</span><spanclass="default_value">''</span></em>, <emclass="sig-param"><spanclass="n">noun_postfix</span><spanclass="o">=</span><spanclass="default_value">''</span></em>, <emclass="sig-param"><spanclass="n">vowels</span><spanclass="o">=</span><spanclass="default_value">'eaoiuy'</span></em>, <emclass="sig-param"><spanclass="n">manual_translations</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">auto_translations</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">force</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#LanguageHandler.add"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.add"title="Permalink to this definition">¶</a></dt>
<li><p><strong>noun_prefix</strong> (<em>str</em><em>, </em><em>optional</em>) – A prefix to go before every noun
in this language (if any).</p></li>
<li><p><strong>noun_postfix</strong> (<em>str</em><em>, </em><em>optuonal</em>) – A postfix to go after every noun
in this language (if any, usually best to avoid combining
with <strong>noun_prefix</strong> or language becomes very wordy).</p></li>
<li><p><strong>vowels</strong> (<em>str</em><em>, </em><em>optional</em>) – Every vowel allowed in this language.</p></li>
<li><p><strong>manual_translations</strong> (<em>dict</em><em>, </em><em>optional</em>) – This allows for custom-setting
certain words in the language to mean the same thing. It is
on the form <strong>{real_word: fictional_word}</strong>, for example
<strong>{“the”, “y’e”}</strong> .</p></li>
<li><p><strong>auto_translations</strong> (<em>str</em><em> or </em><em>list</em><em>, </em><em>optional</em>) – These are lists
words that should be auto-translated with a random, but
fixed, translation. If a path to a file, this file should
contain a list of words to produce translations for, one
word per line. If a list, the list’s elements should be
the words to translate. The <strong>manual_translations</strong> will
always override overlapping translations created
automatically.</p></li>
<li><p><strong>force</strong> (<em>bool</em><em>, </em><em>optional</em>) – Unless true, will not allow the addition
of a language that is already created.</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.contrib.rplanguage.LanguageExistsError"title="evennia.contrib.rplanguage.LanguageExistsError"><strong>LanguageExistsError</strong></a>– Raised if trying to adding a language
with a key that already exists, without <strong>force</strong> being set.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>The <strong>word_file</strong> is for example a word-frequency list for
the N most common words in the host language. The
translations will be random, but will be stored
persistently to always be the same. This allows for
building a quick, decently-sounding fictive language that
tend to produce the same “translation” (mostly) with the
<codeclass="sig-name descname">translate</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">text</span></em>, <emclass="sig-param"><spanclass="n">level</span><spanclass="o">=</span><spanclass="default_value">0.0</span></em>, <emclass="sig-param"><spanclass="n">language</span><spanclass="o">=</span><spanclass="default_value">'default'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#LanguageHandler.translate"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.translate"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">DoesNotExist</code><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.DoesNotExist"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">MultipleObjectsReturned</code><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.MultipleObjectsReturned"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.contrib.rplanguage.LanguageHandler'</em><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.path"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">typename</code><emclass="property"> = 'LanguageHandler'</em><aclass="headerlink"href="#evennia.contrib.rplanguage.LanguageHandler.typename"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">obfuscate_language</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">text</span></em>, <emclass="sig-param"><spanclass="n">level</span><spanclass="o">=</span><spanclass="default_value">0.0</span></em>, <emclass="sig-param"><spanclass="n">language</span><spanclass="o">=</span><spanclass="default_value">'default'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#obfuscate_language"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.obfuscate_language"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">add_language</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#add_language"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.add_language"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">available_languages</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#available_languages"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.available_languages"title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all available language keys.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>languages (list)</em>– List of key strings of all available
<codeclass="sig-prename descclassname">evennia.contrib.rplanguage.</code><codeclass="sig-name descname">obfuscate_whisper</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">whisper</span></em>, <emclass="sig-param"><spanclass="n">level</span><spanclass="o">=</span><spanclass="default_value">0.0</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rplanguage.html#obfuscate_whisper"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rplanguage.obfuscate_whisper"title="Permalink to this definition">¶</a></dt>