Skip to content

Instantly share code, notes, and snippets.

@zbriscoe
zbriscoe / Snippet320.java
Created December 17, 2012 03:37
COMP 354
/*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@zbriscoe
zbriscoe / bigram.py
Created December 2, 2012 07:14
Bigram
import re
#italian
ital_text = re.sub('[^a-z]+', ' ', open('italian.txt').read().lower()).strip() + ' '
ital = {}
for i in xrange(len(ital_text) - 1):
bigram = ital_text[i : i + 2]
if bigram in ital:
continue
@zbriscoe
zbriscoe / 4x4naive_bayes.py
Created November 7, 2012 22:13 — forked from bwrsandman/4x4naive_bayes.py
4x4 naive bayes
#!/usr/bin/env python2
"""\
We are computing the probability of features 1 through 16.
Each feature represents a pixel in a 4 x 4 bitmap.
We are taking into account the probability that a pixel is black.
This simplifies calculations as the probability of white is equal to
the probability of !black.
"""
import numpy, math