Skip to content

rabee05/word-count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word Count CLI

This is a command-line interface (CLI) tool that counts the occurrences of each word in a file. It takes an input file as an argument, processes it, and produces an output with the frequency count of each word in the file.

Features

  • Count the number of occurrences of each word in a file.
  • Show a list of words with the highest count.
  • Option to write the output to a file.
  • Option to read files as a stream to optimize memory usage.

Installation

Usage

    $ node app -f <filename> [-o <output file>] [-s]

Options

-f, --file <filename>: The input file to count the words.
-o, --write <output file>: (Optional) Default output.json
-s, --stream [type]: (Optional) Read the input file as a stream. 
-h, --help: Display help for command

Examples

Count the words in a file and show the list of words with the highest count:

$ node app.js -f input.txt

Count the words in a file and write the output to a file:

$ node app.js -f sample.txt -o somename

Count the words in a large file using a stream:

$ node app.js -f sample.txt -o somename -s

Configuration Options

The following configuration options can be set in config.js:

module.exports = {
    inputDir: 'data/input',
    outputDir: 'data/output',
};

  • inputDir: The directory to read input files from
  • outputDir: The directory to write output files to

Running Unit Tests

This project includes unit tests for the wordsCount and maxCount functions. To run the tests, first make sure you have Jest installed:

$ npm install --save-dev jest

Then, run the tests using the following command:

$ npm run test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published