Conversation
# Conflicts: # lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
|
Hi, As a general question: Do we also add separate types to synonyms or other generated tokens at same position at the moment? |
|
I think you are right, compound is the entire thing, maybe something like 'subword', let me know if you come up with something better. |
|
I think Maybe consider SubwordAttribute which wraps a boolean, or something like that. |
|
@rmuir you are suggesting to create a brand new boolean attribute? I see you point, but with a custom attribute we could not use a generic filter like NumericPayloadTokenFilter to inject a payload and as far as I understand, it would require custom code to do so. |
|
I think both of you have good opinions. The problem of the type attribute is that it only allows one type. In current code of analyzers the original type is copied over. As you see in the test, the tokenizer adds "word" as type (maybe different for other tokenizers, e.g. Japanese). The old code cloned all attributes, so the sub words also get "word" as type. The good idea here is that additional (generated tokens) get a new type assigned, e.g "subword". That helps with generic filters added later like those for payloads. It is not ideal, but it helps to classify later token additions. So in my opinion, this is fine with type attribute. |
|
I'm fine with |
Yes, if you expand synonyms and decompound then this hits you. But your filter chain could handle that. After synonyms you can add a payload filter that would trigger on synonyms and then later add decompounding with another payload filter. The whole token filter chain is problematic with that type of combinations. The whole type concept is feeling like Doug Cuttings original Token class. 😝 |
|
Can you add a changes entry. I think Lucene 10.6 should be fine as it's easy to backport |
|
@uschindler something like this? |
|
@rmuir SynonymGraphFilter emits all the token, even the original one, as type:Synonym, this seems broken to me. Do you have an idea why this is like this? I have observed this in Lucene 9.11 |
| New Features | ||
| --------------------- | ||
|
|
||
| * GITHUB#16680: Add a "subwords" type to the subword tokens generated by |
There was a problem hiding this comment.
Not plural, otherwise fine.
| /** Base class for decomposition token filters. */ | ||
| public abstract class CompoundWordTokenFilterBase extends TokenFilter { | ||
| /** Type assigned to subword tokens generated by {@link #decompose()}. */ | ||
| public static final String TOKEN_TYPE_COMPOUND = "subword"; |
There was a problem hiding this comment.
The constant should be named TOKEN_TYPE_SUBWORD
| new String[] { | ||
| "word", | ||
| CompoundWordTokenFilterBase.TOKEN_TYPE_SUBWORD, | ||
| CompoundWordTokenFilterBase.TOKEN_TYPE_SUBWORD |
There was a problem hiding this comment.
There's a conception to substituting constant to tests that let to detect a change in constant value which may break a client otherwise.
There was a problem hiding this comment.
good point, thanks for your input.
Hi @uschindler
Is there a reason not to have a specific type on the compound words, so that I could inject a payload base on the type and make sure the extracted compound does get a lower boost than the original term?