Skip to content

ManuUseGitHub/atext-wordz

Repository files navigation


npm version License: MIT

INTRO

Imagine you have that homework which requires you to build a list of all different words of a very long text; maybe a whole chapter of a book ! Then yould probably need something like this.

Oh and what if you could also check the number of usage, the the position of it's first appearence or even it's length?

Ok, that's cool and fun! 🥳

NPM package

Light demo

Assuming you have a demo.txt file in a demo folder at the same level as this .js file and you want to get word stats.

const { fs } = require('fs') ;

const { getWStatsList , getWStatsObj , getWordList } = require( "../atext-wordz" );

fs.readFile( "./demo/demo.txt" , "utf8" , ( err , text ) => {

  // We will use byStr ~ Sort // visit : https://www.npmjs.com/package/bystr-sort
  const sortString = ` by number of a > than b's `;
  
  const cbOnNewWord = ( word ) => {
    
    // TODO: make first sector actions on new word found
    
  };

  const options = {  sortString , cbOnNewWord };

  const result = getWStatsList( text , options );

  console.log( result );
  // outputs :
  // < an array of word statistics sorted by most used words >

});

About

Provides a list of words within an entire text alongside few statistics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published