1 |
|
/* ============================================================================ |
2 |
|
* Douglas Thrift's Search Engine License |
3 |
|
* |
4 |
< |
* Copyright (C) 2002, Douglas Thrift. All Rights Reserved. |
4 |
> |
* Copyright (C) 2002-2004, Douglas Thrift. All Rights Reserved. |
5 |
|
* Redistribution and use in source and binary forms, with or without |
6 |
|
* modification, are permitted provided that the following conditions are met: |
7 |
|
* |
46 |
|
// |
47 |
|
// Douglas Thrift |
48 |
|
// |
49 |
< |
// Ranker.h |
49 |
> |
// $Id$ |
50 |
|
|
51 |
< |
#ifndef _Ranker_h_ |
52 |
< |
#define _Ranker_h_ |
51 |
> |
#ifndef _Ranker_hpp_ |
52 |
> |
#define _Ranker_hpp_ |
53 |
|
|
54 |
< |
#include "Search.h" |
55 |
< |
#include "Page.h" |
54 |
> |
#include "Search.hpp" |
55 |
> |
#include "Page.hpp" |
56 |
|
|
57 |
|
class Ranker : public Page |
58 |
|
{ |
59 |
|
private: |
60 |
|
enum state { all, title, url, text }; |
61 |
+ |
enum { sampleMax = 160 }; |
62 |
|
string sample; |
63 |
|
map<unsigned, unsigned> occurrencesTitle; |
64 |
|
map<unsigned, unsigned> occurrencesDescription; |
80 |
|
void checkRequired(); |
81 |
|
void checkExcluded(); |
82 |
|
void checkEitherOr(); |
83 |
< |
unsigned find(string& word, string& where); |
84 |
< |
unsigned find(string& word, string& where, map<unsigned, unsigned>& |
83 |
> |
unsigned find(string word, const string& where); |
84 |
> |
unsigned find(string word, const string& where, map<unsigned, unsigned>& |
85 |
|
occurrences); |
86 |
< |
unsigned phrase(string& phrase, string& where); |
87 |
< |
unsigned phrase(string& phrase, string& where, map<unsigned, unsigned>& |
86 |
> |
unsigned phrase(const string& phrase, const string& where); |
87 |
> |
unsigned phrase(const string& phrase, const string& where, map<unsigned, |
88 |
> |
unsigned>& occurrences); |
89 |
> |
unsigned phrase(const vector<string>& words, unsigned word, unsigned& |
90 |
> |
begin, bool start, const string& where); |
91 |
> |
unsigned phrase(const vector<string>& words, unsigned word, unsigned& |
92 |
> |
begin, bool start, const string& where, map<unsigned, unsigned>& |
93 |
|
occurrences); |
88 |
– |
unsigned phrase(vector<string>& words, unsigned word, unsigned& begin, bool |
89 |
– |
start, string& where); |
90 |
– |
unsigned phrase(vector<string>& words, unsigned word, unsigned& begin, bool |
91 |
– |
start, string& where, map<unsigned, unsigned>& occurrences); |
94 |
|
unsigned evaluate(vector<unsigned>& ins); |
95 |
|
void decrap(string& crap); |
96 |
|
public: |
95 |
– |
Ranker(); |
97 |
|
Ranker(Page& page); |
98 |
|
~Ranker() {} |
99 |
|
void rank(vector<string> query); |
100 |
|
void setSample(); |
101 |
|
string getTitle(); |
102 |
|
string getDescription(); |
103 |
< |
string getSample() { return sample; } |
103 |
> |
string& getSample() { return sample; } |
104 |
|
bool operator==(const unsigned number) const; |
105 |
|
bool operator==(const Ranker& ranker) const; |
106 |
|
bool operator!=(const unsigned number) const; |