https://github.com/samliebl/paragraphs-lines
A Node.js module that splits text into paragraphs and then further divides those into lines with metadata.
https://github.com/samliebl/paragraphs-lines
language language-analysis lines metadata natural-language-processing nlp paragraph poem poetry strings
Last synced: 6 months ago
JSON representation
A Node.js module that splits text into paragraphs and then further divides those into lines with metadata.
- Host: GitHub
- URL: https://github.com/samliebl/paragraphs-lines
- Owner: samliebl
- Created: 2024-07-21T15:20:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-03T15:13:50.000Z (about 1 year ago)
- Last Synced: 2025-03-24T15:43:21.743Z (7 months ago)
- Topics: language, language-analysis, lines, metadata, natural-language-processing, nlp, paragraph, poem, poetry, strings
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```js
import { paragraphsLines } from 'paragraphs-lines';// "After great pain, a formal feeling comes – (372)"
// by Emily Dickinsonconst 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