Extract Monetary Value
Extracts monetary values from text using natural language processing (NLP).
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
This command extracts monetary values from text using natural language processing.
The results that this command returns might vary according to the selected NLP provider. For more information, see Setting an NLP provider.
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.
extractCurrency --culture(Culture) [--numberascurrency(Boolean)] [--minimumvalue(Numeric)] --text(String) (List<Money>)=values (Money)=first (DataTable)=valuesmapping (Boolean)=success
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 |
Language used to extract the currency from. If you define the language manually, make sure to enter only supported language codes. See the culture parameter options for supported
languages.Remember:The decimal notation might change according to the defined language.
|
Number as currency | numberascurrency |
Optional |
Boolean |
Enable to search for numeric values if no explicit currency values are found. |
Minimum value | minimumvalue |
Optional |
Number |
Minimum value to extract from the text. |
Text | text |
Required |
Text |
Text that contains monetary values to extract from. |
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 | Supported provider |
---|---|---|---|
ar |
ar |
Arabic | Watson NLP |
zh-CN |
zh-CN |
Chinese (Simplified) | Watson NLP |
zh-TW |
zh-TW |
Chinese (Traditional) | Watson NLP |
cs |
cs |
Czech | Watson NLP |
da |
da |
Danish | Watson NLP |
nl |
nl |
Dutch | Watson NLP |
de-DE |
de-DE |
German | Watson NLP |
en-US |
en-US |
English | Legacy and Watson NLP |
fi |
fi |
Finnish | Watson NLP |
fr-FR |
fr-FR |
French (France) | Watson NLP |
fr-CA |
fr-CA |
French (Canada) | Watson NLP |
he |
he |
Hebrew | Watson NLP |
it-IT |
it-IT |
Italian | Watson NLP |
ja-JP |
ja-JP |
Japanese | Watson NLP |
ko-KR |
ko-KR |
Korean | Watson NLP |
nb |
nb |
Norwegian Bokmal | Watson NLP |
nn |
nn |
Norwegian Nynorsk | Watson NLP |
pt-BR |
pt-BR |
Portuguese (Brazil) | Legacy and Watson NLP |
pt-PT |
pt-PT |
Portuguese (Portugal) | Legacy and Watson NLP |
pl |
pl |
Polish | Watson NLP |
ro |
ro |
Romanian | Watson NLP |
ru-RU |
ru-RU |
Russian | Watson NLP |
sk |
sk |
Slovak | Watson NLP |
es-ES |
es-ES |
Spanish | Watson NLP |
sv |
sv |
Swedish | Watson NLP |
tr |
tr |
Turkish | Watson NLP |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Values | values |
List<Money> |
List with the monetary values extracted from the text. |
First value | first |
Money |
The first monetary value extracted from the text. |
Values mapping | valuesmapping |
Data Table |
Data table with extracted values mapped by rows and columns. See the valuesmapping parameter section for details. |
Success | success |
Boolean |
Returns True if the monetary values are successfully extracted or False otherwise. |
valuesmapping
parameter options
This parameter returns a data table with details of the extracted values.
The following list shows the mapped values:
- The index of the element in the list of extracted values. Index values start at 1.
- The index in characters where the element is found in the text.
- The length of the text used to extract the monetary value.
- The text used to extract the monetary value and the monetary value.
Example
Example 1: The following example defines English as the language to extract monetary values from text with Minimum value 10. The first value is not extracted properly due to the bad format of the monetary value. On the other side, the command extracts the second value properly because the monetary value is formatted according to the selected language.
defVar --name extractText --type String
defVar --name extractedValues --type List --innertype Money
defVar --name firstValue --type Money
defVar --name success --type Boolean
setVar --name "${extractText}" --value "I would like to bid $ 15,000 and thirty-seven cents. My friend will bid 11,000 dollars and 70 cents."
extractCurrency --culture en-US --minimumvalue 10 --text "${extractText}" extractedValues=values firstValue=first success=success
logMessage --message "Extracted values: ${extractedValues}\r\nFirst value found: ${firstValue}\r\nSuccess: ${success}\r\n\r\n" --type "Info"
// Result:
// Extracted values: [15000,11000.7]
// First value found: 15000
// Success: True
Example 2: The command extracts two monetary values from a text. In both cases the values are extracted in English, but each value is formatted in a unique way.
defVar --name extractText --type String
defVar --name extractedValues --type List --innertype Money
defVar --name firstValue --type Money
defVar --name success --type Boolean
setVar --name "${extractText}" --value "I want to donate a 1,000 dollars and fifty five cents, and my brother wants to donate $5,000."
// The first value is formatted with the currency written after the numeric value, and the second value uses the currency symbol to format it.
extractCurrency --culture "en-US" --text "${extractText}" extractedValues=values firstValue=first success=success
logMessage --message "Extracted values: ${extractedValues}\r\nFirst value found: ${firstValue}\r\nSuccess: ${success}\r\n\r\n" --type "Info"
// Result:
// Extracted values: [1000.55,5000]
// First value found: 1000.55
// Success: True
Limitations
- The monetary or numeric values entered in
Text
must be properly spelled or formatted according to the selected language, otherwise the extracted values aren't accurate. - Monetary values can only be in US dollars. Other currencies are not supported yet.