<commit_before># lexrank.js

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

NodeJS implementation of [Radev's Lexrank algorithm](http://www.jair.org/papers/paper1523.html) for unsupervised text summarization. Essentially applying PageRank to each sentence in a document and ranking each one for relevance to the entire text.

# Usage

Install from npm

```
npm i --save lexrank.js
```

In your script:

```js
import lexrank from 'lexrank.js'

const result = lexrank(text)

// or as a callback
lexrank(text, (err, result) => {
  /* handle result */
})
```

### Returns

Returns a paragraphs array containing sentences of ranked results and a summary string.

```
// paragraphs array
[
  // sentences array
  [
    {
      weight: {
        global: <Number(0-1)>,       // relevance score relative to the entire text
        paragraph: <Number(0-1)>     // relevance score relative to the parent paragraph
      },
      text: <String>,                // original sentence string
      index: <Number>                // global sentence index
    },
    { ... }
  ],
  [ ... ]
]
```

# Tests

Run `npm test` to run tests in all `*.spec.js` files.

Run `npm coverage` to produce a test coverage report.

## License

[MIT][license] © [<NAME>][author]

<!-- Definitions -->

[build-badge]: https://github.com/gorango/lexrank.js/workflows/main/badge.svg
[build]: https://github.com/gorango/lexrank.js/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/gorango/lexrank.js.svg
[coverage]: https://codecov.io/github/gorango/lexrank.js
[downloads-badge]: https://img.shields.io/npm/dm/lexrank.js.svg
[downloads]: https://www.npmjs.com/package/lexrank.js
[size-badge]: https://img.shields.io/bundlephobia/minzip/lexrank.js.svg
[size]: https://bundlephobia.com/result?p=lexrank.js
[license]: license
[author]: https://github.com/gorango<commit_msg>update docs<commit_after># lexrank.js

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

NodeJS implementation of [Radev's Lexrank algorithm][paper] for unsupervised text summarization. Essentially applying PageRank to each sentence in a document and ranking each one for relevance to the entire text.

# Usage

Install from npm

```
npm i --save lexrank.js
```

In your script:

```js
import lexrank from 'lexrank.js'

const result = lexrank(text)

// or as a callback
lexrank(text, (err, result) => {
  /* handle result */
})
```

### Returns

Returns a paragraphs array containing sentences of ranked results and a summary string.

```
// paragraphs array
[
  // sentences array
  [
    {
      weight: {
        global: <Number(0-1)>,       // relevance score relative to the entire text
        paragraph: <Number(0-1)>     // relevance score relative to the parent paragraph
      },
      text: <String>,                // original sentence string
      index: <Number>                // global sentence index
    },
    { ... }
  ],
  [ ... ]
]
```

# Tests

Run `npm test` to run tests in all `*.spec.js` files.

Run `npm coverage` to produce a test coverage report.

## License

[MIT][license] © [<NAME>][author]

<!-- Definitions -->

[build-badge]: https://github.com/gorango/lexrank.js/workflows/main/badge.svg
[build]: https://github.com/gorango/lexrank.js/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/gorango/lexrank.js.svg
[coverage]: https://codecov.io/github/gorango/lexrank.js
[downloads-badge]: https://img.shields.io/npm/dm/lexrank.js.svg
[downloads]: https://www.npmjs.com/package/lexrank.js
[size-badge]: https://img.shields.io/bundlephobia/minzip/lexrank.js.svg
[size]: https://bundlephobia.com/result?p=lexrank.js
[paper]: http://www.jair.org/papers/paper1523.html
[license]: license
[author]: https://github.com/gorango
{'fraction_non_alphanumeric': 0.1590268886043534, 'fraction_numerical': 0.00409731113956466, 'mean_word_length': 3.44874715261959, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 18, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6105596', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1262, 'n_words': 312}