Feature: Allow comments in voc and regex files

When loading voc and regex files, lines starting with "#" are now
ignored, so developers and translators can use them to document their
decisions.

==== Fixed Issues ====
pull/1539/head
Sergio Oller 2018-04-14 21:53:14 +02:00
parent 9655c65686
commit 5e8d8eb1a6
1 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,8 @@ def load_vocab_from_file(path, vocab_type, emitter):
if path.endswith('.voc'):
with open(path, 'r') as voc_file:
for line in voc_file.readlines():
if line.startswith("#"):
continue
parts = line.strip().split("|")
entity = parts[0]
emitter.emit(Message("register_vocab", {
@ -59,6 +61,8 @@ def load_regex_from_file(path, emitter, skill_id):
if path.endswith('.rx'):
with open(path, 'r') as reg_file:
for line in reg_file.readlines():
if line.startswith("#"):
continue
re.compile(munge_regex(line.strip(), skill_id))
emitter.emit(
Message("register_vocab",