<!--Weave of 'How To Include This Module' generated by Inweb-->
<divclass="breadcrumbs">
<ulclass="crumbs"><li><ahref="../index.html">Home</a></li><li><ahref="../compiler.html">Services</a></li><li><ahref="index.html">lexicon</a></li><li><ahref="index.html#P">Preliminaries</a></li><li><b>How To Include This Module</b></li></ul></div>
<pclass="purpose">What to do to make use of the lexicon module in a new command-line tool.</p>
<ulclass="toc"><li><ahref="P-htitm.html#SP1">§1. Status</a></li><li><ahref="P-htitm.html#SP2">§2. Importing the module</a></li><li><ahref="P-htitm.html#SP3">§3. Defining parsing methods</a></li><li><ahref="P-htitm.html#SP4">§4. Using callbacks</a></li></ul><hrclass="tocbar">
<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. Status. </b>The lexicon module is provided as one of the "services" suite of modules,
<pclass="commentary">By convention, the modules considered as "services" have no dependencies on
other modules except for <ahref="../../../inweb/docs/foundation-module/index.html"class="internal">foundation</a> and other "services" modules.
</p>
<pclass="commentary">A tool can import <ahref="index.html"class="internal">lexicon</a> only if it also imports <ahref="../../../inweb/docs/foundation-module/index.html"class="internal">foundation</a>,
<ahref="../words-module/index.html"class="internal">words</a>, <ahref="../syntax-module/index.html"class="internal">syntax</a> and <ahref="../inflections-module/index.html"class="internal">inflections</a>.
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. Importing the module. </b>We'll use the term "parent" to mean the tool which is importing <ahref="index.html"class="internal">lexicon</a>,
<ulclass="items"><li>● The parent must call <spanclass="extract"><spanclass="extract-syntax">LexiconModule::start()</span></span> just after it starts up, and
<spanclass="extract"><spanclass="extract-syntax">LexiconModule::end()</span></span> just before it shuts down. (But just after, and just
before, the corresponding calls to <ahref="../../../inweb/docs/foundation-module/index.html"class="internal">foundation</a>.)
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. Defining parsing methods. </b>When lexicon entries are registered (see <ahref="1-lxc.html"class="internal">Lexicon (in lexicon)</a>), they are
assigned "meaning codes", and these affect the way that parsing is done.
The user should define <spanclass="extract"><spanclass="extract-syntax">EXACT_PARSING_BITMAP</span></span>, <spanclass="extract"><spanclass="extract-syntax">SUBSET_PARSING_BITMAP</span></span>
and <spanclass="extract"><spanclass="extract-syntax">PARAMETRISED_PARSING_BITMAP</span></span> to be sums of the meaning codes for
which these methods are used — see <ahref="2-pe.html"class="internal">Parse Excerpts</a>.
</p>
<pclass="commentary">For example, the parent could define <spanclass="extract"><spanclass="extract-syntax">INGREDIENTS_MC</span></span> and <spanclass="extract"><spanclass="extract-syntax">RECIPES_MC</span></span> to
have two different namespaces, and then define <spanclass="extract"><spanclass="extract-syntax">EXACT_PARSING_BITMAP</span></span> to
be <spanclass="extract"><spanclass="extract-syntax">INGREDIENTS_MC + RECIPES_MC</span></span> to make both of them parsed exactly.
</p>
<pclass="commentary">Mimimal default settings are made if the parent doesn't create these
<pclass="commentary firstcommentary"><aid="SP4"class="paragraph-anchor"></a><b>§4. Using callbacks. </b>Shared modules like this one are tweaked in behaviour by defining "callback
and <spanclass="extract"><spanclass="extract-syntax">EM_IGNORE_DEFINITE_ARTICLE_TEST_LEXICON_CALLBACK</span></span> can all make excerpts
parse in slightly different ways. <ahref="../core-module/index.html"class="internal">core</a> sets all of these to return <spanclass="extract"><spanclass="extract-syntax">TRUE</span></span>
for say phrases, and <spanclass="extract"><spanclass="extract-syntax">FALSE</span></span> for everything else. See <ahref="1-lxc.html#SP3"class="internal">Lexicon::retrieve</a>
and <ahref="1-lxc.html#SP1"class="internal">Lexicon::register</a>.
</li><li>●<spanclass="extract"><spanclass="extract-syntax">PARSE_EXACTLY_LEXICON_CALLBACK</span></span> is called when an excerpt is about to be
parsed in "subset mode" — allowing just a subset of its words to be used,
i.e., not requiring exact wording. This function can refuse to allow that in
certain cases. See <ahref="1-lxc.html#SP3"class="internal">Lexicon::retrieve</a>.
</li><li>●<spanclass="extract"><spanclass="extract-syntax">PROBLEM_LEXICON_CALLBACK</span></span> is called when an error is found, and can
prevent this from being issued to the terminal as an error message: see