ifmatch

Purpose

Returns the first argument if the condition is true, otherwise returns the second argument.

Syntax

ifmatch(condition, argument_1, argument_2)

The function is used only inside PDL functions phrase(), follow(), near(), fnear(), sentence().

Arguments

The function accepts three mandatory arguments.

  1. The first argument is a condition to evaluate, which results in a true or false value.

  2. The second argument is the value to return if the condition is true.

  3. The third argument is the value to return if the condition is false.

Returned value

Documents matching the query.

Examples

ifmatch(vehicle, town, street) returns the word "Wall Street" in the sentence "Some on Wall Street are optimistic about Lucid’s potential to challenge Tesla" or the function returns "small town" in the sentence "In Marines, a small town with a cobbled central square, residents cherish the environment as well as their vehicles".

sentence(ifmatch(length(1, 20, document(), count:=token), preposition(), adverb())) returns prepositions in sentences of less than 20 tokens, otherwise the function returns adverbs.