Simple conditional values
A simple condition is expressed by the typical pattern operand followed by an equal sign and a value.
Alphabetic values must be in quotation marks. A condition to test for the presence of a token with value MAPLE followed by a street type is:
*? = "MAPLE" | T
The *? = "MAPLE"
is a token with a condition and is also an operand.
If the word SOUTH is in the classifications, you can test explicitly for SOUTH by using D = "SOUTH" or for any direction with the standard abbreviation S by using D = "S" for the operand.
You enter numeric values without quotes. The following pattern-action set matches to 1000 MAIN but not to 1001 MAIN.
* ^ = 1000 | ?
The equality operator (=) tests both the standardized abbreviation (if the token is found in the .cls file and has an abbreviation) and the original token value for equality to the operand. Two additional operators are available for testing equality to the abbreviation only or the original token value only. The operators are as follows:
Operator | Value |
---|---|
=A= | Only tests the abbreviation from the .cls file. |
=T= | Only tests the original token value only. |
For example, to properly handle AVE MARIA LANE, test for equality with the original token value:
*T =T= "AVE" | + | T
RETYPE [1] ?
As an operand, *T =T= "AVE"
ensures that AVE is coded and not another
value that maps to the same abbreviation leaving input of AVENUE MARIA unchanged.
Similarly, use =A= if you only want a test on the abbreviation.
Series of conditional values
The following examples are equivalent and mean a street type whose value or standardized
abbreviation is either RD
or AV
or PL
:
T = "RD", "AV", "PL"
T = "RD" "AV" "PL"
Numeric series can be represented in the same manner, except without quotation marks. Optionally, you can use the abbreviation equality operator =A= or the original value operator =T=, such as:
T =A= "RD", "AV", "PL"
T =T= "RD", "AV", "PL"
A series of values can be tested against a dictionary field in a similar fashion:
^ | T | [ {StreetName} = "MAIN", "ELM", "COLLEGE" ]
The following pattern tests country code (specified as CC
) to
determine the processing to be used:
; Armenia, Azerbaijan, China, Georgia, Russia, Tajikstan
;
[ {CC}="ARM" ,"AZE" ,"CHN" ,"GEO" ,"RUS" ,"TJK" ]
CALL Area_Format_B
In the case where you are testing the dictionary field value instead of a normal pattern operand, the test must follow all pattern operands including end-of-field.
^ | ? | T | $ | [ {StreetName} = "MAIN", "ELM", "COLLEGE" ]
The test [ {StreetName} = "MAIN", "ELM", "COLLEGE" ]
follows all pattern
operands, including the end of field specifier ($).
Tables of conditional values
You can use a table of values files when you have many values that would be difficult to include in a conditional statement, or when you prefer to update values in a table rather than modifying the pattern-action file.
Tables can be specified as follows:
@TABLE_FILE_NAME.TBL
For example, you want to test a number to see if it is one of a series of postal codes. First, edit the pattern-action file to reference the file that list postal codes. A placeholder is created for the file in the InfoSphere® DataStage® and QualityStage® Designer. Next you edit the file that list postal codes. Ensure that you have one line for each postal code. As an illustration, this file is named POSTCODE.TBL and looks as follows:
90016
90034
90072
90043
...
A pattern matching city, state, and postal code might look like:
? | S | ^ = @POSTCODE.TBL
This pattern is intended to match to cases with city name, state, and post code. If the numeric operand is in the list, the pattern matches; otherwise it does not. LOS ANGELES CA 90016 matches, but CHICAGO IL 12345 does not because the postal code is not in the table.
The table file name can contain complete or relative path information, including an environment variable. If a rule set has a path specified on a command line, that path is assumed for value files used in that Pattern-Action file for the rule set and the path cannot be specified a second time.
The dictionary field contents can also be tested against tables of values:
^ | T | {StreetName} = @STRTNAME.TBL
If the dictionary field contents are not pattern operands, the test against a table of values must follow all pattern operands, including an end-of-field operand. The following example is not valid, since a pattern operand follows the table test:
^ | {StreetName} = @STRTNAME.TBL | T
Combining conditional expressions
Operator | Value |
---|---|
& |
AND |
| |
OR |
To test for even-numbered houses greater than 1000:
^ [{} % 2 = 0 & {} > 1000]
To test for houses in the range of 1000 to 10000:
^ [{} >= 1000 & {} <= 10000]
To test for houses less than 100 or greater than 1000:
^[{} < 100 | {} > 1000]
To test for even-numbered houses, and for half of the value in temp to be greater than 50, and with a postal code greater than 12345:
^ [{} % 2 = 0 & temp / 2 > 50 & {ZipCode} > 12345]
Parentheses are not permitted. All operations are executed left to right. Within a single bracket-delimited condition, AND and OR operators cannot be mixed. An error message is printed if such a case is encountered. Operator precedence can be obtained by using separate pattern operands if possible. The arithmetic expression ((a | b) & (c | d)) can be represented by:
[a | b] | [c | d]
The vertical lines (|) within the brackets are logical OR operations, and vertical lines outside
the brackets are operand separators. In the previous example, a
,
b
, c
, and d
represent conditional
expressions.