dnnrly / abbreviate

Supporting your devops by shortening your strings using common abbreviations and clever guesswork
Apache License 2.0
220 stars 17 forks source link

Attempt to guess an abbreviation when a predefined one doesn't exist #13

Open dnnrly opened 4 years ago

dnnrly commented 4 years ago

Is your feature request related to a problem? Please describe. At the moment, there is a defined list of abbreviations that are looked up. Where an abbreviation isn't present, it just won't be abbreviated.

Describe the solution you'd like It would be good if the tool could attempt to shorten words taht it doesn't already know about.

A couple of different strategies we could explore:

Additional context How would this work with other languages?

trampfox commented 4 years ago

As a first implementation of this feature, what about something similar the abbreviate function in R for the unmatched words? https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/abbreviate

dnnrly commented 4 years ago

Possibly, although I'd prefer to avoid copyright issues from copying the algorithm. What does the license say?

VishalVatsal97 commented 4 years ago

Hi, I was exploring this issue and tried to implement the removing all vowels strategy. I was thinking whether we should notify user that we are guessing the abbreviation or not?

Example : abbreviate original herewego Guessing abbreviation

dnnrly commented 4 years ago

I would be cautious about that. I think people will be consuming the output directly and we don't want them to be concerned with filtering out log entries. Could an option be to use a CLI param to select the algorithm used?

Maybe we could have something to check if it's a known abbreviation? That might be a separate PR though.

VishalVatsal97 commented 4 years ago

I would be cautious about that. I think people will be consuming the output directly and we don't want them to be concerned with filtering out log entries. Could an option be to use a CLI param to select the algorithm used?

Can you give an example of how the cli param should look.?.I am understanding it as : abbreviate original herewego --algorithm/paramname removeVowel .. Apologies if I am sounding a bit naive

dnnrly commented 4 years ago

No, that's not naive. I would probably call the parameter --strategy or something and just have a list of options available in the help. One of those strategies could be removeVowels, perhaps another could be lookupOnly. I think Cobra insists that the parameter goes before the word to abbreviate but appart from that, it looks good.

Thinking about it, it makes it easier to add new algorithms later.

VishalVatsal97 commented 4 years ago

Ok...For lookupOnly we may need a seperate discussion on how it should be implemented...Should I go ahead with implementing removeVowel or there is something more you want to discuss?

dnnrly commented 4 years ago

No, I think that's it. I look forward to your PR!

VishalVatsal97 commented 4 years ago

Hi, I have implemented this but instead of using --strategy as a command I am using it as a flag with value removeVowel. This is just because I found flags easier to implement and integrate with the current structure of the project.

dnnrly commented 4 years ago

Cool! Are you ready to raise a PR yet?

VishalVatsal97 commented 4 years ago

19 Raised a PR

sperez8 commented 2 years ago

I have another idea to propose for "guessing" an abbreviation. How about truncating each word to its first syllable?

So the behavior would look like:

$ abbreviate original red-difference-strategy --syllabic red-diff-stg

In this example:

(Assuming I can find a clever way to find the first syllable of multi-syllable words)

Would this new flag be of interested? Let me know and I can work on a PR for hacktoberfest!

dnnrly commented 2 years ago

Or red-diff-strat? I like this idea. A lot!!!

Please, feel free to raise a pull request early. Don't worry about having a full solution. Try something, see how the code feels to you.

I'm curious to see what you come up with.

sperez8 commented 2 years ago

Or red-diff-strat? I like this idea. A lot!!!

Oh interesting, I was thinking it would only replace words for which an abbreviation is NOT known. But that might be additional option to add later? Something to think about...

Please, feel free to raise a pull request early. Don't worry about having a full solution. Try something, see how the code feels to you.

Sounds good will do :)