3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-27 13:12:42 +01:00

Factoids: Selectors now fix leading indefinite articles; i.e. a %(orange) -> an orange

This commit is contained in:
Pragmatic Software 2020-06-10 23:06:08 -07:00
parent 51f2c1ffd9
commit af7573a20a

View File

@ -687,7 +687,16 @@ sub expand_factoid_selectors {
last if not length $extracted;
$result .= $self->select_item($context, $extracted, \$rest, %opts);
my $item = $self->select_item($context, $extracted, \$rest, %opts);
if ($result =~ s/\b(a|an)(\s+)$//i) {
my ($article, $trailing) = ($1, $2);
my $fixed_article = select_indefinite_article $item;
$fixed_article = ucfirst $fixed_article if $article =~ m/^A/;
$item = $fixed_article . $trailing . $item;
}
$result .= $item;
$action = $rest;
}