I have a table called "device_criteria". Even with naming => { ALL => 'v8', force_ascii => 1 } in my config file, I end up with a source called DeviceCriteria, not DeviceCriterion.
this looks to be the root problem:
perl -MLingua::EN::Inflect::Phrase -wle'print Lingua::EN::Inflect::Phrase::to_S("device_criteria");'
-> device_criteria
I guess some splitting into words is required first?
From ilmari+cpan@ilmari.org on 2018-07-26 10:16:47
:
"Karen Etheridge via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org>
writes:
> I have a table called "device_criteria". Even with naming => { ALL => 'v8', force_ascii => 1 }
> in my config file, I end up with a source called DeviceCriteria, not DeviceCriterion.
>
> this looks to be the root problem:
>
> perl -MLingua::EN::Inflect::Phrase -wle'print Lingua::EN::Inflect::Phrase::to_S("device_criteria");'
> -> device_criteria
>
> I guess some splitting into words is required first?
That wouldn't help, Lingua::EN::Inflect::Phrase doesn't handle "criteria" on its own either.
$ perl -MLingua::EN::Inflect::Phrase -wle'print Lingua::EN::Inflect::Phrase::to_S("criteria");'
criteria
The underlying problem seems to be that Lingua::EN::Inflect::Number
thinks 'criteria' is already singular:
$ perl -MLingua::EN::Inflect::Number=number -E 'say number "criteria"'
s
I think this all stems from the fact hat Lingua::EN::Inflect::Number
abuses Lingua::EN::Inflect::PL() to convert to _singular_, which is
documented as "undefined (and unlikely to be correct)", the comment in
to_S() even says "I don't know why this works, but it seems to."
Lingua::EN::Inflect does know to pluralise "criterion" to "criteria",
but the usual (accidental?) behaviour of PL() singularising already-plural
words doesn't seem to apply to it (or other "ion" -> "a" words like "aphelion").
Lingua::EN::Inflect::Phrase does have a bunch of special cases, I guess this
could be added there.
-ilmari
From ether@cpan.org on 2018-07-26 15:22:31
:
Is this being rejected because (seemingly) Lingua::* doesn't know how to handle this word?
On 2018-07-26 03:16:47, ilmari wrote:
> > I guess some splitting into words is required first?
>
> That wouldn't help, Lingua::EN::Inflect::Phrase doesn't handle
> "criteria" on its own either.
This works (and indeed is what I'm doing elsewhere in the codebase:
use Lingua::EN::Inflexion 'noun';
my $table_name = 'device_criteria';
my @words = split('_', $table_name);
$words[-1] = noun($words[-1])->singular;
my $source = camelize(join('_', @words));
perl -MLingua::EN::Inflexion=noun -wle'print noun("criteria")->singular'
--> criterion
Migrated from rt.cpan.org#125930 (status was 'open')
Requestors:
From ether@cpan.org on 2018-07-25 16:39:52 :
From ilmari+cpan@ilmari.org on 2018-07-26 10:16:47 :
From ether@cpan.org on 2018-07-26 15:22:31 :