Giter Club home page Giter Club logo

summary.js's Introduction

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.

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.