From 9992119b11a1e88180c46d222ef9f9d9c2ee1fa1 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 9 Jun 2014 10:18:26 +0000 Subject: [PATCH] CGrammar: Improve enumeration translation --- PBot/VERSION.pm | 2 +- modules/c2english/CGrammar.pm | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 1bdf829a..d827b97c 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 622, + BUILD_REVISION => 623, BUILD_DATE => "2014-06-09", }; diff --git a/modules/c2english/CGrammar.pm b/modules/c2english/CGrammar.pm index c004f284..1b80c724 100644 --- a/modules/c2english/CGrammar.pm +++ b/modules/c2english/CGrammar.pm @@ -1137,7 +1137,7 @@ typedef_name: foreach (@defined_types) { if ($item{identifier} eq $_) { $answer = 1; - $return = ($item{identifier} =~ m/^[aeiouy]/ ? 'an ' : 'a ') . $item{identifier}; + $return = ($item{identifier} =~ m/^`[aeiouy]/ ? 'an ' : 'a ') . $item{identifier}; } } if (!$answer) { undef $answer; } @@ -1218,21 +1218,22 @@ enum_specifier: { $return .= 'an enumeration'; + if (@{$item{'identifier(?)'}}){ + $return .= ' of ' . join('',@{$item{'identifier(?)'}}); + } + my @enumerator_list = @{$item{enumerator_list}}; if(@enumerator_list == 1) { - $return .= " of $enumerator_list[0]"; + $return .= " comprising $enumerator_list[0]"; } else { my $last = pop @enumerator_list; - $return .= ' of ' . join(', ', @enumerator_list) . " and $last"; + $return .= ' comprising ' . join(', ', @enumerator_list) . " and $last"; } - if (@{$item{'identifier(?)'}}){ - $return .= ' identified as ' . join('',@{$item{'identifier(?)'}}); - } } | 'enum' identifier - { $return = ($item{identifer} =~ m/^[aieouy]/ ? 'an ' : 'a ') . "$item{identifier} enumeration"; } + { $return = "an enumeration of type $item{identifier}"; } enumerator_list: