On Mon, 31 Jan 2000, Gilles Detillieux wrote:

> code in htsearch/parser.cc just seems wrong to me...
> 
> 
>           dm->score = (wr->Flags() & FLAG_TEXT) * config.Double("text_factor", 1);
>           dm->score += (wr->Flags() & FLAG_CAPITAL) * config.Double("caps_factor", 
>1);
>           dm->score += (wr->Flags() & FLAG_TITLE) * config.Double("title_factor", 1);
>           dm->score += (wr->Flags() & FLAG_HEADING) * 
>config.Double("heading_factor", 1);
>           dm->score += (wr->Flags() & FLAG_KEYWORDS) * 
>config.Double("keywords_factor", 1);
>           dm->score += (wr->Flags() & FLAG_DESCRIPTION) * 
>config.Double("meta_description_factor", 1);
>           dm->score += (wr->Flags() & FLAG_AUTHOR) * config.Double("author_factor", 
>1);
>           dm->score += (wr->Flags() & FLAG_LINK_TEXT) * 
>config.Double("description_factor", 1);
> 
> First of all, it stikes me as odd that this code is duplicated in the else
> clase of the if statement, and inefficient that all the factors are looked
> up and converted for each and every word reference that gets scored.

It is inefficient for both reasons. I wrote this on deadline about 3AM.
I'll clean it up a bit, or if you want to do it, feel free. It was even
worse a few days ago, when it was multiplying by config.Value, which
returns integers...

> are to represent bit masks, none of them should be 0.  Or, if you want
> the default value (no bits set) to indicate text words, the test should
> be more like (wr->Flags() == FLAG_TEXT).

Correct, this was my intent.

> like ((wr->Flags() & FLAG_LINK_TEXT) != 0) would do?  I'd make the changes
> and commit them myself, but at this stage I'd like a second opinion in
> case I'm misreading something.

No, I think I never bothered to think through this code, even this weekend
when switching config.Value to config.Double.

> I'm also a bit unsure about what's allowed in C++.  Apparently, the
> ternary (x ? y : z) operator isn't supposed to be used, judging by the
> response when I did use this, so I'm wondering whether something like
> (x == y) or (x != y) is guaranteed to be 0 or 1 in C++, as it is in C.

The ternary operator is fine, but I personally prefer to see it written
out--I think it's easier to follow as if .. then.. else.

-Geoff


------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] 
You will receive a message to confirm this. 

Reply via email to