Skip to content

Instantly share code, notes, and snippets.

@angeloskath
angeloskath / pre-commit.sh
Created December 4, 2014 21:27
PHP style checking pre-commit hook
#!/bin/bash
CHANGED_FILES=`git diff-index --name-only --cached HEAD`
SUCCESS=1
FILES=""
for f in $CHANGED_FILES
do
# check file f for style errors
TMP=`php-cs-fixer fix --level=psr2 --dry-run $f | head -n -1 | sed "s/ \+/ /" | cut -d " " -f 3`
@angeloskath
angeloskath / sms-spam-detection.php
Created August 26, 2013 15:43
Naive Bayes example using NlpTools
<?php
include('vendor/autoload.php');
use NlpTools\Tokenizers\WhitespaceTokenizer;
use NlpTools\Models\FeatureBasedNB;
use NlpTools\Documents\TrainingSet;
use NlpTools\Documents\TokensDocument;
use NlpTools\FeatureFactories\DataAsFeatures;
use NlpTools\Classifiers\MultinomialNBClassifier;
@angeloskath
angeloskath / README.md
Last active December 18, 2015 10:19
Comparison of the hierarchical clustering implementations in NlpTools (php) and nltk (python).

Hierarchical clustering php vs python

Cluster 500 2-dimensional euclidean points using hierarchical clustering with group average linkage and cosine similarity as distance metric. The python implementation is from the nltk library and the php one is from NlpTools.

To run the test you need to install those libraries, you will find instructions in the corresponding sites.

Results