Skip to content

Instantly share code, notes, and snippets.

View baali's full-sized avatar
🏠
Working from home

baali baali

🏠
Working from home
View GitHub Profile
@baali
baali / manual_nltk_bayes_classify.py
Created December 15, 2011 07:12 — forked from lrvick/manual_nltk_bayes_classify.py
Manually train an NLTK NaiveBayes Classifier
from nltk.probability import ELEProbDist, FreqDist
from nltk import NaiveBayesClassifier
from collections import defaultdict
train_samples = {
'I hate you and you are a bad person': 'neg',
'I love you and you are a good person': 'pos',
'I fail at everything and I want to kill people' : 'neg',
'I win at everything and I want to love people' : 'pos',
'sad are things are heppening. fml' : 'neg',
@baali
baali / dump_file.cpp
Created August 24, 2012 07:58
DebugProtocol to print payload in human redable form.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@baali
baali / fileComparison.py
Created May 13, 2012 06:03
To check for duplicate files
if bool(fileName):
flag = 1
filePath = os.path.join(detach_dir, 'attachments', fileName)
if not os.path.isfile(filePath) :
print fileName
fp = open(filePath, 'wb')
fp.write(part.get_payload(decode=True))
fp.close()
else:
tmpPath = os.path.join(detach_dir, 'attachments', fileName+'tmp')
@baali
baali / audio.html
Created May 4, 2012 17:20
chrome api for speech recognition
<!DOCTYPE html>
<html manifest="cache.appcache">
<head>Speech Recognition</head>
<body>
<input type="text" x-webkit-speech />
</body>
</html>
@baali
baali / permute_list.erl
Created April 10, 2012 08:05
Permutation of List in Erlang
-module('permute_list').
-export([permute/1, permute/2]).
permute(List) ->
permute(List, length(List)).
permute(List, Length) ->
Indices = [],
Permuted_List = [],
jumble(List, Permuted_List, Indices, Length).