applets/wiktionary.pl: show disambiguation when word is not found

Requires latest version of https://github.com/pragma-/WiktionaryParser
This commit is contained in:
Pragmatic Software 2024-06-08 14:24:20 -07:00
parent da75397b51
commit 0786ee03a3
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 19 additions and 6 deletions

23
applets/wiktionary.pl vendored
View File

@ -105,11 +105,6 @@ if ($ENV{DEBUG}) {
print Dumper($entries), "\n";
}
if (@$entries && ref $entries->[0] ne 'HASH') {
print "No entry for `$term` found in $lang; entries found in ", (join ', ', @$entries), "\n";
exit;
}
my @valid_sections = qw/definitions etymology pronunciations participle/;
if (not grep { $_ eq $section } @valid_sections) {
@ -119,6 +114,24 @@ if (not grep { $_ eq $section } @valid_sections) {
my $entries_text = $section;
if (ref $entries eq 'HASH') {
$entries_text =~ s/y$/ies/;
print "No $entries_text for `$term`";
if ($entries->{languages}->@*) {
print " in $lang; try ", (join ', ', $entries->{languages}->@*);
} else {
print " found in any languages";
}
if ($entries->{disambig}->@*) {
print "; see also: ", (join ', ', $entries->{disambig}->@*);
}
print "\n";
exit;
}
my $total_entries_count = @$entries;
if ($total_entries_count == 0) {

View File

@ -25,7 +25,7 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4759,
BUILD_REVISION => 4760,
BUILD_DATE => "2024-06-08",
};