# @treecg/substring-bucketizer

> Applies a substring fragmentation to LDES members

Latest version **2.1.10** (published 2023-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @treecg/substring-bucketizer
pnpm add @treecg/substring-bucketizer
yarn add @treecg/substring-bucketizer
bun add @treecg/substring-bucketizer
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.10 |
| Published | 2023-10-30 |
| First published | 2021-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dwight Van Lancker |
| Maintainers | ajuvercr, woutslabbinck, ddvlanck, dexagod, pietercolpaert, hdlva, julianrojas87, brechtvdv, kasperzutterman |

## Links

- npm: https://www.npmjs.com/package/@treecg/substring-bucketizer
- Repository: https://github.com/TREEcg/bucketizers
- Homepage: https://github.com/TREEcg/bucketizers#readme
- Issues: https://github.com/TREEcg/bucketizers/issues
- npm.io page: https://npm.io/package/@treecg/substring-bucketizer

## Dependencies (2)

- [winston](https://npm.io/package/winston.md) ^3.11.0
- [@treecg/bucketizer-core](https://npm.io/package/@treecg/bucketizer-core.md) ^1.1.9

## Recent versions

- 2.1.10 (latest) — 2023-10-30
- 2.1.9 — 2023-06-07
- 2.1.8 — 2023-05-08
- 2.1.7 — 2023-05-08
- 2.1.6 — 2023-03-07
- 2.1.5 — 2023-03-03
- 2.1.4 — 2023-03-03
- 2.1.3 — 2023-03-03
- 2.1.2 — 2023-02-28
- 2.1.1 — 2022-11-08
- 2.1.0 — 2022-07-28
- 2.0.0 — 2022-06-17
- 2.0.0-alpha.0 — 2022-05-31
- 1.5.3-alpha.0 — 2021-11-29
- 1.5.2-alpha.0 — 2021-11-29
- … 12 more at https://npm.io/package/@treecg/substring-bucketizer/versions

## README

# Substring Bucketizer
[![npm](https://img.shields.io/npm/v/@treecg/substring-bucketizer)](https://www.npmjs.com/package/@treecg/substring-bucketizer)

The purpose of the substring bucketizer is to apply a substring fragmentation to TREE members based on a text property path.

> An LDES bucketizer adds triples with the ldes bucket predicate (https://w3id.org/ldes#bucket) to the array of quads representating an LDES member, indicating the bucket in which the member belongs.

The fragmentation strategy is based on [previous work](https://github.com/TREEcg/substring_fragmenter) and the following method is applied:
![Fragmentation Strategy](https://raw.githubusercontent.com/TREEcg/substring_fragmenter/main/img/files.svg)

## Example

We assume the following LDES member on which a substring fragmentation with the property path set to `(<http://www.w3.org/2000/01/rdf-schema#label>)` will be applied.

```ttl
<http://example.ord/id/123@456> dct:created "2002-08-13T16:33:18+02:00"^^xsd:dateTime ;
          dct:isVersionOf <http://example.org/id/123> ;
          prov:generatedAtTime "2021-09-07T15:44:05.975Z"^^xsd:dateTime ;
          rdfs:label "John Doe" .
```

After passing through the bucketizer, the LDES member will have one or more extra triples
```ttl
<http://example.ord/id/123@456> dct:created "2002-08-13T16:33:18+02:00"^^xsd:dateTime ;
          dct:isVersionOf <http://example.org/id/123> ;
          prov:generatedAtTime "2021-09-07T15:44:05.975Z"^^xsd:dateTime ;
          rdfs:label "John Doe" ;
          ldes:bucket "j"
```

Depending on when this LDES member is processed, it is possible for it to have a different bucket


## Install

```bash
> npm i @treecg/ldes-substring-bucketizer
```

## Usage

A bucketizer should always be used in combination with the LDES client. More information on how to setup an LDES client can be found [here](https://github.com/TREEcg/event-stream-client/tree/main/packages/actor-init-ldes-client). It is important to set the option in the LDES client to receive the LDES member as an array of quads: `representation: 'quads'`.

The bucketizer expects a property path as input and should have the following structure `(<predicate1> <predicate2> ...)`

```
import { SubstringBucketzer } from '@treecg/substring-bucketizer'

const run = async (): Promise<void> => {
  const options = {...};
  const url = ...;
  const pageSize: ...;

  const bucketizer = await SubstringBucketizer.build({ propertyPath: '<http://www.w3.org/2000/01/rdf-schema#label>', pageSize: pageSize });

  const ldes = LDESClient.createReadStream(url, options);
  ldes.on('data', (member) => {
    bucketizer.bucketize(member.quads, member.id)

    // Continue processing the member, but now the array of quads will have extra triples, the bucket triples
  });
}

run().catch(error => console.error(error.stack));
```

---
_Source: https://npm.io/package/@treecg/substring-bucketizer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
