Back to articles
I Replaced 5 npm Packages with One for Text Analysis

I Replaced 5 npm Packages with One for Text Analysis

via Dev.to Webdevckmtools

Every project I built that needed text analysis ended up with the same dependency list: npm install flesch flesch-kincaid coleman-liau automated-readability sentiment Five packages. Five different APIs. Five entries in package.json . And none of them shared the underlying text parsing work — each one re-tokenized the same string independently. I got tired of it and built textlens . The Problem Say you want to score an article's readability and sentiment. Here's what that looked like before: const flesch = require ( ' flesch ' ); const fleschKincaid = require ( ' flesch-kincaid ' ); const colemanLiau = require ( ' coleman-liau ' ); const ari = require ( ' automated-readability ' ); const Sentiment = require ( ' sentiment ' ); // Each package needs its own input format const counts = { sentence : countSentences ( text ), word : countWords ( text ), syllable : countSyllables ( text ) // you write this yourself }; const fleschScore = flesch ( counts ); const fkGrade = fleschKincaid ( count

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
0 views

Related Articles