Giter VIP home page Giter VIP logo

roti-kapda-makaan's Introduction

A JS lib to generate unique combinations of hinglish words. ๐ŸŒฏ ๐Ÿฅป ๐Ÿ 

Website: https://roti-kapda-makaan.dev/

Why?

Imagine interacting with a company's help support and then receiving this robotic reference id:

'9e93d8dd-22aa-4439-a008-f33f4c8b0c69'

Now imagine doing the same but getting this reference id:

'23-mast-chai-cool-coffee'

The latter is enough to slightly amuse you, and much much easier to tell the company representative on call.

And that's the whole idea behind it, share ids which humans understand. It's easy to quote and might put a smile on their faces as well.

Installation

Node

npm install roti-kapda-makaan

Web

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/roti-kapda-makaan.js"></script>

Usage

Node

import { generate } from 'roti-kapda-makaan'

async function getHinglishId() {
    const id = await generate();
    return id;
}

Web

async function getHinglishId() {
    const id = await rotiKapdaMakaan.generate();
    return id;
}

How does it work?

I searched the internet to get a big enough list of hinglish words, and then separated them based on the word being a noun or an adjective. There were some other filters involved as well, for example frequency of the words used in day to day life and length of the words.

Once this set was prepared, I handpicked 64 adjectives and 128 nouns. Now, why 64 and 128 exactly?

Each id is combination of words, prefixed by a number. Something like:

number_prefix + random_adjective + random_noun + random_adjective + random_noun

The number_prefix can be from range 1-64, i.e. 2^6(64) different values of number_prefix are possible. In simple words, number_prefix represents 6 bits of information.

Coming to random_adjective, we only have 64 or 2^6 adjectives. So it also represents 6 bits of information.

And together they represent 12 bits, and 2^12 being 4096, that's the total number of unique combinations we can have:

number_prefix(6 bits) + random_adjective(6 bits) = 12 bits of information

And hence:

number_prefix(6 bits) + random_adjective(6 bits) + random_noun(7 bits) + random_adjective(6 bits) + random_noun(7 bits) = 32 bits of information

Which means there are 2^32(4,29,49,67,296) unique combinations of numbers, nouns and adjectives our function can generate!

roti-kapda-makaan's People

Contributors

iostreamer-x 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.