This tutorial begins where Getting started - Part 3 left off. You’ll add another interpretation in order to improve your agent.
Additional address information
An address can contain additional information such as the apartment number, building number, floor number and so on. These are all optional information in an address.
Addresses with additional info can take the form of any one of the following:
- Apt 2, 12 avenue de Flandres 75019 Paris
- Apt 2, Batiment B, 12 avenue de Flandres 75019 Paris
- Apt 2, 1er étage, Batiment B, 12 avenue de Flandres 75019 Paris
Let us see how we can incorporate this in our agent.
One way would be to create separate formulations for each of these sentences. However, the better and non repetitive way is to treat these additional information in the address as a list. Let us see how we can do this.
Recognize additional info individually
Let us first create a few components that will recognize the additional information in the address.
Step 1 Create a private entities list “building_components”
Then add the following entities with enabled auto solution option.
1
2
batiment
bat
1
étage
1
2
appartement
apt
Step 2 Create a private interpretation “additional_information”
Step 3 Add first formulation in the interpretation
- Type “Apt 1” in the input field.
- Highlight “Apt” and link to the “building_components” entities list you created earlier.
- Highlight “1” and link to “Regex” type. Type
[A-Za-z0-9\S]+
in the Regex input field. - Set solution to
raw_text
.
Step 4 Add second formulation in the interpretation
- Type “1er étage” in the input field.
- Highlight “1er” and link to the
viky/numbers/interpretations/number_ordinal
interpretation. - Highlight “étage” and and link to the
building_components
entities list. - Set solution to
raw_text
.
Step 5 Validate your work
You now have an interpretation that can detect expressions such as “3ème étage” or “Appartement 27b”.
Use the console to check this. The interpretation “additional_information” being private, use the verbose option in the console which allows you not to exclude private interpretations.
Integrate recognition of additional info
Now that we have a private interpretation to recognize additional information, let us create a new formulation in our public “Address” interpretation.
- Type “Apt 2 12 avenue de Flandres 75019 Paris”
- Highlight “Apt 2” and link it to “additional_information” interpretation.
- Select the option “List”.
- Highlight other part like the existing interpretation.
- Add the following solution.
1
2
3
4
5
6
7
{
"additional_information": additional_information.additional_information,
"street_number": street_number.number,
"route": route_type + " " + route_name,
"postal_code": postal_code.number,
"locality": locality.nom_commune
}
You can now validate your work by checking the agent’s behavior using the console.