Giter Club home page Giter Club logo

ttt's Introduction

Word frequency calculator

The program returns the top N most frequently occurring words in the file hosted at http://terriblytinytales.com/test.txt

Installation & Instructions (Ubuntu)

sudo apt-get install npm

Run Program

  • Clone the repository from GitHub.
  • Go to the repo folder through Terminal.
  • Run the following commands to install dependencies and run the program
npm install
npm start

Libraries/Modules used

  • Express : Node's framework, makes it easier to use.
  • Body Parser : To parse the data from HTML Form
  • Request : To send a request to http://terriblytinytales.com/test.txt
  • Mocha : Testing framework for Nodejs
  • Chai : Assertion library for tests

Functions (in function.js)

Frequency

This function takes an array of words as a parameter and returns an array with the even indexes containing the words and the immediately next odd indexes containing their frequencies.

frequency(arr); //where arr is the array of words

Convert

This function takes a data string and an integer N and returns the top N most frequently occurring words in the string.

convert(data, N); //where data is the data string and N is the integer.

The function is explained more with inline comments in the code.

Tests (in test.js)

Tests are run on a sample string and array that is defined in the file test.js itself. To run the tests, use the following command.

npm test

All the tests are self-explanatory and run perfectly. Below is a screenshot attached.

Test Screenshot

Thanks, for any help please email me at [email protected]

ttt's People

Contributors

nama-codes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.