[
https://issues.apache.org/jira/browse/LUCENE-3475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16343073#comment-16343073
]
Adrien Grand commented on LUCENE-3475:
--------------------------------------
I'm not going to work on this in the short term but I just wrote a test case in
case someone else has interest in fixing this issue:
{code}
public void testSynonyms1() throws IOException {
Token t1 = new Token("small", 0, 5);
Token t2 = new Token("little", 0, 5);
t2.setPositionIncrement(0);
Token t3 = new Token("thing", 6, 11);
TokenStream tk = new CannedTokenStream(t1, t2, t3);
ShingleFilter f = new ShingleFilter(tk, 2, 2);
f.setOutputUnigrams(false);
assertTokenStreamContents(f,
new String[] { "small thing", "little thing" },
new int[] {0, 0},
new int[] {11, 11},
new int[] {1, 0});
}
public void testSynonyms2() throws IOException {
Token t1 = new Token("small", 0, 5);
Token t2 = new Token("thing", 6, 11);
Token t3 = new Token("object", 6, 11);
t3.setPositionIncrement(0);
TokenStream tk = new CannedTokenStream(t1, t2, t3);
ShingleFilter f = new ShingleFilter(tk, 2, 2);
f.setOutputUnigrams(false);
assertTokenStreamContents(f,
new String[] { "small thing", "small object" },
new int[] {0, 0},
new int[] {11, 11},
new int[] {1, 0});
}
{code}
> ShingleFilter should handle positionIncrement of zero, e.g. synonyms
> --------------------------------------------------------------------
>
> Key: LUCENE-3475
> URL: https://issues.apache.org/jira/browse/LUCENE-3475
> Project: Lucene - Core
> Issue Type: New Feature
> Components: modules/analysis
> Affects Versions: 3.4
> Reporter: Cameron
> Priority: Minor
> Labels: newdev
>
> ShingleFilter is creating shingles for a single term that has been expanded
> by synonyms when it shouldn't. The position increment is 0.
> As an example, I have an Analyzer with a SynonymFilter followed by a
> ShingleFilter. Assuming car and auto are synonyms, the SynonymFilter produces
> two tokens and position 1: car, auto. The ShingleFilter is then producing 3
> tokens, when there should only be two: car, car auto, auto. This behavior
> seems incorrect.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]