46 |
|
// |
47 |
|
// Douglas Thrift |
48 |
|
// |
49 |
< |
// $Id: Ranker.cpp,v 1.5 2003/07/11 07:54:47 douglas Exp $ |
49 |
> |
// $Id: Ranker.cpp,v 1.6 2003/07/20 01:46:12 douglas Exp $ |
50 |
|
|
51 |
|
#include "Ranker.h" |
52 |
|
|
435 |
|
|
436 |
|
void Ranker::rank() |
437 |
|
{ |
438 |
< |
lowerAddress = string(getAddress().length(), ' '); |
439 |
< |
for (unsigned index = 0; index < lowerAddress.length(); index++) |
440 |
< |
{ |
441 |
< |
lowerAddress[index] = tolower(getAddress()[index]); |
442 |
< |
} |
438 |
> |
lowerAddress = tolower(getAddress()); |
439 |
|
|
440 |
|
if (site == "" || lowerAddress.rfind(site) == lowerAddress.length() - |
441 |
|
site.length()) |
444 |
|
bool isExcluded = excluded.size() > 0; |
445 |
|
bool isEitherOr = eitherOr.size() > 0; |
446 |
|
|
447 |
< |
lowerURL = string(getURL().length(), ' '); |
448 |
< |
for (unsigned index = 0; index < lowerURL.length(); index++) |
449 |
< |
{ |
454 |
< |
lowerURL[index] = tolower(getURL()[index]); |
455 |
< |
} |
456 |
< |
|
457 |
< |
lowerTitle = string(Page::getTitle().length(), ' '); |
458 |
< |
for (unsigned index0 = 0; index0 < lowerTitle.length(); index0++) |
459 |
< |
{ |
460 |
< |
lowerTitle[index0] = tolower(Page::getTitle()[index0]); |
461 |
< |
} |
462 |
< |
|
463 |
< |
lowerText = string(Page::getText().length(), ' '); |
464 |
< |
for (unsigned index1 = 0; index1 < lowerText.length(); index1++) |
465 |
< |
{ |
466 |
< |
lowerText[index1] = tolower(Page::getText()[index1]); |
467 |
< |
} |
447 |
> |
lowerURL = tolower(getURL()); |
448 |
> |
lowerTitle = tolower(Page::getTitle()); |
449 |
> |
lowerText = tolower(Page::getText()); |
450 |
|
|
451 |
|
if (isRequired) checkRequired(); |
452 |
|
if (isExcluded && (isRequired || isEitherOr)) checkExcluded(); |
485 |
|
|
486 |
|
if (value > 0) |
487 |
|
{ |
488 |
< |
string lowerDescription = string(Page::getDescription().length(), |
507 |
< |
' '); |
508 |
< |
for (unsigned index = 0; index < lowerDescription.length(); index++) |
509 |
< |
{ |
510 |
< |
lowerDescription[index] = tolower( |
511 |
< |
Page::getDescription()[index]); |
512 |
< |
} |
488 |
> |
string lowerDescription = tolower(Page::getDescription()); |
489 |
|
|
490 |
< |
for (unsigned index0 = 0; index0 < required.size(); index0++) |
490 |
> |
for (unsigned index = 0; index < required.size(); index++) |
491 |
|
{ |
492 |
< |
if (required[index0].find("URL ") == 0) |
492 |
> |
if (required[index].find("URL ") == 0) |
493 |
|
{ |
494 |
< |
value += find(required[index0].substr(4), lowerDescription, |
494 |
> |
value += find(required[index].substr(4), lowerDescription, |
495 |
|
occurrencesDescription); |
496 |
|
} |
497 |
< |
else if (required[index0].find("TITLE ") == 0) |
497 |
> |
else if (required[index].find("TITLE ") == 0) |
498 |
|
{ |
499 |
< |
value += find(required[index0].substr(6), lowerDescription, |
499 |
> |
value += find(required[index].substr(6), lowerDescription, |
500 |
|
occurrencesDescription); |
501 |
|
} |
502 |
< |
else if (required[index0].find("TEXT ") == 0) |
502 |
> |
else if (required[index].find("TEXT ") == 0) |
503 |
|
{ |
504 |
< |
value += find(required[index0].substr(5), lowerDescription, |
504 |
> |
value += find(required[index].substr(5), lowerDescription, |
505 |
|
occurrencesDescription); |
506 |
|
} |
507 |
|
else |
508 |
|
{ |
509 |
< |
value += find(required[index0], lowerDescription, |
509 |
> |
value += find(required[index], lowerDescription, |
510 |
|
occurrencesDescription); |
511 |
|
} |
512 |
|
} |