Skip to content

πŸ“ Summary.JS is a Light Weight Article Summary Library for Vanilla JavaScript and Node.js

License

Notifications You must be signed in to change notification settings

Lian-D/Summary.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

67 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Summary.js

License: MIT PRs Welcome

A lightweight paragraph summarizer library which can be manipulated to preferred specifications. Utilizing the lex rank algorithm to score sentences. Not as effective as using TensorFlow and NLM but provides a nice middle ground.

Total file size < 10 kb

Main

dist/
β”œβ”€β”€ summary.js        (UMD)
β”œβ”€β”€ summary_minfied.js    (UMD, compressed)
β”œβ”€β”€ summary_legacy.js s (Old legacy summarizer)
└── summary_legacy_minfied.js    (Old legacy summarizer, compressed)
β”œβ”€β”€ summary_node.js        (Node.js module)

Installation

Include files:

<script src="/path/to/summary.js"></script>

Usage

summarize(text, sentences, keywordsInt);

where text is the input text

sentences is the number of sentences you want to return

keywordsInt is the number of keywords you want to factor in during the scoring process

This will return an object:

{
keywords: an array of keywords,
text: the raw string summary
characterSummed: the number or words in this summary
characterOrig: the number of words in the original summary
reductionfactor: the % reduction factor
}

How does it work?

The core algorithm works in a couple of steps

  1. Calculate the occurrence of each word in the text.
  2. Detect which periods represent the end of a sentence. (e.g "Dr." does not).
  3. Split up the text into individual sentences.
  4. Rank sentences by the sum of their words' points and keyword points.
  5. Return X of the most highly ranked sentences in chronological order.

Contributing

Please read through our contributing guidelines.