Download this file

47 lines (36 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import sys
import argparse
from addtypo import add_typo
def main(args):
parser = argparse.ArgumentParser(description='To get arguments')
parser.add_argument('-i',
'--input',
type=str,
default='test_data.yml',
help='Path of the input nlu.yml file',
required=False)
parser.add_argument('-o',
'--output',
type=str,
default='test_typo_data.yml',
help='Path of the output nlu.yml file',
required=False)
parser.add_argument('-n',
'--number',
type=str,
default=1,
help='Number of wrong letters in the string',
required=False)
args = parser.parse_args()
# Instance of AddTypo class
typo_adder = add_typo.AddTypo()
# Load the nlu datas
typo_adder.load_nlu(args.input)
# Name of the entity tags
entities = typo_adder.get_entities()
# Add typo under nlu key examples in the nlu.yml file
typo_adder.nlu_typo(args.number, entities)
# Save new nlu.yml data with typos
typo_adder.save_nlu(args.output)
if __name__ == "__main__":
main(sys.argv[1:])