Skip to content

Instantly share code, notes, and snippets.

View mgill25's full-sized avatar
:electron:

Manish Gill mgill25

:electron:
View GitHub Profile
@mgill25
mgill25 / markov.rb
Created November 19, 2014 12:34
Markov generator finished
# Text Analysis for the Markov chain
# class Object
# def method_missing( name, *args )
# puts "There is no method '##{name}' defined on #{self.class}, you dummy!"
# end
# end
def get_ngrams(n, corpus)
output_list = []
@mgill25
mgill25 / markov.rb
Created November 6, 2014 04:10
Playing around with Markov chains
# Markov chain implementation in Ruby
# We take some text as input, apply the Markov chain algorithm to it,
# and produce some other text as output. Lets see how it is done!
# Markov chain means running an FSM with the states having unequal probability
# of transition.
# References:
# A Mathematical theory of Communication, by C.E. Shannon
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
StaQueue! A Queue created by using 2 stacks!
'''
# the builtin `list` type in python has all the capabilities
# of a stack, so we use that instead of trying to re-created
# the stack itself as well.