piotrmurach / strings-case

Convert strings between different cases.
MIT License
97 stars 2 forks source link

Support for special casing of scientific nomenclature, etc #6

Closed coryschires closed 11 months ago

coryschires commented 11 months ago

This is a feature request – not a bug.

Background

There are scenarios where specific words should always (or never) be capitalized. To provide one clear example, I recommend looking at scientific nomenclature such as names of species, bacteria, etc: http://englishplus.com/grammar/00000047.htm.

Problem

Looking at your code, I don't see any support for scientific nomenclature (or other similar scenarios).

Solution

It would be cool if this library included dictionaries of these type of terms, so that it could handle the casing correctly. Furthermore, these dictionaries could be included / excluded via configuration, as I suspect many users would not care about such edge cases.

Nevertheless, IMHO, if you're goal is to be the best casing tool around (and maybe that's not your goal for all I know), then support for scientific nomenclature would be an excellent addition.

PS: I have created a similar tool for internal usage. I would be interested in replacing it with this tool but the lack of support for scientific nomenclature is a blocker. I would share my code, but my own solution is a bit ad hoc and would not be suitable for an open source tool.

Thanks for building this tool and considering this request!

piotrmurach commented 11 months ago

Hi Cory 👋

Thanks for taking an interest in this gem and providing your thoughts on improving it.

It would be cool if this library included dictionaries of these type of terms, so that it could handle the casing correctly. Furthermore, these dictionaries could be included / excluded via configuration, as I suspect many users would not care about such edge cases.

I won't be adding any specific dictionaries. Taking on such responsibility would place a burden on me to maintain such dictionaries. It would make the download size of the gem bigger. Potentially reduce speed for anyone else who doesn't care. I must admit this to be a rather niche requirement.

One possible way would be to provide some extension points in the configuration. However, I wonder if the current acronyms functionality couldn't be repurposed for what you need:

terms = YAML.load_file("terms.yml")
strings = Strings::Case.new(acronyms: terms)

Nevertheless, IMHO, if you're goal is to be the best casing tool around (and maybe that's not your goal for all I know), then support for scientific nomenclature would be an excellent addition.

My goal in creating strings gems is to solve underlying problems I've been finding when working on the ttytoolkit. That's the primary goal - facilitating a reusable way to do common strings manipulation in command line apps. The side effect is creating something that others may find useful. The secondary goal for the future is to achieve some parity with ActiveSupport::Inflector to offer people alternatives. Greatness has never been the goal and my notion of greatness doesn't involve adding every possible use case under the sun. Quiet the opposite. There is an appeal for me in having small sharp tools that are good for most but not every case. Pun intended.

I hope my answer won't impact your future contributions to any of my gems. I tried to answer your query as best as I could without creating false assumptions. If you believe there is a neat way to extend this gem configuration to allow you to achieve your aim, please submit PR.

coryschires commented 11 months ago

Sounds good.

Thanks for following up with such a thoughtful response!