mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-16 00:49:35 +01:00
applets/wiktionary.pl: show disambiguation when word is not found
Requires latest version of https://github.com/pragma-/WiktionaryParser
This commit is contained in:
parent
da75397b51
commit
0786ee03a3
23
applets/wiktionary.pl
vendored
23
applets/wiktionary.pl
vendored
@ -105,11 +105,6 @@ if ($ENV{DEBUG}) {
|
|||||||
print Dumper($entries), "\n";
|
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/;
|
my @valid_sections = qw/definitions etymology pronunciations participle/;
|
||||||
|
|
||||||
if (not grep { $_ eq $section } @valid_sections) {
|
if (not grep { $_ eq $section } @valid_sections) {
|
||||||
@ -119,6 +114,24 @@ if (not grep { $_ eq $section } @valid_sections) {
|
|||||||
|
|
||||||
my $entries_text = $section;
|
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;
|
my $total_entries_count = @$entries;
|
||||||
|
|
||||||
if ($total_entries_count == 0) {
|
if ($total_entries_count == 0) {
|
||||||
|
@ -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 => 4759,
|
BUILD_REVISION => 4760,
|
||||||
BUILD_DATE => "2024-06-08",
|
BUILD_DATE => "2024-06-08",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user