Git Product home page Git Product logo

abbreviate's Introduction

abbreviate

Shorten your strings using common abbreviations.

ko-fi

codecov godoc report card

GitHub watchers GitHub stars Twitter URL

Supported by Tidelift

Motivation

This tool comes out of a frustration of the name of resources (in my specific case, AWS stack names) being too long. Wouldn't it be nice if we could have a tool that would be able to suggest shorter alternatives if your original name is too long.

Before we get any further, I'm really interested in how you feel about this tool. Please take the time to fill in this short survey: https://forms.gle/6xV1gB8yKGdmuHJ78

Installation

go get github.com/dnnrly/abbreviate
make build

Usage

This tool will attempt to shorten the string provided using common abbreviations
specified by language and 'set'. Word boundaries will be detected using title case
and non-letters.

Hosted on Github - https://github.com/dnnrly/abbreviate

I'm really interested in how you feel about this tool. Please take the time to fill
in this short survey:
https://forms.gle/6xV1gB8yKGdmuHJ78

If you spot a bug, feel free to raise an issue or fix it and make a pull
request. We're really interested to see more abbreviations added or corrected.

Usage:
  abbreviate [action] [flags]
  abbreviate [command]

Available Commands:
  camel       Abbreviate a string and convert it to camel case
  help        Help about any command
  kebab       Abbreviate a string and convert it to kebab case
  original    Abbreviate the string using the original word boundary separators
  pascal      Abbreviate a string and convert it to pascal case
  print       Print abbreviations in this set
  separated   Abbreviate a string and convert it using separator passed
  snake       Abbreviate a string and convert it to snake case

Flags:
  -c, --custom string     Custom abbreviation set
      --from-front        Shorten from the front
  -h, --help              help for abbreviate
  -l, --language string   Language to select (default "en-us")
      --list              List all abbreviate sets by language
  -m, --max int           Maximum length of string, keep on abbreviating while the string is longer than this limit
  -n, --newline           Add newline to the end of the string (default true)
  -s, --set string        Abbreviation set (default "common")
      --no-stopwords      Remove stopwords from abbreviation
      --strategy string   Abbreviation strategy (default "lookup")

Use "abbreviate [command] --help" for more information about a command.

Examples:

$ abbreviate original strategy-limited
stg-ltd

$ abbreviate original prestrategy-limitedment
prstg-ltdmnt

$ abbreviate original --max 11 strategy-limited
strategy-ltd

$ abbreviate original --max 11 --from-front strategy-limited
stg-limited

$ abbreviate camel --max 99 strategy-limited
strategyLimited

$ abbreviate kebab StrategyLimited
stg-ltd

$ abbreviate separated StrategyLimited --separator +
stg+ltd

$ abbreviate separated StrategyLimited
stgltd

Code of Conduct

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code.

Contributing

Pull requests are welcome. See the contributing guide for more details.

Please make sure to update tests as appropriate.

github.com/dnnrly/abbreviate for enterprise

Available as part of the Tidelift Subscription

The maintainers of github.com/dnnrly/abbreviate and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

License

Apache 2

abbreviate's People

Contributors

amoghrajesh avatar andrysds avatar billcobbler avatar dnnrly avatar dubek avatar leafoliage avatar milesmcc avatar riyajohn avatar scottyeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

abbreviate's Issues

Handle common prefixes/suffixes (when predefined word does not exist)

Is your feature request related to a problem? Please describe.
Related to #13

Describe the solution you'd like
Add list of common prefixes and suffixes and their abbreviations (e.g. -ible -> bl)
When predefined word does not exist, attempt to remove common prefix or suffix (e.g. in-access-ible -> access-ible)
Look up remaining word again
Repeat prefix/suffix removal as many times as necessary (e.g. access-ible -> access)
Concatenate prefix abbreviation, word abbreviation, and suffix abbreviation (e.g. in-access-ible -> in-acc-bl)

cc @FungusHumungus

Hi sir

What word do you think needs abbreviating?

Go on, what's too long?

What should it be abbreviated to?

What's better?

Add kebab (dash) case command

Is your feature request related to a problem? Please describe.
At the moment camel, pascal and snake cases are available. Kebab case is another popular ways to combine strings and abbreviate doesn't provide this option.

Describe the solution you'd like
It would be nice to have also the kebab command available that can be used to abbreviate a string and convert it to kebab case.

Example

$ abbreviate kebab StrategyLimited
stg-ltd

Remove functional words using a list of stopwords

Is your feature request related to a problem? Please describe.
The English language has a lot of short connector words which have a grammatical function but don't necessarily provide meaning. Thus they can be omitted when creating abbreviations.

Describe the solution you'd like
A simple solution would be to save a list of stopwords and to have a flag that the user could use to remove them.

Here is an example:
$ abbreviate snake "The strategy of limited science" --stopwords tstg_ltd_sci

versus the current behavior (so without the flag):
$ abbreviate snake "The strategy of limited science" --stopwords the_stg_of_ltd_sci

Additional context
Initially we could curate our own list of stopwords. Eventually we could use this as a possible source:
https://github.com/bbalet/stopwords

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

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?

Migrate to GoDog acceptance tests

Is your feature request related to a problem? Please describe.

At the moment, we have to include non-go dependencies to run acceptance tests. This is bash based and tricky to get right. We could achieve just as much with godog, without having to switch to another language. And go has more testing features/libraries available.

Describe the solution you'd like
BATS acceptance tests replaced with Godog ones.

Upgrade CI actions

Is your feature request related to a problem? Please describe.
At the moment, the PR build action doesn't provide all of the features that I would expect. It would be nice if this repo could follow some of the later best practices.

Describe the solution you'd like

Perhaps using wait-for as an example, update the PR workflow action to include (and not limited to):

  • Coverage metrics
  • Release build validation
  • Enabled for external contributors

Add abbreviations for title case

What word do you think needs abbreviating?

We should add support for abbreviating using title casing.
Title Case:

  • Title case capitalizes the first letter of each word in a string, typically used for formatting titles, headings, or sentences and seperates it with space
    Example: The Quick Brown Fox

What should it be abbreviated to?

Usage example:

$ abbreviate title prestrategy-limitedment
Prstg Ltdmnt

What's better?
NA

Shorten from the front

Is your feature request related to a problem? Please describe.
At the moment, the algorithm used starts from the last 'word' in the string and works backwards. This makes an assumption about how the string should be shortened that may not work for everyone.
A good option might be to shorten from the front instead.

Describe the solution you'd like

$ abbreviate --length 15 strategy-limited
strategy-ltd
$ abbreviate --from-front --length 15 strategy-limited
stg-limited

Setting up a workflow for every pull request

Is your feature request related to a problem? Please describe.
Creating a pull request does not check whether the change has broken current working test cases. Although it is encouraged to run all the tests before someone submits a PR but being double sure is good.

Describe the solution you'd like
Add a github workflow that will trigger all the tests to run when someone raises a PR.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

New abbreviations

Is your feature request related to a problem? Please describe.
The current list of abbreviations is OK but l feel a little lacking.

Describe the solution you'd like

  • More abbreviations
  • Abbreviations in other languages

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.