Skip to content

Instantly share code, notes, and snippets.

@bufas
bufas / earley.py
Created November 2, 2014 20:46
Basic Python implementation of the Earley algorithm for parse tree generation
class State(object):
def __init__(self, label, rules, dot_idx, start_idx, end_idx, idx, made_from, producer):
self.label = label
self.rules = rules
self.dot_idx = dot_idx
self.start_idx = start_idx
self.end_idx = end_idx
self.idx = idx
self.made_from = made_from
self.producer = producer
@bufas
bufas / ID3Classifier.py
Last active August 29, 2015 14:07
Barebones ID3 Classifier
__author__ = 'Mathias Bak Bertelsen'
__email__ = 'bufas@cs.au.dk'
from __future__ import division
import math
def segment_set_by_class(es):
return segment_set_by_attr(es, len(es[0])-1)
@bufas
bufas / Queue.java
Created October 3, 2014 13:09
Very simple FIFO queue implementation in Java
/**
* Author: Mathias Bak Bertelsen
* Email: bufas@cs.au.dk
* Date: 03-08-2014
*
* A very simple implementation of a generic FIFO queue.
*/
public class Queue<T> {