searchengine/oss/cl/clucene/src/clucene/highlighter/SimpleHTMLFormatter.cpp
changeset 7 a5fbfefd615f
child 15 cf5c74390b98
equal deleted inserted replaced
3:ae3f1779f6da 7:a5fbfefd615f
       
     1 #include "CLucene/StdHeader.h"
       
     2 #include "SimpleHTMLFormatter.h"
       
     3 
       
     4 
       
     5 CL_NS_DEF2(search,highlight)
       
     6 CL_NS_USE(util)
       
     7 
       
     8 SimpleHTMLFormatter::SimpleHTMLFormatter(const TCHAR* preTag, const TCHAR* postTag):
       
     9 	_preTag(stringDuplicate(preTag)),
       
    10 	_postTag(stringDuplicate(postTag))
       
    11 {
       
    12 }
       
    13 
       
    14 SimpleHTMLFormatter::SimpleHTMLFormatter()
       
    15 {
       
    16 	_preTag = stringDuplicate(_T("<B>"));
       
    17 	_postTag = stringDuplicate(_T("</B>"));
       
    18 }
       
    19 
       
    20 SimpleHTMLFormatter::~SimpleHTMLFormatter() 
       
    21 {
       
    22 	_CLDELETE_CARRAY(_preTag);
       
    23 	_CLDELETE_CARRAY(_postTag);
       
    24 }
       
    25 
       
    26 TCHAR* SimpleHTMLFormatter::highlightTerm(const TCHAR* originalText, const TokenGroup* tokenGroup)
       
    27 {
       
    28 	if(tokenGroup->getTotalScore()>0){
       
    29 		StringBuffer sb;
       
    30 		sb.append(_preTag);
       
    31 		sb.append(originalText);
       
    32 		sb.append(_postTag);
       
    33 		return sb.toString();
       
    34 	}
       
    35 	return stringDuplicate(originalText);
       
    36 }
       
    37 
       
    38 CL_NS_END2