◷ Reading Time: 2 minutes
Natural Language commands
An Xml document can represent a Natural Language (NL) document. The following table shows the available commands to model Natural Language using Xml Language.
Natural
Main container of an NL model. This contains all the related elements for Natural Language.
name
- Description: Sets the name for an NL rule
- Mandatory: Yes
- Type: String
Dsl, Declaration, Glossary
<Natural name="Potential theft rating calculation">
<Glossary>
<Term name="Price" expression="car.Price" domain="Numeric" />
<Term name="Car is listed in HTPA" expression="probList.Contains(car.Made+'-'+car.Model)" domain="Boolean" />
<Term name="Theft Rating" expression="car.TheftCategory=$value" domain="Options">
<Option value="High" />
<Option value="Low" />
<Option value="Moderate" />
</Term>
<Term name="Car is Convertible" expression="car.Convertible" domain="Boolean" />
</Glossary>
<Dsl>
given car, probList
when
r1 and
r2 and
r3 and
r4 and
r5
end
when r1
Car is Convertible
then
Theft Rating is High
end
when r2
Car is listed in HTPA and
Price ge 45000
then
Theft Rating is High
end
when r3
Car is listed in HTPA
then
Theft Rating is High
end
when r4
Car is listed in HTPA is false and
Price is [20000;45000]
then
Theft Rating is Low
end
when r5
Car is not listed in HTPA and
Price < 20000
then
Theft Rating is low
end
when Car is not listed in HTPA
Car is listed in HTPA is false
end
</Dsl>
</Natural>
Declaration
This section is a container for the referencing types and defining parameters in all logic (e.g., Procedural, Flow, Validation, etc.).
This command has no parameters.
This command requires Define in its scope.
<Declaration>
<Define name="minAge" value="18i" direction="local" />
</Declaration>
Glossary
A glossary is a dictionary that defines all of the business terms and their domains.
Dsl
The Dsl element contains the actual rule body in the Natural Language format.
This section in an Natural Language document provides the actual rules and logic in Natural Language format as a text body of the element.
This command has no parameters.
Natural Language rules.
<Dsl>
when r5
Car is not listed in HTPA and
Price le 20000
then
Theft Rating is low
end
when Car is not listed in HTPA
Car is listed in HTPA is false
end
</Dsl>