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
parent
9655c65686
commit
5e8d8eb1a6
|
@ -37,6 +37,8 @@ def load_vocab_from_file(path, vocab_type, emitter):
|
||||||
if path.endswith('.voc'):
|
if path.endswith('.voc'):
|
||||||
with open(path, 'r') as voc_file:
|
with open(path, 'r') as voc_file:
|
||||||
for line in voc_file.readlines():
|
for line in voc_file.readlines():
|
||||||
|
if line.startswith("#"):
|
||||||
|
continue
|
||||||
parts = line.strip().split("|")
|
parts = line.strip().split("|")
|
||||||
entity = parts[0]
|
entity = parts[0]
|
||||||
emitter.emit(Message("register_vocab", {
|
emitter.emit(Message("register_vocab", {
|
||||||
|
@ -59,6 +61,8 @@ def load_regex_from_file(path, emitter, skill_id):
|
||||||
if path.endswith('.rx'):
|
if path.endswith('.rx'):
|
||||||
with open(path, 'r') as reg_file:
|
with open(path, 'r') as reg_file:
|
||||||
for line in reg_file.readlines():
|
for line in reg_file.readlines():
|
||||||
|
if line.startswith("#"):
|
||||||
|
continue
|
||||||
re.compile(munge_regex(line.strip(), skill_id))
|
re.compile(munge_regex(line.strip(), skill_id))
|
||||||
emitter.emit(
|
emitter.emit(
|
||||||
Message("register_vocab",
|
Message("register_vocab",
|
||||||
|
|
Loading…
Reference in New Issue