Skip to content

Commit fcf77bc

Browse files
committed
fix(picture)
1 parent 4342643 commit fcf77bc

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

-1.1 KB
Loading

regexp-imatriculation/regexp-imatriculation.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ duration: 3
1111

1212
# Introduction
1313

14-
Botfuel natively supports 31 built-in entities such as `forename`, `location`, `duration` or `url`. You can create your own dictionary of custom entities using the <a href="https://docs.botfuel.io/dialog/reference/entities/custom-entities" target="_blank">CorpusExtractor</a> class.
14+
Botfuel natively supports 31 built-in entities such as `forename`, `location`, `duration` or `url`. You can also create your own dictionary of custom entities using the <a href="https://docs.botfuel.io/dialog/reference/entities/custom-entities" target="_blank">CorpusExtractor</a> class.
1515
However, you may want to use an extractor based on string scheme.
1616

17-
In this tutorial, you will learn how to create an extractor for French vehicle registration plates using a RegexExtractor
17+
In this tutorial, you will learn how to create an extractor for French licence plates using a RegexExtractor
1818

1919
## What you will need
2020
* Have completed the <a href="/#/codelab/getting-started" target="_blank">Getting Started tutorial</a>
@@ -40,7 +40,7 @@ Shorted SIV for <i>système d'immatriculation des véhicules</i>, the French veh
4040
You can find more information on <a href="https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_France#SIV" target="_blank">wikipedia</a>
4141
</aside>
4242

43-
This SIV system makes is very easy to identify wherease a string is a licence plate. However, as mentioned in wikipedia `The SIV format provides ((23 x 23) - 2) x 999 x ((23 x 23) - 1), or 277,977,744, different combinations`. We don't recommand you build a corpus of entities with every possible combination...
43+
This SIV system makes is very easy to identify wherease a string is a licence plate. However, as mentioned in wikipedia `The SIV format provides ((23 x 23) - 2) x 999 x ((23 x 23) - 1), or 277,977,744 different combinations`. Therefore, we don't recommand you build a corpus of entities with every possible combination...
4444

4545
--sep--
4646
---
@@ -50,27 +50,26 @@ duration: 8
5050

5151
# The RegexExtractor
5252

53-
Botfuel provides a RegexExtractor that you can use to easily extract when a patern appears in a phrase. In our case, we want to extract as entities any string that looks like `AA-999-AA`.
53+
Botfuel provides a RegexExtractor that you can use to easily extract paterns in a sentense. In our case, we want to extract any string that look like `AA-999-AA`.
5454

55-
# Build the regexp
56-
57-
We mentioned in the introduction that you needed a basic understanding of Regular expression to do this tutorial. But don't worry, the regex we are going to build here is very simple.
58-
59-
Our licence plate is separated in 5 sections :
60-
1. `AA`: Here we use `[A-Za-z]{2}` to match any combinaison of two letters between ranges A and Z or a an d z as we don't want to the licence plate to be case sensitive. We want to understand if the user sends us one in lowercase
61-
2. `-`: A literal dash character
62-
3. `999`: We use [0-9]{2,3} as we want to match any combination of 2 or 3 digits. (Scooters use 2 letters)
63-
4. `-`: Another literal dash character
64-
5. `AA`: The last section is the same as the first section
55+
## Build the regex
6556

57+
We mentioned in the introduction that you would neede a basic understanding of regular expressions to do this tutorial. But don't worry, the regex we are going to build here is very simple.
6658

6759
<center>
6860
<img src="https://github.com/Botfuel/tutorials/raw/master/regexp-imatriculation/images/regex.png" alt="Regex explanation" title="Regex explanation"/>
6961
</center>
7062

63+
Our licence plate is separated in 5 sections :
64+
1. `AA`: Here, we use `[A-Za-z]{2}` to match any combinaison of two letters between ranges `A` and `Z` or `a` an d `z` as we don't want our extractor to be case sensitive. We want to extract the licence plate even if the user sends us one in lowercase.
65+
2. `-`: A literal dash character.
66+
3. `999`: We use `[0-9]{2,3}` as we want to match any combination of 2 or 3 digits. (Scooters use 2 letters).
67+
4. `-`: Another literal dash character.
68+
5. `AA`: The last section is the same as the first one.
69+
7170
Once we have our regular expression to extract a licence plate, we can use is in our extractor
7271

73-
# Use it in the RegexExtractor
72+
## Use it in the RegexExtractor
7473

7574
Create a new file called `immatriculation-extractor.js` in the `extractors` folder containing the code below:
7675

@@ -89,11 +88,11 @@ class ImmatriculationExtractor extends RegexExtractor {
8988
module.exports = ImmatriculationExtractor
9089
```
9190

92-
As you can see, creating a new RegexExtractor is very easy. You just need to specify a dimention that is going to be used in your dialog and the regex you want to match to extract your entity.
91+
As you can see, creating a new RegexExtractor is very easy. You just need to specify a `dimention` that is going to be used in your dialog and the regex you want to match to extract your entities.
9392

9493
--sep--
9594
---
96-
title: Test the extractor
95+
title: Use the extractor
9796
duration: 5
9897
---
9998

@@ -111,7 +110,7 @@ Add a few training phrases the user may enter to give you his licence plate.
111110

112111
## Create the Dialog
113112

114-
To test the extractor, go in you dialogs folder and create a new dialog called `licenceplate-dialog.js` with the code below:
113+
Go in you dialogs folder and create a new dialog called `licenceplate-dialog.js` with the following code:
115114

116115
```javascript
117116
const { PromptDialog } = require('botfuel-dialog');
@@ -136,7 +135,7 @@ Here, you just specified that the `LicencePlateDialog` will have an entity of di
136135

137136
You can use your entity in your view the same way you use any other entity in Botfuel
138137

139-
Create a file `licenceplate-view.js` in the view folder with the code below:
138+
Goo in you views folder and create a new dialog called `licenceplate-view.js` with the following code:
140139

141140
```javascript
142141
const { PromptView, BotTextMessage } = require('botfuel-dialog');
@@ -160,7 +159,7 @@ module.exports = LicencePlateView;
160159

161160
## Test
162161

163-
Start the bot with the `BOTFUEL_APP_ID`, `BOTFUEL_APP_KEY` and `BOTFUEL_APP_TOKEN` environment variables using your app’s credentials:
162+
Start the bot using your app’s credentials:
164163

165164
```bash
166165
BOTFUEL_APP_TOKEN=<the BOTFUEL_APP_TOKEN> BOTFUEL_APP_ID=<the BOTFUEL_APP_ID> BOTFUEL_APP_KEY=<the BOTFUEL_APP_KEY> npm start
@@ -179,7 +178,7 @@ duration: 1
179178

180179
# Congratulation
181180

182-
You have reached the end of this tutorial. The `RegexExtractor` opens endless possibilities to create custom extractors
181+
You have reached the end of this tutorial. The `RegexExtractor` opens endless possibilities to create custom extractors.
183182

184183
## <i class="fas fa-heart"></i> Support us
185184

0 commit comments

Comments
 (0)