These are chat archives for Humanizr/Humanizer

18th
Mar 2016
Joseph Musser
@jnm2
Mar 18 2016 14:15
@chadsowald Doesn't it do that by default?
Or do you mean you want to toggle the pluralization to the opposite of whatever it is?
chadsowald
@chadsowald
Mar 18 2016 16:52
@jnm2 Yes, to your second option. I want to toggle to the opposite without knowing what it starts as.
or at least try to
chadsowald
@chadsowald
Mar 18 2016 16:57
Thank you. I'm used to the .NET PluralizationService that offers both an IsPlural(word) and IsSingular(word) method to check.
It looks like passing inputIsKnownToBePlural = false might do the trick.
Joseph Musser
@jnm2
Mar 18 2016 17:03
The way it deals with not knowing is to try to both pluralize and singularize. I'm really not sure what the logic is behind that if statement though. You could do something similar:
var tryPlural = word.Pluralize();
var wordWithToggledPlurality = tryPlural == word ? word.Singularize() : tryPlural;
Joseph Musser
@jnm2
Mar 18 2016 17:35
Tbh IsPlural and IsSingular give the illusion that a word can't be both. It can.
if (word == word.Pluralize())
{
    return word == word.Singularize() ? Plurality.Ambiguous : Plurality.Plural;
}
else
{
    return word == word.Singularize() ? Plurality.Singular : Plurality.Ambiguous;
}
chadsowald
@chadsowald
Mar 18 2016 19:44
Thank you and sorry for the delay writing back. It might be nice if something like this got into the Humanizer library rather than maintaining it myself. The reason being that it's odd to have to pick .Pluralize or .Singularize to start with. It would worry me that I should perhaps be calling the other method first. How am I to know if it matters?
Joseph Musser
@jnm2
Mar 18 2016 20:07
@chadsowald not a problem, it's chat. I agree that it would be nice to know whether a word is strictly singular, strictly plural, or ambiguous (ask here), but I can't imagine a case where I personally would use it.

How am I to know if it matters?

Every time I have used Humanizer, I know the word(s) at compile time. Or I'm humanizing a type name (always singular) and sending it through. I think that's the typical use case. I can't speak for the Humanizer team but my perception was that this library isn't intended to be used for advanced linguistics, just to make computer-human interactions a bit more polished.

chadsowald
@chadsowald
Mar 18 2016 20:12

Yeah, that makes sense. We currently use the .NET PluraizationService to help with name suggestion. We're trying to "spin" various names based on whatever a user inputs and, of course, we don't know if they enter singular or plural word(s).

I'm also interested in finding, if possible, a dictionary of words and their plurals to test the .NET implementation vs. Humanizer or other libraries to see if I should prefer one over the other.

After finding the library, I do intend to use it for other things, such as those you mentioned rather than just these more advanced linguistic tasks.

Joseph Musser
@jnm2
Mar 18 2016 20:15
The reason why it doesn't matter if you try .Pluralize() or .Singularize() first is that either way if the word changes, you know it toggled and return it. Otherwise, you try the other one and return it. If neither operation changed it, it's ambiguous.
It's just a bit strange because simply toggling the plurality without caring about the plurality of the result is a very odd thing to do. I think.
chadsowald
@chadsowald
Mar 18 2016 20:18
True, but what if Pluralize incorrectly pluralizes a word (so it changes), but Singularize might have actually been the right thing to do first (and would have worked properly)?
Joseph Musser
@jnm2
Mar 18 2016 20:18
Ah, that's why you use the parameter indicating that you don't know the plurality.
If you try to pluralize children and the pluralizer incorrectly generates childrens (I don't know if this happens or not), the inputIsKnownToBeSingular parameter causes Humanizer to check itself.
chadsowald
@chadsowald
Mar 18 2016 20:24
I see.
alright... well I still need to test both libraries against a large list of words to see how they do. I think with either library I'll have to add a good number of manual corrections.
Joseph Musser
@jnm2
Mar 18 2016 20:26
What it does is try singularizing your original input children and it gets child. Since that is different, it pluralizes child and gets children. If the singularized-then-pluralized word matches the input word (it does) it returns the input word.
I can understand wanting both singular and plural and knowing which is which, but I'm still really curious why you don't care about the resulting plurality.
Take a look at the pluralization test cases.
Joseph Musser
@jnm2
Mar 18 2016 20:31
I would be thrilled and I'm sure the team would be happy if you added the vocabulary you're checking against in a PR. Please do that! :smile:
chadsowald
@chadsowald
Mar 18 2016 20:40
absolutely!
thanks again
Joseph Musser
@jnm2
Mar 18 2016 20:58
@chadsowald now what's hilarious is when ReSharper suggests the name eventArgses :D
chadsowald
@chadsowald
Mar 18 2016 20:59
yikes!