lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject RE: Using Highlighter in web Demo
Date Tue, 29 Jun 2004 13:57:00 GMT
It sounds like you don't have the Highligher Jar in your CLASSPATH at
compile-time.

1. Get Highlighter from CVS
2. Build a Jar using Ant and Highligher's build.xml
3. Add the resulting Jar to CLASSPATH
4. Compile your code (the one that imports QueryScorer)

That should work.

Otis


--- Karthik N S <karthik@controlnet.co.in> wrote:
> Hi
> Otis
> 
> I am not able to compile the Code because the import statement for
> the below
> is not avaliable in the API
> QueryScorer scorer = new QueryScorer(query);
> 
> 
> 
> with regards
> Karthik
> 
> 
> -----Original Message-----
> From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com]
> Sent: Tuesday, June 29, 2004 6:55 PM
> To: Lucene Users List
> Subject: Re: Using Highlighter in web Demo
> 
> 
> Karthik, I don't understand your question.
> Sorting was only added in 1.4* versions, if I recall correctly. 
> There
> was no sorting in 1.3.
> 
> Otis
> 
> 
> --- Karthik N S <karthik@controlnet.co.in> wrote:
> >
> > Hello Developer's
> >
> >    I am NOT able to get the API for the same [1.3-final or 1.4rc4 ]
> > for
> > import  details.
> >     QueryScorer scorer = new QueryScorer(query);
> >
> >
> > just was curious to Compile and execute the same...:)
> >
> >
> >
> > Karthik
> >
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> > Sent: Tuesday, June 29, 2004 5:52 PM
> > To: Lucene Users List
> > Subject: Re: Using Highlighter in web Demo
> >
> >
> > On Jun 28, 2004, at 5:18 PM, Hetan Shah wrote:
> > > Is it possible to use highlighter successfully in the demos the
> web
> > > demo to be specific. Has any one tried out there? If so can they
> > > explain me how to go about it any code sample is really  very
> > > appreciated.
> >
> > Straight from Lucene in Action:
> >
> > public class HighlightIt {
> >    private static final String text =
> >        "Contrary to popular belief, Lorem Ipsum is" +
> >        " not simply random text. It has roots in a piece of" +
> >        " classical Latin literature from 45 BC, making it over" +
> >        " 2000 years old. Richard McClintock, a Latin professor" +
> >        " at Hampden-Sydney College in Virginia, looked up one" +
> >        " of the more obscure Latin words, consectetur, from" +
> >        " a Lorem Ipsum passage, and going through the cites" +
> >        " of the word in classical literature, discovered the" +
> >        " undoubtable source. Lorem Ipsum comes from sections" +
> >        " 1.10.32 and 1.10.33 of \"de Finibus Bonorum et" +
> >        " Malorum\" (The Extremes of Good and Evil) by Cicero," +
> >        " written in 45 BC. This book is a treatise on the" +
> >        " theory of ethics, very popular during the" +
> >        " Renaissance. The first line of Lorem Ipsum, \"Lorem" +
> >        " ipsum dolor sit amet..\", comes from a line in" +
> >        " section 1.10.32.";  // from http://www.lipsum.com/
> >
> >    public static void main(String[] args) throws IOException {
> >      String filename = args[0];
> >
> >      if (filename == null) {
> >        System.err.println("Usage: HighlightIt <filename>");
> >        System.exit(-1);
> >      }
> >
> > //    TermQuery query = new TermQuery(new Term("f", "ipsum"));
> >      PhraseQuery query = new PhraseQuery();
> >      query.add(new Term("f", "lorem"));
> >      query.add(new Term("f", "ipsum"));
> >      QueryScorer scorer = new QueryScorer(query);
> >      SimpleHTMLFormatter formatter =
> >          new SimpleHTMLFormatter("<span class=\"highlight\">",
> >              "</span>");
> >      Highlighter highlighter = new Highlighter(formatter, scorer);
> >      Fragmenter fragmenter = new SimpleFragmenter(50);
> >      highlighter.setTextFragmenter(fragmenter);
> >
> >      TokenStream tokenStream = new StandardAnalyzer()
> >          .tokenStream("f", new StringReader(text));
> >
> >      String result =
> >          highlighter.getBestFragments(tokenStream, text, 5, "...");
> >
> >      FileWriter writer = new FileWriter(filename);
> >      writer.write("<html>");
> >      writer.write("<style>\n" +
> >          ".highlight {\n" +
> >          " background: yellow;\n" +
> >          "}\n" +
> >          "</style>");
> >      writer.write("<body>");
> >      writer.write(result);
> >      writer.write("</body></html>");
> >      writer.close();
> >    }
> > }
> >
> > I just added the PhraseQuery in there instead of the TermQuery that
> > is
> > commented out.  Highlighter works well with phrases also (although
> > highlights each term individually, not the breadth of the phrase by
> > itself).  The above code runs like it says in the usage statement,
> > give
> > it a filename to save an HTML file that shows the terms highlighted
> > in
> > yellow.
> >
> > 	Erik
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> lucene-user-help@jakarta.apache.org
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> lucene-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message