Skip to main content

Posts

Amazing Word clouds using python

Ever wondered how word clouds are generated from a big text corpus? In this post we learn how to make interesting word clouds using simple natural language processing and python. What are word clouds? Word clouds are a way of representing some of the most important words or some of the most occurring words from the big text corpus. In this post we will consider the some speeches by George Bush as our test corpus and make a word cloud from the words that occur the most in the speeches. Steps taken Load the speeches and store them in a variable Remove all the stopwords, stop words are words like 'the', 'and', 'this' and they can be removed for our current purpose. Remove all the punctuation's Construct word cloud consisting of 100 most frequent words and save the image Lets have a look at the code The above code produces the following image as the output Now, the above code produces a simple image, we can mask and try to make our wor...

Vigenere decipher process

In an earlier post we discussed a method to encrypt a string using Vigenere Cipher, in this post we see the method to decrypt the encrypted message. The  Vigenère cipher  is a method of  encrypting   alphabetic  text by using a series of interwoven  Caesar ciphers  based on the letters of a keyword.  It is a form of  polyalphabetic substitution . Even though the vigenere cipher is easy to understand and implement, for three centuries it resisted all attempts to break it. In order to encrypt a given message, a table of alphabets can be used, termed a  tabula recta , The following is the image of the Table. the above table   consists of the alphabet written out 26 times in different rows, each alphabet shifted cyclically to the left compared to the previous alphabet.  At different points in the encryption process, the cipher uses a different alphabet from one of the rows. The alphabet used at each point depe...

Encrypt files using Vigenere Cipher

In this post we discuss a method to encrypt your files using  Vigenère Cipher . The  Vigenère cipher  is a method of  encrypting   alphabetic  text by using a series of interwoven  Caesar ciphers  based on the letters of a keyword.  It is a form of  polyalphabetic substitution . Even though the vigenere cipher is easy to understand and implement, for three centuries it resisted all attempts to break it. In order to encrypt a given message, a table of alphabets can be used, termed a  tabula recta , The following is the image of the Table. the above table   consists of the alphabet written out 26 times in different rows, each alphabet shifted cyclically to the left compared to the previous alphabet.  At different points in the encryption process, the cipher uses a different alphabet from one of the rows. The alphabet used at each point depends on a repeating keyword. Now let us consider an example...

Counting sort Algorithm

 Want to sort numbers in a given range? Use Counting sort algorithm. Counting sort is a integer sorting algorithm, It is a non-comparison sorting algorithm as it does not compare different elements rather it uses index of elements and their count while sorting them. Counting sort is a linear sorting algorithm and must be used when elements are in a given range and variation in the elements is not much. It simply operates by counting the number of occurrences of  different elements in a given range, as it is a linear sorting technique it has time complexity of   O(n + k) where 'n' is the number of elements in the array and 'k' is the number of elements between max and min elements. let us consider the below example,  let the array of numbers to be sorted be  arr = {1,3,2,1,3,3,2} here, n = 7, min = 1, max = 3 hence k = 3 now we create a array that holds counts of all the elements, 1 has occurred 2 times, 2 has occurred 2 times and 3 has o...

Quick Sort Algorithm using Recursion

Quick sort is one of the most important and widely used sorting algorithm. Quick sort is a very efficient algorithm which if implemented well can run two to three times faster than its competitors merge sort and and heap sort. The algorithm is a divide and conquer algorithm. The algorithm works by selecting a pivot element, this pivot element is usually the first element and choice of the pivot element affects the running time of the algorithm. The algorithm is basically to select a pivot element and then moving all the element less than the pivot element to its left and all the elements greater than pivot element to its right. Then we divide the array into 2 parts, one on the left of the pivot and other on the right of the pivot and then pass these 2 arrays to the algorithm for further sorting. Algorithm : Choose a Pivot element. Take 2 variables left_marker and right_marker excluding the pivot element. Set left_marker as the first element of the array Set right_marker as the...

Installing python modules without pip

Ever wanted to install python modules, but you were unable to do it using pip install command, or simply wanted to do it using python, if so then this is the post you want to read.  pip module is now by default installed when you install the latest python, if you want to install multiple python modules you can either enter pip commands in command prompt or terminal or make a batch file, In this post, we will see how to install all the modules that you want by executing a python program. Lets look at the code,  In the above code you can simply put the modules you want to install in the list and execute the code. You might also be interested in  Data Encryption using Caesar Cipher Data Decryption using Caesar Cipher LCM of 2 numbers Anagram Strings Double Linked List Finding Middle node in a Linked List Infix to Prefix Conversion

Data decryption using Caesar Cipher

In the previous blog post we discussed about Encryption of a file using Caesar Cipher, in this post we discuss a method to decrypt the same file. If you want to view the previous post on Encryption using Caesar Cipher click HERE . Decryption is a process of decoding the encrypting the encrypted file, to do this we need to know 2 things, the first is the method of encryption and the second is cipher key which in this case is our shift value. once we know these things we can start deciphering the files.  As caesar cipher is a substitution cipher, shift value decides which value is replaced with another value, in encryption we replace each letter by the letter to its right by shift value position, hence now we need to do the opposite, we have to replace each letter by the letter to its left by shift value positions. So for shift value of 3 we have, Plaintext :          ABCDEFGHIJKLMNOPQRSTUVWXYZ  decipher text :     XYZ AB...