FAQ
Hello List,

Having posted a couple of days ago, I have one last question regarding the following code fragment

public static Token[] tokensFromAnalysis(Analyzer analyzer, String text)
throws IOException {
TokenStream stream = analyzer.tokenStream("contents",
new StringReader(text));
ArrayList<Token> tokenList = new ArrayList<Token>();
Token token = null;
while ((token = stream.next()) != null) <-------
tokenList.add(token);
Token[] tokens = new Token[tokenList.size()];
for (int i = 0; i < tokens.length; i++)
tokens[i] = tokenList.get(i);
return (tokens);

I am getting an error on stream.next() as highlighted. I am prompted to add a cast to stream, however I then am faced with the problem of which object to pass... which I do not know.

while ((token = ((Object) stream).next()) != null)

Thank you
Lewis


Glasgow Caledonian University is a registered Scottish charity, number SC021474

Winner: Times Higher Education's Widening Participation Initiative of the Year 2009 and Herald Society's Education Initiative of the Year 2009
http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html

Search Discussions

  • Simon Willnauer at Dec 2, 2010 at 3:35 pm
    man what version of lucene are you useing?

    simon

    On Thu, Dec 2, 2010 at 4:27 PM, McGibbney, Lewis John
    wrote:
    Hello List,

    Having posted a couple of days ago, I have one last question regarding the following code fragment

    public static Token[] tokensFromAnalysis(Analyzer analyzer, String text)
    throws IOException {
    TokenStream stream = analyzer.tokenStream("contents",
    new StringReader(text));
    ArrayList<Token> tokenList = new ArrayList<Token>();
    Token token = null;
    while ((token = stream.next()) != null) <-------
    tokenList.add(token);
    Token[] tokens = new Token[tokenList.size()];
    for (int i = 0; i < tokens.length; i++)
    tokens[i] = tokenList.get(i);
    return (tokens);

    I am getting an error on stream.next() as highlighted. I am prompted to add a cast to stream, however I then am faced with the problem of which object to pass... which I do not know.

    while ((token = ((Object) stream).next()) != null)

    Thank you
    Lewis


    Glasgow Caledonian University is a registered Scottish charity, number SC021474

    Winner: Times Higher Education's Widening Participation Initiative of the Year 2009 and Herald Society's Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • McGibbney, Lewis John at Dec 2, 2010 at 3:46 pm
    I have been trying to reuse code which was originally written a while ago as you can tell.

    I am looking for suggestions as to how I could get the code working, if this is not possible alternatively I will start from scratch.

    Thank you


    -----Original Message-----
    From: Simon Willnauer
    Sent: 02 December 2010 15:35
    To: java-user@lucene.apache.org
    Subject: Re: tokensFromAnalysis

    man what version of lucene are you useing?

    simon

    On Thu, Dec 2, 2010 at 4:27 PM, McGibbney, Lewis John
    wrote:
    Hello List,

    Having posted a couple of days ago, I have one last question regarding the following code fragment

    public static Token[] tokensFromAnalysis(Analyzer analyzer, String text)
    throws IOException {
    TokenStream stream = analyzer.tokenStream("contents",
    new StringReader(text));
    ArrayList<Token> tokenList = new ArrayList<Token>();
    Token token = null;
    while ((token = stream.next()) != null) <-------
    tokenList.add(token);
    Token[] tokens = new Token[tokenList.size()];
    for (int i = 0; i < tokens.length; i++)
    tokens[i] = tokenList.get(i);
    return (tokens);

    I am getting an error on stream.next() as highlighted. I am prompted to add a cast to stream, however I then am faced with the problem of which object to pass... which I do not know.

    while ((token = ((Object) stream).next()) != null)

    Thank you
    Lewis


    Glasgow Caledonian University is a registered Scottish charity, number SC021474

    Winner: Times Higher Education's Widening Participation Initiative of the Year 2009 and Herald Society's Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

    Email has been scanned for viruses by Altman Technologies' email management service - www.altman.co.uk/emailsystems

    Glasgow Caledonian University is a registered Scottish charity, number SC021474

    Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
  • Steven A Rowe at Dec 2, 2010 at 4:29 pm
    Lewis,

    Simon asked about the version of Lucene you're using because this section of the API has seen regular change. If you don't tell us which version, we can't help, because we don't know what you're coding against.

    Steve
    -----Original Message-----
    From: McGibbney, Lewis John
    Sent: Thursday, December 02, 2010 10:46 AM
    To: 'java-user@lucene.apache.org'; 'simon.willnauer@gmail.com'
    Subject: RE: tokensFromAnalysis

    I have been trying to reuse code which was originally written a while ago
    as you can tell.

    I am looking for suggestions as to how I could get the code working, if
    this is not possible alternatively I will start from scratch.

    Thank you


    -----Original Message-----
    From: Simon Willnauer
    Sent: 02 December 2010 15:35
    To: java-user@lucene.apache.org
    Subject: Re: tokensFromAnalysis

    man what version of lucene are you useing?

    simon

    On Thu, Dec 2, 2010 at 4:27 PM, McGibbney, Lewis John
    wrote:
    Hello List,

    Having posted a couple of days ago, I have one last question regarding
    the following code fragment
    public static Token[] tokensFromAnalysis(Analyzer analyzer, String text)
    throws IOException {
    TokenStream stream = analyzer.tokenStream("contents",
    new StringReader(text));
    ArrayList<Token> tokenList = new ArrayList<Token>();
    Token token = null;
    while ((token = stream.next()) != null) <-------
    tokenList.add(token);
    Token[] tokens = new Token[tokenList.size()];
    for (int i = 0; i < tokens.length; i++)
    tokens[i] = tokenList.get(i);
    return (tokens);

    I am getting an error on stream.next() as highlighted. I am prompted to
    add a cast to stream, however I then am faced with the problem of which
    object to pass... which I do not know.
    while ((token = ((Object) stream).next()) != null)

    Thank you
    Lewis


    Glasgow Caledonian University is a registered Scottish charity, number SC021474
    Winner: Times Higher Education's Widening Participation Initiative of
    the Year 2009 and Herald Society's Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,
    en.html
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

    Email has been scanned for viruses by Altman Technologies' email
    management service - www.altman.co.uk/emailsystems

    Glasgow Caledonian University is a registered Scottish charity, number
    SC021474

    Winner: Times Higher Education’s Widening Participation Initiative of the
    Year 2009 and Herald Society’s Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,
    en.html
  • McGibbney, Lewis John at Dec 2, 2010 at 4:58 pm
    Having done a search the version is 2.3!!!

    I have been making changes since posting my first message, if it is ok I will add a reply to this thread in upcoming days if I bump into more problems. I didn't realise the API had changed to the degree it has.

    Lewis




    -----Original Message-----
    From: Steven A Rowe
    Sent: 02 December 2010 16:30
    To: java-user@lucene.apache.org
    Subject: RE: tokensFromAnalysis

    Lewis,

    Simon asked about the version of Lucene you're using because this section of the API has seen regular change. If you don't tell us which version, we can't help, because we don't know what you're coding against.

    Steve
    -----Original Message-----
    From: McGibbney, Lewis John
    Sent: Thursday, December 02, 2010 10:46 AM
    To: 'java-user@lucene.apache.org'; 'simon.willnauer@gmail.com'
    Subject: RE: tokensFromAnalysis

    I have been trying to reuse code which was originally written a while ago
    as you can tell.

    I am looking for suggestions as to how I could get the code working, if
    this is not possible alternatively I will start from scratch.

    Thank you


    -----Original Message-----
    From: Simon Willnauer
    Sent: 02 December 2010 15:35
    To: java-user@lucene.apache.org
    Subject: Re: tokensFromAnalysis

    man what version of lucene are you useing?

    simon

    On Thu, Dec 2, 2010 at 4:27 PM, McGibbney, Lewis John
    wrote:
    Hello List,

    Having posted a couple of days ago, I have one last question regarding
    the following code fragment
    public static Token[] tokensFromAnalysis(Analyzer analyzer, String text)
    throws IOException {
    TokenStream stream = analyzer.tokenStream("contents",
    new StringReader(text));
    ArrayList<Token> tokenList = new ArrayList<Token>();
    Token token = null;
    while ((token = stream.next()) != null) <-------
    tokenList.add(token);
    Token[] tokens = new Token[tokenList.size()];
    for (int i = 0; i < tokens.length; i++)
    tokens[i] = tokenList.get(i);
    return (tokens);

    I am getting an error on stream.next() as highlighted. I am prompted to
    add a cast to stream, however I then am faced with the problem of which
    object to pass... which I do not know.
    while ((token = ((Object) stream).next()) != null)

    Thank you
    Lewis


    Glasgow Caledonian University is a registered Scottish charity, number SC021474
    Winner: Times Higher Education's Widening Participation Initiative of
    the Year 2009 and Herald Society's Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,
    en.html
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

    Email has been scanned for viruses by Altman Technologies' email
    management service - www.altman.co.uk/emailsystems

    Glasgow Caledonian University is a registered Scottish charity, number
    SC021474

    Winner: Times Higher Education’s Widening Participation Initiative of the
    Year 2009 and Herald Society’s Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,
    en.html
    Email has been scanned for viruses by Altman Technologies' email management service - www.altman.co.uk/emailsystems

    Glasgow Caledonian University is a registered Scottish charity, number SC021474

    Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009
    http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedDec 2, '10 at 3:27p
activeDec 2, '10 at 4:58p
posts5
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase