Boolean Extract

Extracts a boolean value from an input text.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

The Boolean Extract command analyzes the input text to look for words that might be categorized as affirmative or negative words. This command uses these words to extract and return the true value for affirmative words, and false for negative words.

The following list shows sample sentences that the Boolean Extract command recognizes:

  • It's true
  • Ok, I can
  • That's fine for me
  • It's false
  • I'm not sure about that

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

extractBoolean --culture(Culture) --text(String) (Boolean)=value

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Language culture Required Text, Culture The language that is used to analyze the input text.

If you define the language manually, make sure to enter only supported language codes.

See the culture parameter options for supported languages.
Text text Required Text The input text.

culture parameter options

The following table displays the options available for the culture input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
en-US en-US English
pt-BR pt-BR Portuguese (Brazil)
pt-PT pt-PT Portuguese (Portugal)

Output parameter

Designer mode label Script mode name Accepted variable types Description
Boolean value Boolean Returns True if it recognizes an affirmative word in the input text, or False if it recognizes a negative word. It retrieves the first occurrence of an affirmative or negative word to return the value.
It returns False if it can't recognizes an affirmative or negative word in the input text.

Example

Example 1: The following code example demonstrates how to use the Boolean Extract command to analyze a list of affirmative and negative sentences and extract the boolean value that corresponds to it.

defVar --name result --type Boolean
defVar --name listOfSentences --type List --innertype String
defVar --name sentence --type String
// Assigns affirmative and negative sentences to the "${listOfWords}" variable.
setVar --name "${listOfSentences}" --value "[It\'s true, That\'s fine for me, It\'s false, I\'m not sure about that]"
// Checks each sentence on the list of sentences to extract a boolean value from it.
foreach --collection "${listOfSentences}" --variable "${sentence}"
	// Extracts a boolean result from the input text.
	extractBoolean --culture "en-US" --text "${sentence}" result=value
	// Logs the extracted value.
	logMessage --message "The sentence \"${sentence}\" is ${result}." --type "Info"
endFor
// You can get the following outputs:
//
// The sentence "It's true" is True.
// The sentence "That's fine for me" is True.
// The sentence "It's false" is False.
// The sentence "I'm not sure about that" is False.

Example 2: The following code example demonstrates how to use the Boolean Extract command to analyze the input text. It looks for words that make it an affirmative sentence or not, and as result it returns True after it finds the first occurrence of an affirmative word, like "no problem".

defVar --name booleanAnalysis --type Boolean
defVar --name sentence --type String
// Assigns a sentence which contains affirmative words to the "${sentence}" variable.
setVar --name "${sentence}" --value "There\'s no problem to use natural language processing on digital workers to analyze the text that comes in with invoices, for example. RPA technology drives down operational costs by automating the transaction-heavy, manually intensive tasks that require reconciliation."
// Extracts a boolean value as result of the analysis of the input text.
extractBoolean --culture "en-US" --text "${sentence}" booleanAnalysis=value
// Logs the extracted value.
logMessage --message "Result of the analysis: ${booleanAnalysis}" --type "Info"
// You can get the following output:
//
// Result of the analysis: True

Limitations

This command does not support Watson NLP provider.