todictword

Purpose

Converts the argument to the specified dictionary field.

Syntax

todictword(dict_type, $argument, dictionary:=dictionary_name, MatchColumn:=column_name, field:=field_name)

or

todictword(dict_type, dictionary:=dictionary_name, ColumnName:=$argument, field:=field_name)

Notes

The function accepts two syntax variants.

  • In the first case, the expression to search for is specified as the required argument $argument, and the dictionary columns to compare with this argument, are specified in the parameter Matchcolumn.

In this mode, you can search in several dictionary columns. In this case, they must be specified through a vertical bar: MatchColumn:=Derivative|Name.

For example, if one wants to output the Region field from a standard Geoadministrative dictionary by comparing the value of the $variable argument with the Derivative column of the same dictionary, one should write the following query:

todictword(GeoAdministrative, $variable, dictionary:=Default, MatchColumn:=Derivative, field:=Region)

  • The second option is a simplified, more compact syntax. In this case, one need to assign to the column the value of the $argument (e.g.: Derivative:=$x). In this mode, you can search only in one dictionary column.

Then the query from the first example will look like this:

todictword(GeoAdministrative, dictionary:=Default, Derivative:=$variable, field:=Region)

If dictionary name is not specified, the function uses all switched dictionaries of the same category. One can also specify several dictionaries using the vertical bar: dictionary:=X|Y.

Arguments

The function takes several required arguments.

Argument

Comment

dict_type

Sets dictionary type.

$argument

A named variable to be converted to a dictionary field.

MatchColumn

The column against which the named variable $argument is compared to determine a match.

field

Resulting field.

The function also takes the following optional named arguments:

Argument

Comment

dictionary

Sets dictionary name.

mode:=all/none/first

In case of several matching entries in the dictionary, the parameter allows to choose between them. By default, mode:=first).

Returned value

String value.

Examples

Dataset

XPDL-rule

Result

the city of Elazig

rule: r1

{

query: {phrase(city, of, {lemma(noun)}:variable)}:m

result: Match = $m

attribute:Country = todictword(GeoAdministrative, dict_name:=Default, Name:=$variable, field:=Country)

}

Turkey

The function can also convert the variable that has other formatting functions applied to it, for example, form or case normalization:

Dataset

XPDL-rule

Result

the city of Elazig

rule: r2

{

query: {phrase(city, of, {lemma(noun)}:variable)}:m

result: Match = $m

attribute: City = todictword(GeoAdministrative, dict_name:=Default, Name:=tolower(norm($variable)), field:=City)

}

elazig