summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-07-04 14:18:08 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-07-04 15:53:44 +0100
commitb27d3f0d496b0358ab5c3bc2a8ecef5f863a635b (patch)
tree5076bc7def795088e5a102ead6e00f861ac4511f
parent770a6cb434ac31238eb2eee526e235728ce07aff (diff)
downloadmorph-b27d3f0d496b0358ab5c3bc2a8ecef5f863a635b.tar.gz
Fix issue when overriding default chunk splitting rules
When overriding a default chunk splitting rule, the use 'break' would mean that some of the other default chunk split rules might be ignored. This isn't ever what you want. I also clarified the current behaviour in a comment. I think in future we should add a mechanism to extend the default rules, as well as the current mechanism which allows only replacing them. But that is a separate issue.
-rw-r--r--morphlib/artifactsplitrule.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/morphlib/artifactsplitrule.py b/morphlib/artifactsplitrule.py
index bc92e5fb..16b0e81b 100644
--- a/morphlib/artifactsplitrule.py
+++ b/morphlib/artifactsplitrule.py
@@ -230,10 +230,11 @@ def unify_chunk_matches(morphology):
name = morphology['name']
for suffix, patterns in DEFAULT_CHUNK_RULES:
ca_name = name + suffix
- # Default rules are replaced by explicit ones
- if ca_name in split_rules.artifacts:
- break
- split_rules.add(ca_name, FileMatch(patterns))
+ # Explicit rules override the default rules. This is an all-or-nothing
+ # override: there is no way to extend the default split rules right now
+ # without duplicating them in the chunk morphology.
+ if ca_name not in split_rules.artifacts:
+ split_rules.add(ca_name, FileMatch(patterns))
return split_rules
@@ -267,9 +268,11 @@ def unify_stratum_matches(morphology):
for suffix, patterns in DEFAULT_STRATUM_RULES:
sta_name = morphology['name'] + suffix
- if sta_name in match_split_rules.artifacts:
- break
- match_split_rules.add(sta_name, ArtifactMatch(patterns))
+ # Explicit rules override the default rules. This is an all-or-nothing
+ # override: there is no way to extend the default split rules right now
+ # without duplicating them in the chunk morphology.
+ if sta_name not in match_split_rules.artifacts:
+ match_split_rules.add(sta_name, ArtifactMatch(patterns))
# Construct a new SplitRules with the assignments before matches
return SplitRules(itertools.chain(assignment_split_rules,