Add offset correction for split filter #149
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix #148
Fix the offset when the length of the morpheme is different from the actual length in the input text.
Since
correctOffset
method is only available for CharFilter and Tokenizer, we need to keep offset mapping information for sudachi_split filter somehow.I chose to put it in
MorphemeAttribute
because it is morpheme related data.With combined character,
extended
mode behaves badly (e.g. "㍍㍉" will be extended to "㍍", "㍉", not "メ", "ー", "ト", "ル”, "ミ", "リ").In this case using the normalized form will be more natural, but we cannot calculate offsets for them (mapping between surface and normalized form is missing). So I chose to keep using surface, i.e. text before normalization.
Also change dictionary type for test from small to core, to test "㍿" which is not in the small dict.
Note that due to the correctOffset behavior of icu-normalizer, offsets for subsplits of ㍿ (株式 + 会社) is now [0,0] + [0,1].