string-contractor

calculates permutations of expanded / contracted english language strings

Usage no npm install needed!

<script type="module">
  import stringContractor from 'https://cdn.skypack.dev/string-contractor';
</script>

README

Strng-Contractor

Actions Status

Takes a string and works out augmentations with different contractions. This includes full expansions and contractions, as well as all possible combinations of either.

For example I am sure it's a good example will contract to I'm sure it's a good example. It will expand to

I am sure it has a good example
I am sure it is a good example

since it's could mean it is or it has. All possible combinations gives us

I'm sure it's a good example
I'm sure it has a good example
I'm sure it is a good example
I am sure it's a good example
I am sure it has a good example
I am sure it is a good example

Using it

In typescript

import StringContractor from 'string-contractor'

const stringContractor = new StringContractor()

const input = "I am sure it's a good example"

stringContractor.contract(input)
stringContractor.expand(input)
stringContractor.all(input)

In javascript

const StringContractor = require('string-contractor').default

const stringContractor = new StringContractor()

const input = "I am sure it's a good example"

stringContractor.contract(input)
stringContractor.expand(input)
stringContractor.all(input)

Data Source

The data for the contractions comes from a slightly modified form of the wikipedia list