lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Feldmann <anton.feldm...@uni-bielefeld.de>
Subject SentenceHighlighter
Date Wed, 19 Apr 2006 13:08:11 GMT
Hi

I am writing a application to find words into a sentence.
I began with the Formatter:


import org.apache.lucene.search.highlight.Formatter;
import org.apache.lucene.search.highlight.TokenGroup;


public class SimpleSentenceFormatter implements Formatter{

	String tag;

	/**
	 *Use a String to mark the sentence 
	 */
	public SimpleSentenceFormatter(String Tag) {
		this.tag = tag;
	}

	/**
	 * Default constructor uses "\\.x\\" to mark a Sentence 
	 */
	public SimpleSentenceFormatter() {
		this.tag = "\\.x\\"; //("\\.x\\") instead DOT
	}

	/* (non-Javadoc)
	 * @see
org.apache.lucene.search.highlight.Formatter#highlightTerm(java.lang.String, org.apache.lucene.search.highlight.TokenGroup)
	 */
	public String highlightTerm(String originalText, TokenGroup tokenGroup)
{
		StringBuffer returnBuffer;
		if ( tokenGroup.getTotalScore() > 0 ) {
			returnBuffer = new StringBuffer();
			returnBuffer.append(tag);
			returnBuffer.append(originalText);
			returnBuffer.append(tag);
			return returnBuffer.toString();
		}
		return originalText;
	}
	
	public String getTag(){
		return tag;
	}

}

Now i am Writing a Highlighter. But I have know i dear how i could
display the howl sentens which includes the querry string. Do some of
you have an Idear?

cheers

anton



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


Mime
View raw message