7ec58b2000-10-26Johan Schön // Roxen Whitefish main pike module
5f4e122000-05-15Martin Nilsson //
ca4c382001-05-17Johan Schön // Copyright © 2000,2001 Roxen IS.
5f4e122000-05-15Martin Nilsson 
ca4c382001-05-17Johan Schön private mapping filters; // void create() // { // foreach(values(Search.Filter), program filter) // { // Search.Filter.Base tmp=filter(); // foreach(tmp->contenttypes || ({ }), string mime) // filters[mime]=tmp; // } // } private void get_filters()
7ec58b2000-10-26Johan Schön {
ca4c382001-05-17Johan Schön  filters=([]); foreach(values(Search.Filter), object filter) foreach(filter->contenttypes || ({ }), string mime) filters[mime]=filter;
5f4e122000-05-15Martin Nilsson }
78fadb2000-11-30Johan Schön Search.Filter.Base get_filter(string mime_type)
7ec58b2000-10-26Johan Schön {
ca4c382001-05-17Johan Schön  if(!filters) get_filters();
5f4e122000-05-15Martin Nilsson  if(!filters[mime_type]) return 0;
78fadb2000-11-30Johan Schön  return filters[mime_type];
5f4e122000-05-15Martin Nilsson }
ca4c382001-05-17Johan Schön mapping(string:Search.Filter.Base) get_filter_mime_types()
7ec58b2000-10-26Johan Schön {
ca4c382001-05-17Johan Schön  if(!filters) get_filters(); return filters;
5f4e122000-05-15Martin Nilsson }
6b3def2000-10-27Martin Nilsson  // --- Page Ranking Algorithms ------------ float entropy(array(string) page_words) { mapping(string:int) words=([]); foreach(page_words, string word) words[word]=1; return (float)sizeof(words)/(float)sizeof(page_words); }
e1d7152000-11-24Johan Schön 
6b3def2000-10-27Martin Nilsson // A normal page has an entropy value around 0.5, so the result x should probably be // remapped to abs(x-0.5) or even 1-abs(x-0.5)