ErgoText is a feature of Ergo that enables one to do knowledge entry using controlled English-like sentences.
This facility is designed for knowledge engineers that are experts in various target domains of knowledge (e.g., legalese) but are not very skilled in Ergo.
Please note that in the current beta version of ergotext, an error warning will appear in the Studio editor next to each template statement in the *.ergotxt file. This is a known issue and will not affect the performance of the knowledge base or template file. It is safe to ignore this error message.
ErgoText documents have two parts: the actual knowledge base (say, mykb.ergo
), which contains the actual knowledge base, and the template file (say, mykb.ergotxt
or mykb_templ.ergotxt
), which contains ErgoText templates, which tell the system how to map English into logical Ergo sentences. The knowledgebase file, mykb.ergo
, declares the use of a template with the directive
:- ergotext{mykb_templ}.
(or ergotext{mykb}
-- whichever is the case).
The .ergotxt
file would normally be created by an Ergo expert in collaboration with a domain expert.
An important feature of ErgoText is that controlled English can be freely mixed with the regular Ergo syntax provided that certain simple rules are obeyed. The other benefit of ErgoText is that it is integrated with ErgoAI Studio's answer explanation mechanism so that whenever an explanation matches an existing ErgoText template, and English sentence would be shown instead of the, perhaps more cryptic for a non-expert, Ergo sentence. An example of ErgoText-enhanced explanation window is shown below:
The purpose of this tutorial to just give a flavor of what ErgoText does. To use this feature productively, one must consult section "ErgoText" of the ErgoAI Reasoner User's Manual.
The following is part of an Ergo representation of the so called Regulation W, set forth in Section 23 of the Federal Reserve Code. The full code of this example appears in the ErgoAI Example Bank.
It concerns activities between a bank and its affiliate that could expose the bank to the risks of its affiliates including loans, investments,
purchases, and other transactions. One ErgoText rule (say, in file regw.ergo
) that represents part of this regulation, looks like this:
:- ergotext{regWtempl}.
... ... ...
... ... ...
@!{rule105a1}
\(RegW prohibits the proposed transaction ?Id by ?Bank with ?Affiliate of $?Amount million\) :-
\(The proposed transaction ?Id by ?Bank with ?Affiliate of $?Amount million is a RegW covered transaction\),
\(RegW imposes a limit of $?Limit million for any covered proposed transaction by bank ?Bank with affiliate ?Affiliate\),
\(The proposed transaction of $?Amount million is greater than the RegW limit of $?Limit million\).
The templatized natural language sentences that are used here are enclosed inside the \(...\)
delimiters and may contain variables like ?Bank, ?Affiliate
, but otherwise they look like normal English sentences. Punctuation signs and other common textual wherewithals are also accepted. The templates that define the mapping from English to Ergo should appear in the file regWtempl.ergotxt
(according to the above ergotext
declaration), and they would look like this:
template(headbody,
\(RegW prohibits the proposed transaction between ?Bank and ?Company for amount $?Amount million\),
prohibited(by(RegW))(proposed(transaction)(by(?Bank))(with(?Company))(of(amount(?Amount)))(having(id(?_Id))))
).
template(headbody,
\(The proposed transaction ?Id by ?Bank with ?Affiliate of $?Amount million is a RegW covered transaction\),
covered(proposed(transaction))(by(?Bank))(with(?Affiliate))(of(amount(?Amount)))(having(id(?Id)))
).
template(headbody,
\(RegW imposes a limit of $?Limit million for any covered proposed transaction by bank ?Bank with affiliate ?Affiliate\),
limit(from(RegW))(of(amount(?Limit)))(for(any(covered(proposed(transaction))))(by(?Bank))(with(?Affiliate)))
).
template(headbody,
\(The proposed transaction of $?Amount million is greater than the RegW limit of $?Limit million\),
amount(of(proposed(transaction)))(greater(than(the(limit))))(?Amount,?Limit)
).
The headbody
argument in each of the above templates tells where the corresponding English template is allowed to appear -- both in the rule heads and in their bodies in this case. The green parts above are the ErgoText English templates that are intended to appear in the regw.ergo
knowledge base, as we have seen. The light brown parts are the Ergo formulas into which the English templates are translated.
The reader is referred to the ErgoAI Reasoner User's Manual for further details.