Query where there is text equivalence

This is probably very simple but I can’t find the solution. I use queries to gather notes around topic areas. The problem I have is that many terms are written differently even though they have the same meaning. A simple example is American and non-American spelling e.g. ‘modelling’, ‘modeling’. I want to write a query that will gather notes that have the text ‘modelling’ OR ‘modeling’. The other common issue is acronyms e.g. ‘systems thinking’, ‘ST’. I want a query that will gather both regardless of whether it is written in full or an acronym is used.

Any ideas.

Thanks

David

The is no built-in dictionary of such terms, but .icontains() and regular expressions. For example to match notes where $MyString contains a value of ‘CAR’, ‘Car’, ‘car’ or ‘cAr’, etc., use the query

$MyString.icontains("car")

Because the match is case-insenitive, it doesn’t matter what lettercase you use for the match string. If you wanted to match a value of exactly those 3 letters, use:

$MyString.lowercase=="car"

This lets us use the simpler == equality test, and we deal with the case-sensitivity issue by testing the value of $MyString converted to all lowercase. The latter transformation is on the fly in the computer, i.e. the source value in $MyString is unaffected.

‘modelling’ OR ‘modeling’? Here we use a regular expression:

$MyString.icontains("mode(l)+ing")

The regex syntax (l)+ means at least one_or_more_consecutiive lowercase ‘L’.

‘systems thinking’, ‘ST’. here you need two terms with an OR join:

$MyString.icontains("systems thinking") | $MyString.contains("ST")

Here, I’ve used .contains() which is case-sensitive as we probably don’t want to match ‘st’ or ‘St’.

Note that if the attribute-type you are using is list-based, i.e. a List or Set (or a string-based list returned from an action operator, the use of regex is not possible in the same way: see here.

Does that help?

1 Like

Thank you Mark. Solved my problem.

David

1 Like