Attributes from external files
Attribute's values may be replaced by a particular type of file called external list, which contains the same values but is loaded by the rule itself, resulting in the same behavior of a normal list.
The syntax is:
attribute(LOAD "file1"[, LOAD "file2", ...])
Or:
attribute(EXPAND "file1"[, EXPAND "file2", ...])
where:
attribute
cannot beRELEVANT
, because it already refers to lists: those are produced by the disambiguator.
LOAD
andEXPAND
are language keywords and must be written in uppercase.file#
refers to the complete name of the external file including the extension.
Files must be plain text files with .cl
extension and the values they contain must comply with the standards described for each attribute.
Below are syntax guidelines for listing values in external files:
- Each value should stand alone in a line.
- Commas are not to be used to separate values from one another.
- Quotation marks and spaces at the end of each value are not allowed.
- Blank lines are also not allowed.
- Comments can be used, but they must be removed before deploying the project.
- All list files must use the UTF-8 encoding.
The table below gives some examples of the difference between inline lists and an external list.
Attribute | Inline list | External list |
---|---|---|
TAG |
TAG_1, TAG_2, TAG_3 |
TAG_1 |
KEYWORD |
"rag", "duster", "filth" |
rag |
LEMMA |
"dog", "kangaroo", "slipper" |
dog |
SYNCON |
17200, 37560, 12985, 15380 |
17200 |
ANCESTOR |
34567:2, 897, 72914:2:superverbum/subverbum |
34567:2 |
TYPE |
PRO, NPH:F, NOU:S, VER:simple_past |
PRO |
PATTERN |
"a.+", "[0-1]+" |
a.+ |
LIST |
34567:2, 897, 72914:2:superverbum/subverbum |
34567:2 |
ROLE |
SUBJECT, OBJECT |
SUBJECT |
POSITION |
BEGIN SENTENCE, END PARAGRAPH |
BEGIN SENTENCE |
If you load lists with the KEYWORD
attribute, strings can have case sensitive or insensitive matches based on their case. Check the dedicated page for more information.
The use of LOAD
or EXPAND
is interchangeable in external lists.
The use of external lists is particularly useful when an attribute containing a list of multiple values must be used several times for different rules. In essence, transferring the list of values to an external file is convenient, because the list will only need to be defined just once, even if it is used in several rules. If the external list is modified, the changes will be automatically valid for all rules containing the same external list. In other words, there is no need to repeat the same modification for every instance of the list as is the case when using standard syntax.
For example:
SYNCON(LOAD "european_union_countries.cl")
The external list european_union_countries.cl which contains the syncon IDs for all member countries of the European Union, corresponds with the following statement, that uses the standard syntax for the SYNCON
Attribute:
SYNCON(12768485,12788565,10728626,10144226,13063047,12610771,10449831,10655933,13003269,12907079,10387796,10715658,12949572,13160565,10454354,10593395,12946294,12550744,12737184,10794206,12253132,10794211,13043341,13175669,12498789,12649090,12622858)
External lists can also be used if the text file is placed in a sub-folder. In this case the LOAD
/EXPAND
syntax notation is as follows:
SYNCON(LOAD "subfolder_name/.../european_union_countries.cl")
the slash symbol (/
) is preferred to the backslash (\
) because it is compatible with both Linux and Windows environments. However both notations are accepted if working in Windows.