Why FlattenGraphFilter (after SynonymGraphFilter) is doing nothing in this analyzer example? The Next CEO of Stack OverflowWhy is the analyzer defined globally in Zend.Search.Lucene?Different analyzers for each fieldIs there a HTML analyzer/tokenizer for Lucene?How can I read a Lucene document field tokens after they are analyzed?Comparison of Lucene AnalyzersLUCENE Standard Analyzer Hyphen considerationLucene AnalyzerCombine Lucene query with different analyzerAnalyzer for '&' and 'and'Why lucene query returns nothing?
What do "high sea" and "carry" mean in this sentence?
Anatomically Correct Strange Women In Ponds Distributing Swords
How does the mv command work with external drives?
What happened in Rome, when the western empire "fell"?
How to start emacs in "nothing" mode (`fundamental-mode`)
If a black hole is created from light, can this black hole then move at speed of light?
MessageLevel in QGIS3
Are there any unintended negative consequences to allowing PCs to gain multiple levels at once in a short milestone-XP game?
Limits on contract work without pre-agreed price/contract (UK)
How to solve a differential equation with a term to a power?
A "random" question: usage of "random" as adjective in Spanish
Between two walls
Inappropriate reference requests from Journal reviewers
Why am I allowed to create multiple unique pointers from a single object?
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
Is there a way to save my career from absolute disaster?
How fast would a person need to move to trick the eye?
Complex fractions
"and that skill is always a class skill for you" - does "always" have any meaning in Pathfinder?
How to Reset Passwords on Multiple Websites Easily?
Interfacing a button to MCU (and PC) with 50m long cable
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
Indicator light circuit
Preparing Indesign booklet with .psd graphics for print
Why FlattenGraphFilter (after SynonymGraphFilter) is doing nothing in this analyzer example?
The Next CEO of Stack OverflowWhy is the analyzer defined globally in Zend.Search.Lucene?Different analyzers for each fieldIs there a HTML analyzer/tokenizer for Lucene?How can I read a Lucene document field tokens after they are analyzed?Comparison of Lucene AnalyzersLUCENE Standard Analyzer Hyphen considerationLucene AnalyzerCombine Lucene query with different analyzerAnalyzer for '&' and 'and'Why lucene query returns nothing?
I'm trying to make synonyms work right and for that I'm trying to understand better graphs in a token stream.
For that purpose I've built this code:
Builder builder = CustomAnalyzer.builder();
builder.withTokenizer(StandardTokenizerFactory.class);
MySynonymGraphFilterFactory.registerSynonyms(Arrays.asList(
Arrays.asList("go to", "navigate", "open")
));
builder.addTokenFilter(MySynonymGraphFilterFactory.class, "synonyms", "unused");
(MySynonymGraphFilterFactory is just a hack to pass a list of lists for synonyms. It expands everything mapping everything to everything.)
builder.addTokenFilter(FlattenGraphFilterFactory.class); // nothing changes with this!
Analyzer analyzer = builder.build();
TokenStream ts = analyzer.tokenStream("*", new StringReader("go to the webpage!"));
Then I call a tokenStreamToString()
function that just dumps terms, position increments and position lengths (the code for that function is included at the bottom of this question):
System.out.println(tokenStreamToString(ts));
What I don't understand is this. I get the same output whether I include FlattenGraphFilter
or not. This is the output:
navigate<2> (0)open<2> (0)go to the webpage
(angle brackets show position lengths of the preceding term; parenthesis show position increments of the following term)
There's something I'm not understanding here. I'd thought that flattening the stream meant that no token will have position length > 1... was I wrong? I would greatly appreciate any help with understanding this.
PS: The implementation of my debugging function tokenStreamToString()
:
static String tokenStreamToString(TokenStream stream) throws IOException
CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
PositionIncrementAttribute posAtt = stream.addAttribute(PositionIncrementAttribute.class);
PositionLengthAttribute posLenAtt = stream.addAttribute(PositionLengthAttribute.class);
StringBuilder sb = new StringBuilder();
stream.reset();
while(stream.incrementToken())
int inc = posAtt.getPositionIncrement();
if(inc != 1)
sb.append('(').append(inc).append(')');
sb.append(termAtt.toString());
int posLen = posLenAtt.getPositionLength();
if(posLen != 1)
sb.append('<').append(posLen).append('>');
sb.append(' ');
return sb.toString();
Thanks.
lucene
add a comment |
I'm trying to make synonyms work right and for that I'm trying to understand better graphs in a token stream.
For that purpose I've built this code:
Builder builder = CustomAnalyzer.builder();
builder.withTokenizer(StandardTokenizerFactory.class);
MySynonymGraphFilterFactory.registerSynonyms(Arrays.asList(
Arrays.asList("go to", "navigate", "open")
));
builder.addTokenFilter(MySynonymGraphFilterFactory.class, "synonyms", "unused");
(MySynonymGraphFilterFactory is just a hack to pass a list of lists for synonyms. It expands everything mapping everything to everything.)
builder.addTokenFilter(FlattenGraphFilterFactory.class); // nothing changes with this!
Analyzer analyzer = builder.build();
TokenStream ts = analyzer.tokenStream("*", new StringReader("go to the webpage!"));
Then I call a tokenStreamToString()
function that just dumps terms, position increments and position lengths (the code for that function is included at the bottom of this question):
System.out.println(tokenStreamToString(ts));
What I don't understand is this. I get the same output whether I include FlattenGraphFilter
or not. This is the output:
navigate<2> (0)open<2> (0)go to the webpage
(angle brackets show position lengths of the preceding term; parenthesis show position increments of the following term)
There's something I'm not understanding here. I'd thought that flattening the stream meant that no token will have position length > 1... was I wrong? I would greatly appreciate any help with understanding this.
PS: The implementation of my debugging function tokenStreamToString()
:
static String tokenStreamToString(TokenStream stream) throws IOException
CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
PositionIncrementAttribute posAtt = stream.addAttribute(PositionIncrementAttribute.class);
PositionLengthAttribute posLenAtt = stream.addAttribute(PositionLengthAttribute.class);
StringBuilder sb = new StringBuilder();
stream.reset();
while(stream.incrementToken())
int inc = posAtt.getPositionIncrement();
if(inc != 1)
sb.append('(').append(inc).append(')');
sb.append(termAtt.toString());
int posLen = posLenAtt.getPositionLength();
if(posLen != 1)
sb.append('<').append(posLen).append('>');
sb.append(' ');
return sb.toString();
Thanks.
lucene
add a comment |
I'm trying to make synonyms work right and for that I'm trying to understand better graphs in a token stream.
For that purpose I've built this code:
Builder builder = CustomAnalyzer.builder();
builder.withTokenizer(StandardTokenizerFactory.class);
MySynonymGraphFilterFactory.registerSynonyms(Arrays.asList(
Arrays.asList("go to", "navigate", "open")
));
builder.addTokenFilter(MySynonymGraphFilterFactory.class, "synonyms", "unused");
(MySynonymGraphFilterFactory is just a hack to pass a list of lists for synonyms. It expands everything mapping everything to everything.)
builder.addTokenFilter(FlattenGraphFilterFactory.class); // nothing changes with this!
Analyzer analyzer = builder.build();
TokenStream ts = analyzer.tokenStream("*", new StringReader("go to the webpage!"));
Then I call a tokenStreamToString()
function that just dumps terms, position increments and position lengths (the code for that function is included at the bottom of this question):
System.out.println(tokenStreamToString(ts));
What I don't understand is this. I get the same output whether I include FlattenGraphFilter
or not. This is the output:
navigate<2> (0)open<2> (0)go to the webpage
(angle brackets show position lengths of the preceding term; parenthesis show position increments of the following term)
There's something I'm not understanding here. I'd thought that flattening the stream meant that no token will have position length > 1... was I wrong? I would greatly appreciate any help with understanding this.
PS: The implementation of my debugging function tokenStreamToString()
:
static String tokenStreamToString(TokenStream stream) throws IOException
CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
PositionIncrementAttribute posAtt = stream.addAttribute(PositionIncrementAttribute.class);
PositionLengthAttribute posLenAtt = stream.addAttribute(PositionLengthAttribute.class);
StringBuilder sb = new StringBuilder();
stream.reset();
while(stream.incrementToken())
int inc = posAtt.getPositionIncrement();
if(inc != 1)
sb.append('(').append(inc).append(')');
sb.append(termAtt.toString());
int posLen = posLenAtt.getPositionLength();
if(posLen != 1)
sb.append('<').append(posLen).append('>');
sb.append(' ');
return sb.toString();
Thanks.
lucene
I'm trying to make synonyms work right and for that I'm trying to understand better graphs in a token stream.
For that purpose I've built this code:
Builder builder = CustomAnalyzer.builder();
builder.withTokenizer(StandardTokenizerFactory.class);
MySynonymGraphFilterFactory.registerSynonyms(Arrays.asList(
Arrays.asList("go to", "navigate", "open")
));
builder.addTokenFilter(MySynonymGraphFilterFactory.class, "synonyms", "unused");
(MySynonymGraphFilterFactory is just a hack to pass a list of lists for synonyms. It expands everything mapping everything to everything.)
builder.addTokenFilter(FlattenGraphFilterFactory.class); // nothing changes with this!
Analyzer analyzer = builder.build();
TokenStream ts = analyzer.tokenStream("*", new StringReader("go to the webpage!"));
Then I call a tokenStreamToString()
function that just dumps terms, position increments and position lengths (the code for that function is included at the bottom of this question):
System.out.println(tokenStreamToString(ts));
What I don't understand is this. I get the same output whether I include FlattenGraphFilter
or not. This is the output:
navigate<2> (0)open<2> (0)go to the webpage
(angle brackets show position lengths of the preceding term; parenthesis show position increments of the following term)
There's something I'm not understanding here. I'd thought that flattening the stream meant that no token will have position length > 1... was I wrong? I would greatly appreciate any help with understanding this.
PS: The implementation of my debugging function tokenStreamToString()
:
static String tokenStreamToString(TokenStream stream) throws IOException
CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
PositionIncrementAttribute posAtt = stream.addAttribute(PositionIncrementAttribute.class);
PositionLengthAttribute posLenAtt = stream.addAttribute(PositionLengthAttribute.class);
StringBuilder sb = new StringBuilder();
stream.reset();
while(stream.incrementToken())
int inc = posAtt.getPositionIncrement();
if(inc != 1)
sb.append('(').append(inc).append(')');
sb.append(termAtt.toString());
int posLen = posLenAtt.getPositionLength();
if(posLen != 1)
sb.append('<').append(posLen).append('>');
sb.append(' ');
return sb.toString();
Thanks.
lucene
lucene
asked Mar 21 at 16:59
niqueconiqueco
1,2121026
1,2121026
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285608%2fwhy-flattengraphfilter-after-synonymgraphfilter-is-doing-nothing-in-this-analy%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285608%2fwhy-flattengraphfilter-after-synonymgraphfilter-is-doing-nothing-in-this-analy%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown