These are chat archives for Humanizr/Humanizer

3rd
Jun 2016
Kevin Watkins
@MrKWatkins
Jun 03 2016 11:35
Hi. Firstly - great library, really good job!
Secondly - is there any way to add an exception for specific words to tell Humanizr not to change their capitalization? For example "RoboCopIsAGreatFilm".Humanize() would come out as "Robo cop is a great film". Is there a way to add "RoboCop" so it comes out as "RoboCop is a great film" instead?
Alois
@aloisdg
Jun 03 2016 12:34
I dunno, but you can use string.Replace("Robo cop", "RoboCop").
Joseph Musser
@jnm2
Jun 03 2016 12:51
@MrKWatkins No, there are no dictionaries involved in the string.Humanize() process. See https://github.com/Humanizr/Humanizer/blob/dev/src/Humanizer/StringHumanizeExtensions.cs#L27
However, your request is basically the same as mine (#404) where I want to keep 3D as 3D and not 3 d. @MehdiK said "if more users get behind this request, we'll implement it."
Kevin Watkins
@MrKWatkins
Jun 03 2016 13:49
@aloisdg Using string replace gets pretty messy in general:
  • Depending on the humanize options/method used I'd also need to replace "robo cop" and "Robo Cop".
  • I'd have to do that everywhere I used humanize. I could wrap that up in extension methods of course so not a massive pain but I'd still have to do that for every humanize method.
  • I have an annoying edge case where one of the words in another case also makes sense as the two separate words... I.e. so I have the two cases "robo cop".Humanize() and "RoboCop".Humanize(), which I'd like to become "Robo cop" and "RoboCop" respectively.
@jm2 I've added a comment to #404 adding my use case, thanks.
Joseph Musser
@jnm2
Jun 03 2016 14:12
s/jm2/jnm2
100% with you on string.Replace. Yuck.
The solution would have to be searching every upper-case-containing word from every capital letter or digit in the string. Not great for a general .Humanize(), perf-wise. A regex will create a fast state machine for you from a custom dictionary but even so. It might have to be opt-in.
Joseph Musser
@jnm2
Jun 03 2016 15:40
@MrKWatkins