Miscellaneous
Miscellaneous functions do not fit under any of the other categories, but still provide useful mechanisms for creating and processing information.
The examples for each function use the following notation:
- Square brackets (
[]) indicate arrays. - Curly braces (
{}) indicate groups. - Arrows (
==>) separate inputs and outputs. Inputs are shown on the left side of the arrow. Outputs are shown on the right side of the arrow.
Combination Converter
The Combination Converter function takes an array argument, compares each array element to the column header value, and assigns True if there is a header that matches.
If the combination of columns with True assigned exists in the combination table configured by the user, the function returns the converted value.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A string array or integer array.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers |
|
| Output Datatype(s) | The datatype of the Value column of the conversion table. |
Examples
Sample Combination Table:
|--------------------------------------------------|
| apple | orange | pecan | salad | Converted Value |
|--------------------------------------------------|
| TRUE | TRUE | FALSE | FALSE | 0.2 |
| TRUE | FALSE | FALSE | FALSE | 0.1 |
| FALSE | TRUE | TRUE | FALSE | 0.6 |
| TRUE | FALSE | FALSE | TRUE | 0.9 |
| TRUE | TRUE | TRUE | TRUE | 0.4 |
|--------------------------------------------------|
combinationConverter(['apple', 'orange']) ==> 0.2
combinationConverter(['apple','orange','pecan']) ==> null
combinationConverter(['apple','orange',null], ignore_null=True) ==> 0.2
combinationConverter(['apple','orange',null], ignore_null=False) ==> null
combinationConverter({['apple', 'orange'],['salad','apple']}) ==> {0.2,0.9}
combinationConverter({['apple', 'orange'],['salad','apple','pecan']}) ==> {0.2,null}
First Non-Null
The First Non-Null function returns the first non-null value received, evaluated in the order that arguments are supplied.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 2+ |
| Mandatory Argument Names and Datatypes | arg: Any datatype. All input arguments must share the same datatype.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | The output datatype matches the input datatype. |
Examples
firstNonNull(null,null,"input3",null,"input5") ==> "input3"
firstNonNull([null,null,3],null,[1,2,3]) ==> [null,null,3]
firstNonNull({1,null,null},{10,20,null},8) ==> {1,20,8}
Get System Confidence
The Get System Confidence function returns the system-computed confidence for the given solution. (This is the same value as the resulting COG_confidence output field.) If risk computation is not enabled for the template, the functions returns a null value.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 0 |
| Mandatory Argument Names and Datatypes | N/A |
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | Float |
Examples
getSystemConfidence() ==> 0.65
getSystemConfidence() ==> null // when no risk table is configured
Get URL Part
The Get URL Part function returns the part of the specified URL that corresponds to the provided part string.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 2 |
| Mandatory Argument Names and Datatypes | url: A URL containing the part to return.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | part: A string indicating the part of the URL to return. The available options are:
|
| Output Datatype(s) | String |
Examples
getUrlPart("https://www.google.com",part="scheme") ==> "https"
getUrlPart("https://www.google.com",part="query") ==> null
getUrlPart(["https://www.google.com"],part="scheme") ==> "https"
getUrlPart(["https://www.google.com","https://www.amazon.com","https://cogynt.io"],part="scheme") ==> ["https","https","https"]
getUrlPart({"https://www.google.com","https://www.amazon.com","https://cogynt.io"},part="scheme") ==> {"https","https","https"}
getUrlPart({[],[],[]},part="scheme") ==> {[],[],[]}
JSON Builder
The JSON Builder function builds a JSON object from its arguments. The fields of the JSON object, and therefore the function's arguments, are defined by a schema. Use it to create nested JSON structures and to reduce the number of unnecessary fields exposed in the outcome schema of a pattern.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | One for each field defined in the schema. The function has no arguments until a schema is defined. |
| Mandatory Argument Names and Datatypes | One argument for each schema field, named for the field's Name (or its Path, if no name is set) and of the field's Data Type.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | schema: The list of fields that make up the JSON object. Right-click the modifier and select Add Schema (or Update Schema once a schema is defined) to bring up the JSON Builder Schema window. |
| Output Datatype(s) | JSON |
Defining the Schema
The schema determines which fields the JSON object contains, and each schema field adds one argument to the function.
To define the schema of a JSON Builder:
- In the diagramming area, right-click the
schemamodifier of the function and select Add Schema. The JSON Builder Schema window opens. - Click ADD FIELD to add a field to the schema. For each field:
- From the Data Type dropdown menu, select the datatype of the field.
- In the Paths field, enter the path of the field in the JSON object. Use
|as a delimiter to define nested fields. Each path must be unique. - In the Name field, enter the name of the field as it should be displayed in Cogynt applications and on the function's argument.
- Click the arrow beside ADD FIELD to instead add fields from an existing Kafka topic or schema, as when defining the fields of an event type.
- Click Save. An argument for each schema field is added to the function.
- Hover over a field and click X to remove it from the schema.
- The function's arguments are listed in alphabetical order of their field names, or of their paths for fields that have no name.
To change the schema, right-click the schema modifier and select Update Schema. Arguments for fields that remain in the schema keep their connections, provided their paths are unchanged. Changing a field's path replaces its argument, and removing a field from the schema removes its argument along with any connections to it.
To remove a field from the schema directly from the diagram, right-click its argument and select Remove Field.
Examples
Sample Schema:
Path: id Name: ID Data Type: Integer
Path: customer|name Name: Customer Name Data Type: String
Path: customer|city Name: Customer City Data Type: String
Arguments, in alphabetical order of the field names: Customer City, Customer Name, ID
jsonBuilder("London", "Ada", 1001) ==> {"id": 1001, "customer": {"name": "Ada", "city": "London"}}
Lexicon Match
The Lexicon Match function returns an array of matching lexicon entries (words and phrases in the selected lexicon node) if the input expression matches the lexicon. Otherwise, it returns a null value.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A string.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | lexicon node: The specific lexicon node to search. |
| Output Datatype(s) | String array |
Examples
lexicon = {
"node1": ['Abc','Def','Ghi'],
"node2": ['123','456','789']
}
lexMatch("Abc 123 Ghi", lexicon['node1']) ==> ['Abc','Ghi']
lexMatch({"Abc 123 Ghi","123 789 Abc"}, lexicon['node2']) ==> {["123"],["123", "789"]}
Make URL
The Make URL function generates a URL based on the input parameters.
All arguments are required, but all except the host argument can be null. The scheme value defaults to http if not provided. The host value can be an actual host name or a domain name (for example, cogility.com). See the Java URI class documentation for more details.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | host: A string indicating the host.
|
| Optional Argument Names and Datatypes |
|
| Modifiers | N/A |
| Output Datatype(s) | String array |
Examples
makeUrl() ==> "http://"
Random UUID
The Random UUID function returns a unique UUID.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 0 |
| Mandatory Argument Names and Datatypes | N/A |
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | UUID |
Examples
randomUuid() ==> '5ee968d0-6301-4826-9a81-a7062a050215'
Value Converter
The Value Converter function takes the argument and converts it into a value based on a user-defined conversion table.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A string, integer, string array, or integer array.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | Right-click menu that brings up the conversion table. |
| Output Datatype(s) | The datatype of the Value column of the conversion table. |
Examples
Sample Conversion Table:
{
'abc': 0.2,
'123': 0.5,
'doremi': 0.1
}
valueConverter('doremi') ==> 0.1
valueConverter('abc 123') ==> null
valueConverter(null) ==> null
valueConverter(['abc', '123']) ==> [0.2, 0.5]
valueConverter([null, '123']) ==> [null, 0.5]
valueConverter({'abc', '123'}) ==> {0.2, 0.5}
valueConverter({null, '123'}) ==> {null, 0.5}
valueConverter({['abc',null],['doremi','123']}) ==> {[0.2,null],[0.1,0.5]}
valueConverter({null,['abc','123']}) ==> {null,[0.2,0.5]}
Weighted Risk
The Weighted Risk function performs the same computation of risk as when using the risk table in the pattern view (i.e., the complement of the product of complements of weights).
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1+ |
| Mandatory Argument Names and Datatypes | arg: A float or float array.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | ignore null (default: True): If True, the computations set null values to 0, and a valid computation occurs. If False, the resulting value will be null instead. |
| Output Datatype(s) | Float |
If the first input argument is an array, the number of arguments should only be 1.
The function's output will always have a positive value between 0 and 1.
Examples
weightedRisk(0.2,0.5,0.1) ==> 0.64
weightedRisk(0.2,0.5,null, ignore_null=False) ==> null
weightedRisk(0.2,0.5,null, ignore_null=True) ==> 0.6
weightedRisk([0.2, 0.5, 0.1]) ==> 0.64
weightedRisk([0.2, 0.5, null], ignore_null=False) ==> null
weightedRisk([0.2, 0.5, null], ignore_null=True) ==> 0.6
weightedRisk({0,2,0.5,0.1},{0.5,0.2,0.5},{0.1,0.1,0.2}) ==> {0.64,0.64,0.64}
weightedRisk({[0,2,0.5,0.1],[0,2,0.5,0.1],[0,2,0.5,0.1]}) ==> {0.64,0.64,0.64}
When
The When function evaluates a defined expression based on the truth or falsity of the submitted argument. When the argument is nonzero or True, when returns the if true option. Otherwise, it returns the if false option.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 2 |
| Mandatory Argument Names and Datatypes |
|
| Optional Argument Names and Datatypes |
|
| Modifiers | N/A |
| Output Datatype(s) | Shares the same datatype as the input value for if true and/or if false. |
At least one of the two optional arguments must be non-null.
Examples
when(True,if_true="ABC",if_false="123") ==> "ABC"
when(True,if_true="ABC") ==> "ABC"
when(False,if_true="ABC") ==> null
when(True,if_false="123") ==> null
when([True,False,True],1,2) ==> [1,2,1]
when([True,False,True],if_true=["A","B","C"],if_false=["D","E","F"]) ==> ["A","E","C"]
when({True,False,True},{"A","B","C"},{"D","E","F"}) ==> {"A","E","C"}
when({[True,False,True],[False,True],[False,False,True]},if_true=[1,2,3],if_false=["A","B","C"]) ==> TBD