Skip to content

Commit

Permalink
Prefer shorter replies
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik committed May 4, 2011
1 parent 5142367 commit 851b8a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,8 @@ Revision history for Hailo

{{$NEXT}}

- Scored engine: Prefer shorter replies, like MegaHAL/cobe.

0.68 2011-05-03 13:16:05

- Speed up the learning of repetitive sentences by caching more
Expand Down
12 changes: 12 additions & 0 deletions lib/Hailo/Engine/Scored.pm
Expand Up @@ -172,6 +172,18 @@ sub _evaluate_reply {
}
}

# Prefer shorter replies. This behavior is present but not
# documented in recent MegaHAL.
my $score_divider = 1;
my $n_tokens = @$reply_token_ids;
if (@$reply_token_ids >= 8) {
$score_divider = sqrt(@$reply_token_ids - 1);
}
elsif (@$reply_token_ids >= 16) {
$score_divider = @$reply_token_ids;
}

$score = $score / $score_divider;
return $score;
}

Expand Down

0 comments on commit 851b8a6

Please sign in to comment.