This package can be used to summarize longs texts to custom summarized sentence.
npm install git+https://github.com/Caliph91/text-summarisation
You can just simply call the function and get the summary of the text without passing your target sentence.
const summarize = require("text-summarize");
const text = "Alice and Bob are friends. Alice is fun and cuddly. Bob is cute and quirky. Together they go on wonderful adventures in the land of tomorrow. Alice's cuddliness and Bob's cuteness allow them to reach their goals. But before they get to them, they have to go past their mortal enemy — Mr. Boredom. He is ugly and mean. They will surely defeat him. He is no match for their abilities.";
// summarize function returns a Promise
summarize(text).then(data => console.log(data));
// output: Alice and Bob are friends. Alice is fun and cuddly. Bob is cute and quirky. Together they go on wonderful adventures in the land of tomorrow. Alice's cuddliness and Bob's cuteness allow them to reach their goals. But before they get to them, they have to go past their mortal enemy — Mr. Boredom. He is ugly and mean. They will surely defeat him. He is no match for their abilities.You can pass custom target sentence that you want after summarize the text.
const summarize = require("text-summarize");
const text = "Alice and Bob are friends. Alice is fun and cuddly. Bob is cute and quirky. Together they go on wonderful adventures in the land of tomorrow. Alice's cuddliness and Bob's cuteness allow them to reach their goals. But before they get to them, they have to go past their mortal enemy — Mr. Boredom. He is ugly and mean. They will surely defeat him. He is no match for their abilities.";
// summarize function returns a Promise
summarize(text, { sentences: 2 }).then(data => console.log(data));
// output: Alice and Bob are friends. Alice's cuddliness and Bob's cuteness allow them to reach their goals.You can pass language to translate the summarized text.
const summarize = require("text-summarize");
const text = "Alice and Bob are friends. Alice is fun and cuddly. Bob is cute and quirky. Together they go on wonderful adventures in the land of tomorrow. Alice's cuddliness and Bob's cuteness allow them to reach their goals. But before they get to them, they have to go past their mortal enemy — Mr. Boredom. He is ugly and mean. They will surely defeat him. He is no match for their abilities.";
// summarize function returns a Promise
summarize(text, { sentences: 2, translate: 'bn' }).then(data => console.log(data));
// output: এলিস এবং বব বন্ধু। অ্যালিসের কুশ্রীতা এবং বব এর কর্তৃত্ব তাদেরকে তাদের লক্ষ্যে পৌছাতে দেয়।The options can be
const options = {
sentences: 2, // return specific lines of summary
translate: 'bn' // translate the summary into the target language
}
summarize(text, options).then(data => console.log(data));sentenceis set to10.