Measuring weight for a word on a page
Code for calculation weight for a word in its context on a page. This code is from Sphider project.
<?php
// Relative weight of a word in the title of a webpage
$title_weight = 20;
// Relative weight of a word in the domain name
$domain_weight = 60;
// Relative weight of a word in the path name
$path_weight = 10;
// Relative weight of a word in meta_keywords
$meta_weight = 5;
function calc_weight ($words_in_page, $word_in_title, $word_in_domain, $word_in_path, $path_depth, $meta_keyword) {
global $title_weight, $domain_weight, $path_weight,$meta_weight;
$weight = ($words_in_page + $word_in_title * $title_weight +
$word_in_domain * $domain_weight +
$word_in_path * $path_weight + $meta_keyword * $meta_weight) *10 / (0.8 +0.2*$path_depth);
return $weight;
}
?>
Source: Sphider project http://www.sphider.eu/