Overview

This tool will give a summary for the given text by ranking each sentence by its relevance.

Features

  • Summary output with configurable threshold – only the lines with a frequency over the threshold will be returned
  • Best words extraction – most relevant keyword will be extracted (ordered by their relevance)
  • Sentences split – the given text is automatically split into sentences
  • Common words skip – in order to provide better results, common words are skipped based on a dictionary (only for English language provided)
  • Minimal dependencies – all you need is PHP 5+ to run it (PHP 7 supported)
  • Incredibly fast – in most cases, the summary is returned in less than 0.1 seconds
  • Low memory usage – with regular articles less than 1MB of memory is used
  • Natural language processing – much better results when using non-standard languages (e.g. Russian, Farsi, Arabic, Chinese)

Requirements

PHP 5 / 7

Instructions

Basic usage

Here is how to create the summary of a given text.
From local file:

 require_once(dirname(__FILE__) . '/Summarizer.php'); $text = file_get_contents(dirname(__FILE__) . '/test_files/cap1.txt'); $summarizer = new Summarizer(); $summarizer->loadText($text); $summary = $summarizer->run(); print_r($summary);    

From remote url:

 require_once(dirname(__FILE__) . '/Summarizer.php'); $url = 'http://edition.cnn.com/2011/LIVING/02/07/russell.simmons.super.rich/index.html?hpt=C2'; $summarizer = new Summarizer(); $summarizer->loadUrl($url); $summary = $summarizer->run(); print_r($summary);    

API documentation

To view all of the available class methods take a look at the API reference.

Related