Repository navigation
GH-1342: Escape separators in dependency parser combined features - #1520
henriquejsza wants to merge 1 commit into
Conversation
|
@henriquejsza thank you for this PR. I have time to look it over this weekend (within 48 hours). Thank you for your contribution and appreciate the time you put into this! I'll also get you an answer about the model training. |
krickert
left a comment
There was a problem hiding this comment.
Just a few minor nits
I got around to reviewing this - it's a clean fix and the tests read well.
Two small nits:
escapecould be a plain private method like the other helpers in the class, no need forstatic.- The Javadoc says the feature "is read back unambiguously", but nothing reads it back. Maybe "stays unambiguous".
|
On the model question: the dependency parser is new in 3.0 and we haven't released a model for it, so nothing published needs retraining. The only thing affected is @mawiesne - once we get someone a second review I'll start the eval job change and post the numbers here. If they moved, I'll share the numbers for @henriquejsza to update the expected scores. |
rzo1
left a comment
There was a problem hiding this comment.
LGTM once krickert's nits are in. Separate issue: a token that is literally *NULL* or *ROOT* still collides with the marker values.
| /** | ||
| * Prefixes every {@link #ESCAPE}, {@link #WORD_TAG_SEPARATOR}, and | ||
| * {@link #POSITION_SEPARATOR} in a value with {@link #ESCAPE}, so that a combined | ||
| * feature of several positions is read back unambiguously and cannot collide with the |
There was a problem hiding this comment.
Nothing reads this back. "stays unambiguous"?
| * @param value The value to escape. Must not be {@code null}. | ||
| * @return The escaped value, or {@code value} if it has nothing to escape. | ||
| */ | ||
| private static String escape(String value) { |
There was a problem hiding this comment.
Doesn't need to be static, the other helpers aren't.
DependencyContextGenerator joined position values with the word-tag separator '/' and the position separator '|' without escaping them. A value containing one of these characters could make a combined feature of one configuration read the same as that of another, for example s1t=X|Y, s0t=Z and s1t=X, s0t=Y|Z both produced s1t,s0t=X|Y|Z. Escape the escape character '\', '/', and '|' in each value that is joined into a combined feature, so every combined feature is read back unambiguously. Single-position features carry one value and are left as is. Values without these characters are returned unchanged. Signed-off-by: henriquejsza <henriquejsza@gmail.com>
c9bd776 to
6e4bf84
Compare
Thank you for contributing to Apache OpenNLP.
For all changes:
For code changes:
Fixes #1342
DependencyContextGeneratorjoined the word-tag and position values of acombined feature with
/and|without escaping them. A value holding oneof these characters could make a combined feature of one configuration read
the same as that of another, for example
s1t=X|Y, s0t=Zands1t=X, s0t=Y|Zboth produced
s1t,s0t=X|Y|Z.This escapes the escape character
\,/, and|in every value that isjoined into a combined feature, so each combined feature is read back
unambiguously. Single-position features carry one value, so a separator there
cannot split the feature and the value is left as is. Values without any of
these characters are returned unchanged.
The dependency parser is new in 3.0 and no models have shipped yet, so there is
no released model to keep compatible. Universal POS tags never contain
/or|, so the trained-model feature strings only change for tokens that containone of these characters; the pinned
UniversalDependencyParserEvalscoresshould be re-run on a newly trained model.