Extract Address

Extracts addresses from a text.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

This command analyzes a text and look for one or more addresses on the text. It uses a pre-established integration with Google™ Geocoding API 🡥 to analyze these addresses and returns a list of addresses that match with the ones that are found on the text.

As an output from this command, you get the addresses returned in a list, the first address from this list, and a data table with the mapping of these addresses like their street, street number, neighborhood, city, state, and country.

Important:On IBM RPA 23.0.3, the pre-established integration with Google™ Geocoding API for this command got deprecated. Starting from IBM RPA 23.0.5, you must enter your own Google™ Geocoding API key in the API Key parameter.

Dependencies

To use the command, you must provide a valid Google™ Geocoding API key.

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.

extractAddress --culture(Culture) --apiKey(String) --addressText(String) [--country(String)] [--state(String)] [--city(String)] (List<Address>)=values (Address)=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 The language to analyze the text.

If you define the language as a text, make sure to enter only supported language codes.

See the culture parameter options for supported languages and language codes.
API key apiKey Required Text The Google™ Geocoding API key.

See Use API Keys with Geocoding API 🡥 for more details on how to get your own API key.
Text addressText Required Text Text to analyze.
Preferred country country Optional Text The country name. The command prioritizes the extraction of addresses that matches the country name.

See the country, state, and city parameters options section for details.
Preferred state state Optional Text The state name. The command prioritizes the extraction of addresses that matches the state name.

See the country, state, and city parameters options section for details.
Preferred city city Optional Text The city name. The command prioritizes the extraction of addresses that matches the city name.

See the country, state, and city parameters options section for details.

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)

country, state, and city parameters options

The Preferred country, Preferred state, and Preferred city parameters prioritize filtering specific addresses in the text, which match to what you enter to one of them. Enter a value to more than one of them to filter a more specific location.

As a return, you get the addresses that match to what you put on these parameters plus the other addresses that it finds in the input text.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Values values List<Address> Returns the addresses that are extracted from the text in a list.
First value first Address Returns the first occurrence of an address in the address list.
Values mapping valuesmapping Data Table Returns the mapping of the addresses extracted.

See the valuesmapping parameter options section for details.
Success success Boolean Return True if the command extracts any address, or False otherwise.

valuesmapping parameter options

This parameter returns a data table containing the occurrence of each address that is extracted from the input text.

The following list shows the properties of the addresses that are mapped:

  • The index value in the list of extracted addresses. Index values start at 1.
  • The street type.
  • The street.
  • The street number.
  • The neighborhood.
  • The locality.
  • The sub locality.
  • The city.
  • The state.
  • The postal code.
  • The postal-code suffix.
  • The country.

Example

The following code example uses the Extract Address command to analyze a text and look for an address on it. It looks for parts of text that corresponds to an address value like "32 Vassar Street, Cambridge". As result it returns this value and its properties, for example, "Vassar Street, 32, Area 2/MIT, Middlesex County, Massachusetts, 02139, United States".

defVar --name addressList --type List --innertype Address
defVar --name firstAddress --type Address
defVar --name addressExtracted --type Boolean
defVar --name sentence --type String
// Assigns a sentence which contains an address to the "${sentence}" variable.
setVar --name "${sentence}" --value "Finance automation got a kick-start in the 1990s, when MIT researchers located at 32 Vassar Street, Cambridge, developed the optical character recognition (OCR) technology for reading the handwritten parts of checks with high speed and accuracy."
// Extracts the addresses within the input text. 
extractAddress --culture "en-US" --addressText "${sentence}" addressList=values firstAddress=first addressExtracted=success
// Logs the extracted address.
logMessage --message "Check the output from the sentence used by this example:\r\n\r\nLisf of addresses: ${addressList}\r\nFirst address: ${firstAddress}\r\nAddress extracted with success: ${addressExtracted}" --type "Info"
// You can get the following outputs:
//
// Lisf of addresses: [Vassar Street, 32, Area 2/MIT, Middlesex County, Massachusetts, 02139, United States]
// First address: Vassar Street, 32, Area 2/MIT, Middlesex County, Massachusetts, 02139, United States
// Address extracted with success: True

Limitations

  • This command does not support Watson NLP provider.
  • If the input Text parameter contains multiple addresses, the command may return unreliable results.