Substitution variables
- Last Updated: May 13, 2026
- 4 minute read
- Semaphore
- Documentation
As the template is written to describe the classification strategy for a number of concepts, when the rules are generated we need to be able to insert the correct value (preferred label, GUID, etc.) into the generated rule. In order to do this there are a number of special variables that will be replaced with the information for the specific rulebase being generated.
These variables are usually seen in:
- Category rules - to make sure the correct information is being returned as the response from Classification Server
- links/labels - to ensure that unique links and labels are used across the many rules that are being generated.
Substitution variables are used so that the template can apply to many concepts but the correct information is used to ensure the correct information is returned from Classification Server and links/labels used to re-use sections of rules are unique across the rulebase set.
Values - Current Concept Context
This set of variables uses the context of the current concept to set the actual values in the generated rulebase. These are the variables used for the Link attribute and category rules.
| Value | Description |
|---|---|
| ${rulebaseClass} | rulebase class name - as defined by the Publisher default behavior, or explicitly in the publisher configuration file property rulebaseClassName |
| ${resource.label} | Preferred label for the concept the rulebase is being generated for |
| ${resource.guid} | GUID for the concept the rulebase is being generated for |
| ${language.iso_code} | Language code for the concept the rulebase is being generated for |
To maintain backwards compatibility with templates in versions of Semaphore older than 4.x, the following values will still be processed by Publisher when creating the rulebase:
| Value | Description |
|---|---|
| ${className} | rulebase class name - as defined by the Publisher default behavior, or explicitly in the publisher configuration file property rulebaseClassName |
| ${term.name} | Preferred label for the concept the rulebase is being generated for |
| ${term.id} | GUID for the concept the rulebase is being generated for |
| ${term.zthesId} | GUID for the concept the rulebase is being generated for |
| ${rulebaseSetConfig.language.iso_code} | Language code for the concept the rulebase is being generated for |
| ${rulebaseSetConfig.language.name} | Language code for the concept the rulebase is being generated for |
Values - Related Concept Context
When link labels to other rulebases, there is a different syntax. This is because we now want all the information from the related concept, not the current concept. This set of variables uses the context of the related concept to set the actual values in the generated rulebase. These are the variables used for the Label attribute in the Link List and Descendants template rules.
| Value | Description |
|---|---|
| RULEBASE_CLASS | rulebase class name - as defined in the publisher configuration file property rulebaseClassName. Note: when linking to rulebases generated by a separate publishing process, e.g. rulebases generated from a publishing process of another model, then you will need to hardcode the rulebase class rather than use the RULEBASE_CLASS variable. |
| WORD_FIELD | Preferred label name for the concept the rulebase is being generated for |
| ID_FIELD | GUID for the concept the rulebase is being generated for |
| LANGUAGE | Language code for the concept the rulebase is being generated for |
| ZTHES* | GUID for the concept the rulebase is being generated for |
(*) This value is still valid in order to maintain backwards compatibility with templates in versions of Semaphore older than 4.x
Example 1 - Category rules
For a model that contains preferred labels ‘Drug Enforcement Agency’ with a GUID ‘136793252386776059236437’, and ‘Organized Crime’ with a GUID ‘21812048135347993391369’ and has a Rulebase Class defined as ‘Topic’
Using the following template rule:
<category class="${className}" name="${term.name}" id="${term.zthesId}">
<phraselist field="body" case="0" stem="1" weight="40" skip="0" foreach="1" termtypes="PT|NPT" wordtypes="MULTIWORD"/>
</category>
For the rulebase output for the preferred label ‘Drug Enforcement Agency’, it would generate:
<category class="Topic" name="Drug Enforcement Agency" id="136793252386776059236437">
<phrase data="Drug Enforcement Agency" field="body" case="0" stem="1" weight="40" skip="0" foreach="1"/>
</category>
For the rulebase output for the preferred label ‘Organized Crime’, it would generate:
<category class="Topic" name="Organized Crime" id="21812048135347993391369">
<phrase data="Organized Crime" field="body" case="0" stem="1" weight="40" skip="0" foreach="1"/>
</category>
Example 2 - Link labels
For a model that contains two english preferred labels with a Rulebase Class defined as ‘Topic’:
- ‘Drug Enforcement Agency’ with a GUID ‘136793252386776059236437’
- ‘Organized Crime’ with a GUID ‘21812048135347993391369’
Using the following template rule:
<combine label="link.${className}.${term.name}.${rulebaseSetConfig.language.iso_code}.${term.id}_TERMS" weight="100">
<phraselist field="body" case="0" stem="1" weight="40" skip="0" foreach="1" termtypes="PT|NPT" wordtypes="MULTIWORD"/>
</combine>
For the rulebase output for the preferred label‘Drug Enforcement Agency’, it would generate:
<combine label="link.Topic.Drug Enforcement Agency.eng.136793252386776059236437_TERMS" weight="100">
<phrase data="Drug Enforcement Agency" field="body" case="0" stem="1" weight="40" skip="0" foreach="1"/>
</combine>
For the rulebase output for the preferred label ‘Organized Crime’, it would generate:
<combine label="link.Topic.Organized Crime.eng.21812048135347993391369_FINAL" weight="100">
<phrase data="Organized Crime" field="body" case="0" stem="1" weight="40" skip="0" foreach="1"/>
</combine>
Example 3 - linklist rule labels
If we wanted to incorporate evidence in the concept ‘Drug Trafficking’ rulebase using associative relationships to ‘Drug Enforcement Agency’ and ‘Organized Crime’, we could re-use the labels defined in the previous example.
The following template rule:
<linklist label="link.RULEBASE_CLASS.WORD_FIELD.LANGUAGE.ID_FIELD_TERMS" weight="25" relationshiptypes="Associative"/>
would generate the output:
<link label="link.Topic.Drug Enforcement Agency.eng.2_TERMS"/>
<link label="link.Topic.Organized Crime.eng.3_TERMS"/>