You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: regexp-imatriculation/regexp-imatriculation.md
+20-21Lines changed: 20 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,10 @@ duration: 3
11
11
12
12
# Introduction
13
13
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 <ahref="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 <ahref="https://docs.botfuel.io/dialog/reference/entities/custom-entities"target="_blank">CorpusExtractor</a> class.
15
15
However, you may want to use an extractor based on string scheme.
16
16
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
18
18
19
19
## What you will need
20
20
* Have completed the <ahref="/#/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
40
40
You can find more information on <ahref="https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_France#SIV"target="_blank">wikipedia</a>
41
41
</aside>
42
42
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...
44
44
45
45
--sep--
46
46
---
@@ -50,27 +50,26 @@ duration: 8
50
50
51
51
# The RegexExtractor
52
52
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`.
54
54
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
65
56
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.
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
+
71
70
Once we have our regular expression to extract a licence plate, we can use is in our extractor
72
71
73
-
# Use it in the RegexExtractor
72
+
##Use it in the RegexExtractor
74
73
75
74
Create a new file called `immatriculation-extractor.js` in the `extractors` folder containing the code below:
76
75
@@ -89,11 +88,11 @@ class ImmatriculationExtractor extends RegexExtractor {
89
88
module.exports= ImmatriculationExtractor
90
89
```
91
90
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.
93
92
94
93
--sep--
95
94
---
96
-
title: Test the extractor
95
+
title: Use the extractor
97
96
duration: 5
98
97
---
99
98
@@ -111,7 +110,7 @@ Add a few training phrases the user may enter to give you his licence plate.
111
110
112
111
## Create the Dialog
113
112
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:
0 commit comments