mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-18 06:20:41 +01:00
Revert "FuncBuiltins: maybe-the: do it for all words"
This reverts commit 7093fa0ae4a81fe8cc6fd8ff4a4d2e832f024db0.
This commit is contained in:
parent
7093fa0ae4
commit
e656fb46cf
@ -76,7 +76,7 @@ sub initialize {
|
|||||||
$self->{pbot}->{functions}->register(
|
$self->{pbot}->{functions}->register(
|
||||||
'maybe-the',
|
'maybe-the',
|
||||||
{
|
{
|
||||||
desc => 'prepend "the" in front of words depending on their part-of-speech',
|
desc => 'prepend "the" in front of text depending on the part-of-speech of the first word in text',
|
||||||
usage => 'maybe-the <text>',
|
usage => 'maybe-the <text>',
|
||||||
subref => sub { $self->func_maybe_the(@_) }
|
subref => sub { $self->func_maybe_the(@_) }
|
||||||
}
|
}
|
||||||
@ -169,35 +169,26 @@ sub func_ana {
|
|||||||
sub func_maybe_the {
|
sub func_maybe_the {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $text = "@_";
|
my $text = "@_";
|
||||||
my @words = split ' ', $text;
|
|
||||||
my @result;
|
|
||||||
|
|
||||||
foreach my $part (@words) {
|
my ($word) = $text =~ m/^\s*([^',.;: ]+)/;
|
||||||
my ($word) = $part =~ m/^\s*([^',.;: ]+)/;
|
|
||||||
|
|
||||||
# don't prepend "the" if a proper-noun nick follows
|
# don't prepend "the" if a proper-noun nick follows
|
||||||
if ($self->{pbot}->{nicklist}->is_present_any_channel($word)) {
|
if ($self->{pbot}->{nicklist}->is_present_any_channel($word)) {
|
||||||
push @result, $part;
|
return $text;
|
||||||
next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# special-case some indefinite nouns that Lingua::EN::Tagger treats as plain nouns
|
# special-case some indefinite nouns that Lingua::EN::Tagger treats as plain nouns
|
||||||
if ($word =~ m/(some|any|every|no)(thing|one|body|how|way|where|when|time|place)/i) {
|
if ($word =~ m/(some|any|every|no)(thing|one|body|how|way|where|when|time|place)/i) {
|
||||||
push @result, $part;
|
return $text;
|
||||||
next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $tagged = $self->{tagger}->add_tags($word);
|
my $tagged = $self->{tagger}->add_tags($word);
|
||||||
|
|
||||||
if ($tagged !~ m/^\s*<(?:det|prps?|cd|in|nnp|to|rb|wdt|rbr|jjr)>/) {
|
if ($tagged !~ m/^\s*<(?:det|prps?|cd|in|nnp|to|rb|wdt|rbr|jjr)>/) {
|
||||||
push @result, "the $part";
|
$text = "the $text";
|
||||||
next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
push @result, $part;
|
return $text;
|
||||||
}
|
|
||||||
|
|
||||||
return join ' ', @result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4562,
|
BUILD_REVISION => 4561,
|
||||||
BUILD_DATE => "2022-08-03",
|
BUILD_DATE => "2022-08-03",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user