Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

anton-bot/expand-contractions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expand English Contractions

Convert English contractions to complete words.

Uses the word list from https://en.wikipedia.org/wiki/Wikipedia:List_of_English_contractions.

Adapted from the unmaintained contractions package by JamesHight. This fixes an issue in the original package when the words like "super" were changed into "what is uper", because "sup" is replaced with "what is up".


npm install expand-contractions

var contractions = require('expand-contractions');

console.log(contractions.expand("I don't know who ya'll are."));
// Outputs: I do not know who you all are.

console.log(contractions.contract("You all will have not seen this."));
// Outputs: Y'all'll'ven't seen this.

You can also use your own list of contractions / strings.

Note: Longer strings take precedent over short strings.

var Contractions = require('expand-contractions').Contractions;

var contractions = new Contractions({
	'asap': 'as soon as possible', // only lower case characters should be used in the list
	'a.s.a.p.': 'as soon as possible'
});


var text = 'asap';

text = contractions.expand(text);
console.log(text);
// Outputs: as soon as possible

text = contractions.contract(text);
console.log(text);
// Outputs: a.s.a.p.

About

Convert English contractions to complete words.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%