Skip to content

A Node.js module that splits text into paragraphs and then further divides those into lines with metadata.

Notifications You must be signed in to change notification settings

samliebl/paragraphs-lines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

paragraphs-lines

The goal is to build this out more with some plans I have in mind. At present, this NPM module exports a function that takes a text input parameter textInput.

It takes paramater textInput and splits it into paragraphs $.text.textParagraphs[] and lines within paragraphs as $.text.textParagraphs[i].paragraphLines[i].lineText. They are strings and each "text level" has a corresponding data object that tracks metadata about that text string. Each object within the $.text.textParagraphs[0] array, for example, has a .paragraphData object that provides such properties as paragraphLineCount; each line within each paragraph has a lineData object with corresponding properties like lineWordCount

It reformats this data into a JSON object that includes metadata along with the original text.

It is written in ESM format.

Usage

import { paragraphsLines } from 'paragraphs-lines';

// "After great pain, a formal feeling comes – (372)"
// by Emily Dickinson

const textInput = `
After great pain, a formal feeling comes – (372)

After great pain, a formal feeling comes –
The Nerves sit ceremonious, like Tombs –
The stiff Heart questions ‘was it He, that bore,’
And ‘Yesterday, or Centuries before’?

The Feet, mechanical, go round –
A Wooden way
Of Ground, or Air, or Ought –
Regardless grown,
A Quartz contentment, like a stone –

This is the Hour of Lead –
Remembered, if outlived,
As Freezing persons, recollect the Snow –
First – Chill – then Stupor – then the letting go –
`;

const result = paragraphsLines(textInput);
console.log(JSON.stringify(result, null, 2));

returns a JSON object w/ the text and data.

License

MIT

About

A Node.js module that splits text into paragraphs and then further divides those into lines with metadata.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published