Knowledgebase Home Page  >  SearchUnit
Search the Knowledge Base
Modifying meta tag word weight
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=196&catId=54

Options

Print this page
Email this to a friend
This article is an extension of the article at http://keyoti.com/kb/Default.aspx?ToDo=view&questId=190 which must be followed first to implement meta-tag searching.  Make the changes described below, or use the attached classes which are already changed.
 
 
 
1. Modify ExtendedHtmlDocumentParser, by adding this to the class
 

public static string keywordStartMark = "@#$", keywordEndMark = "$#@", descStartMark = "$%^", descEndMark = "^%$";

 
 
2. Then change this part of ReadText, add the parts in bold
 

if (_metaTable["keywords"] != null)

{

modWriter.Write(keywordStartMark);

modWriter.Write(_metaTable["keywords"].ToString());

modWriter.Write(keywordEndMark);

Keyoti.SearchEngine.DataAccess.Log.WriteLogEntry("Plug-in", "Meta keywords:" + _metaTable["keywords"].ToString(), Configuration);

}

if (_metaTable["description"] != null)

{

modWriter.Write(descStartMark);

modWriter.Write(_metaTable["description"].ToString());

modWriter.Write(descEndMark);

Keyoti.SearchEngine.DataAccess.Log.WriteLogEntry("Plug-in", "Meta description:" + _metaTable["description"].ToString(), Configuration);

}

 
 
this will mark the fields for use later.
 
 
 
3. In ExternalEventHandler, you want to modify the dispatcher_Action event handler to
 

public void dispatcher_Action(object sender, ActionEventArgs e)

{

if (e.ActionData.Name == ActionName.CalculateWordRelevancies)

{

WordCollection words = e.ActionData.Data as WordCollection;

bool inKeywords=false, inDescription=false;

for (int i = 0; i < words.Count; i++)

{

if (words[i].WordContent.Contains(Plugin.ExtendedHtmlDocumentParser.keywordStartMark))

inKeywords = true;

if (words[i].WordContent.Contains(Plugin.ExtendedHtmlDocumentParser.keywordEndMark))

inKeywords = false;

if (words[i].WordContent.Contains(Plugin.ExtendedHtmlDocumentParser.descStartMark))

inDescription = true;

if (words[i].WordContent.Contains(Plugin.ExtendedHtmlDocumentParser.descEndMark))

inDescription = false;

if (inKeywords || inDescription)

{

words[i].Weight *= 5;

Keyoti.SearchEngine.DataAccess.Log.WriteLogEntry("Plug-in", "Modified weight of "+words[i].WordContent+" to "+words[i].Weight, conf);

}

}

}

}

 
This multiplies the weight meta tag words by 5.  To verify this works see the logging.  You might want to use more than "5", because that means that one occurrence of a word in the meta tag is equal to 5 occurrences of the words in the body. 

Related Questions:

Attachments: