This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
NewerOlder