Ruby NLP: N-gram Analysis For Fun & Profit

What would you do if you are given a big collection of text & you want to extract some meaning out of it? A good start is to break up your text into n-grams. Here’s a description: In the fields of computational linguistics and probability, an n-gram is a contiguous sequence of n items from … Read more

How to Use Recursion & Memoization in Ruby

What is recursion in Ruby? Recursive functions are those that keep calling themselves until they hit an end goal (also known as the base case). After each function call you make progress towards this base case, reducing the amount of work left to be done. Once the base case is reached, the recursion ends, and … Read more

Static Analysis in Ruby

Let’s say that you want to parse your source code to find all your methods, where they are defined & what arguments do they take. How can you do this? Your first idea might be to write a regexp for it… But is there a better way? Yes! Static analysis is a technique you can … Read more

How to Debug & Fix Your Ruby Programs

How often does your program do exactly what you want the first time around? Many times our programs dont’t work like we expect, so we have to use the art of debugging ruby to help us finding out why. You may be familiar with the following error message: undefined method ‘some_method’ for nil:NilClass This means … Read more

How to Use Ruby Threads: An Easy To Understand Tutorial

What is a thread in Ruby? Threads make your Ruby programs do multiple things at the same time. Things like: Reading multiple files Handling multiple web request Making multiple API connections As a result of using threads, you’ll have a multi-threaded Ruby program, which is able to get things done faster. But one warning… In … Read more