abbreviate icon indicating copy to clipboard operation
abbreviate copied to clipboard

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

Open dnnrly opened this issue 4 years ago • 14 comments

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:

  • Match only parts of words
  • Remove all vowels

Additional context How would this work with other languages?

dnnrly avatar Jan 27 '20 21:01 dnnrly

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

trampfox avatar Mar 21 '20 11:03 trampfox

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

dnnrly avatar Mar 21 '20 19:03 dnnrly

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

VishalVatsal97 avatar Aug 02 '20 08:08 VishalVatsal97

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.

dnnrly avatar Aug 02 '20 11:08 dnnrly

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

VishalVatsal97 avatar Aug 02 '20 13:08 VishalVatsal97

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.

dnnrly avatar Aug 02 '20 21:08 dnnrly

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?

VishalVatsal97 avatar Aug 03 '20 07:08 VishalVatsal97

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

dnnrly avatar Aug 03 '20 12:08 dnnrly

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.

VishalVatsal97 avatar Sep 08 '20 10:09 VishalVatsal97

Cool! Are you ready to raise a PR yet?

dnnrly avatar Sep 10 '20 18:09 dnnrly

#19 Raised a PR

VishalVatsal97 avatar Sep 12 '20 08:09 VishalVatsal97

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:

  • strategy already has a known abbreviation so we use that
  • red is a one syllable word so it is left unchanged
  • difference is truncated to its first syllable

(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!

sperez8 avatar Oct 13 '22 19:10 sperez8

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.

dnnrly avatar Oct 13 '22 19:10 dnnrly

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 :)

sperez8 avatar Oct 13 '22 20:10 sperez8