Giter VIP home page Giter VIP logo

paraphrase-sentences's Introduction

Paraphrase Sentences

Generate multiple variations of your sentence.

This is a quick hack to generate multiple variations of the same sentence by google-translating them back and forth into random languages.

For example, it takes the sentence "how is my laptop called?" and outputs "what is the name of my laptop?".

Generating 10 variations of a medium-sized sentence (75 characters) costs 0.03 USD in Google Tranlate API costs.

Basic example

This takes a sentence in English (by default), generates up to 10 (by default) variations, and removes duplicates (by default) from the results:

let Paraphrase = require('paraphrase-sentences');
const key = '<INSERT YOUR GOOGLE TRANSLATE API KEY HERE>';

let paraphrase = new Paraphrase({ key });

(async () => {
  let results = await paraphrase.get('Nearly half Hong Kong flats rent for more than US$2,550 a month');
  console.log(results);
})();

// Outputs:
// [ 'Nearly half of Hong Kong\'s rental apartments exceed $ 2,550 a month.',
//  'More than half a Hong Kong rental costs more than US $ 2,550 per month.',
//  'Nearly half of Hong Kong Flats will rent more than US $ 2,550 a month.',
//  'Almost half of Hong Kong apartments for rent for more than $ 2,550 per month.',
//  'Nearly half of Hong Kong homes have earned more than $ 2.550 a month.',
//  'About half of the Hong Kong floors rented over US $ 2,550 a month.',
//  'Almost half Hong Kong ask for rent for more than $ 2,550 in a month.',
//  'Nearly half of Hong Kong costs more than $ 2,550 a month.',
//  'Nearly one of the Hong Kong Hong Kong taxpayers is $ 2.5,550 per month.',
//  'Almost half of the apartments in Hong Kong hire more than 2,550 US dollars a month.' ]

Other constructor options

The constructor takes the following options, where only key is required. Default values are listed below.

let paraphrase = new Paraphrase({
  num: 10, // how many variations to generate
  key: null, // your API key
  lang: 'en', // language of your source sentence in the Google Translate format
  removeDuplicates: true, // whether to remove duplicate sentences in the results
});

paraphrase-sentences's People

Contributors

anton-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

teamplumaa oytla

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.