Skip to content
Snippets Groups Projects
Commit 21e2463b authored by Benoit Favre's avatar Benoit Favre
Browse files

add new xml; fix bug in validation

parent add1e4fa
No related branches found
No related tags found
No related merge requests found
......@@ -47,10 +47,11 @@ DONE add thread for slu
DONE remove section changer UI
DONE change xml view to reflect already performed actions, already recognized text
DONE add global keybindings (1-9 for sections, y/n)...
DONE events = click action or words to resynchronize ?
add slu model selector
add UI to edit phonetizations
events = click action or words to resynchronize ?
click line = synchronize to that line
click action = synchronize to the next line
insert timer in main ui, use it for logger
add logger
move slu to asr
......
This diff is collapsed.
......@@ -15,10 +15,10 @@ class VerifyException(Exception):
return str(self)
def is_int(text):
return re.match(r'^\d+$', text)
return text != None and re.match(r'^\d+$', text)
def has_blank(text):
return re.search(r'\s', text)
return text != None and re.search(r'\s', text)
def verify_keyword(node):
global seen_actions, warnings
......@@ -64,9 +64,9 @@ def verify_section(node):
if has_blank(node.get('action')):
raise VerifyException('spaces not allowed in action "%s"' % node.get('action'), node)
if not is_int(node.get('id')):
raise VerifyException('only integers allowed for section id "%s"' % node.get('id'))
raise VerifyException('only integers allowed for section id "%s"' % node.get('id'), node)
if node.get('id') in seen_section_ids:
raise VerifyException('repeated section id "%s"' % node.get('id'))
raise VerifyException('repeated section id "%s"' % node.get('id'), node)
seen_section_ids[node.get('id')] = True
for child in node:
if child.tag == 'sequence':
......@@ -119,7 +119,11 @@ def validate_xml(filename):
except Exception as e:
if len(warnings) > 0:
warnings.append('--------------')
return (False, '\n'.join(warnings) + '\n' + str(e))
if isinstance(e, VerifyException):
return (False, '\n'.join(warnings) + '\n' + str(e))
else:
import traceback, sys
return (False, '\n'.join(warnings) + '\n' + traceback.format_exc(e))
if len(warnings) > 0:
warnings.append('--------------')
return (True, '\n'.join(warnings) + '\nsuccessfuly validated "%s"\nfound %d sections, %d types of action' % (filename, len(seen_section_ids), len(seen_actions)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment