My name is Alessio Sclocco and I was born in Italy during year 1983.
I'm currently an MSc student in computer science at both the "Università degli Studi dell'Aquila" and the "Vrije Universiteit Amsterdam".

It is possible to contact me filling this form.

This website contains most of mine experiments with computers, for anyone interested in my personal life I have also a blog.

Alessio Sclocco

TV-Shows Name Changer 0.1

I have a lot of passions, between them computer science and tv-shows.
I wanted to learn a bit of Python before the holidays so I’ve developed a simple (really simple)  script in Python to change the filenames of my favorite tv-shows on the format that I prefer to archive them, something like “[LANG] TV-SHOW NAME – SEASONxEPISODE.ext“.

I’m not sure the script can be useful for someone else, but I like to share my code. The script can be downloaded here and can be read in the following part of the post.

"""
TV-Shows name changer

The script will change the filename of all the files in a certain dir to something like:
[LANG] TV-SHOW NAME - SEASONxEPISODE.ext

Usage: python showsNameChanger.py [options] [files]

Options:
-l ..., --language=...	the language of the show
-n ..., --name=...	the name of the show
-s ..., --season=...	the season
-e ..., --episode=...	the first episode of the list
-d ..., --dir=...	the directory where the files are (if not provided, the current directory is used)

Files:
If a user doesn't want to change all the files in a dir, it is possible to list all the files to rename on the command line.

Assumptions:
	1) The script will number all the files sequentially starting from the given episode number.
	2) The files must be alphabetically sortable.
"""

__author__ = "Alessio Sclocco - <alessio@sclocco.eu>"
__version__ = "$Revision: 0.1 $"
__copyright__ = "Copyright (c) 2009 Alessio Sclocco"
__license__ = "GNU General Public License version 3"

import os
import sys
import getopt

def usage():
	print __doc__

try:
	params, args = getopt.getopt(sys.argv[1:], "l:n:s:e:d:", ["language=", "name=", "season=", "episode=", "dir="])

except getopt.GetoptError:
	usage()
	sys.exit(-1)

if not params:
	usage()
	sys.exit(0)

lang = ""
show = ""
season = ""
episode = 1
dir = "."
fileList = []

for opt, arg in params:
	if opt in ("-l", "--language"):
		lang = arg
	elif opt in ("-n", "--name"):
		show = arg
	elif opt in ("-s", "--season"):
		season = arg
	elif opt in ("-e", "--episode"):
		episode = int(arg)
	elif opt in ("-d", "--dir"):
		dir = arg

if not args:
	fileList = os.listdir(dir)
	fileList.sort()
else:
	for file in args:
		fileList.append(file)
	fileList.sort()

for fileName in fileList:
	if fileName[0] == ".":
		continue
	else:
		newFileName = "[%s] %s - %sx%02d%s" % (lang, show, season, episode, os.path.splitext(fileName)[1])
		os.rename(dir + "/" + fileName, dir + "/" + newFileName)
	 	episode = episode + 1

sys.exit(0)

Information theory analyzer

Hello :)

I’ve taken an exam those summer called “Information theory” and as a project I’ve developed, with the help of Alfredo Aiello, a program for evaluating entropy (simple, joint and conditional) and mutual information of random variables (and subset of them) from a sample set.

Like every other time I want to share the code (that is licensed with GNU General Public License 3.0) with the whole world, so this is a zip file containing all the code.
There isn’t a makefile right now but you can easily find a way to compile it, the only external dependencies is my ArgumentList library.

After compiling it you can use it on command line just tiping:

./ITA <[-e] | [-j] | [-c] | [-m]> -n <null_char> <set_file> <input_file> <output_file>

Obviously you have to call your binary :)

The first parameter is for the operation wanted (-e for entropy, -j for joint entropy, -c for conditional entropy and -m for mutual information), the second is for setting the null char of the sample set and last three ones are filename.
The first of them (set_file) permits you to control which variable of the sample set is in which subset, I know I can be a little too enigmatic but I’ll provide an example later; the second (input_file)  is the file which contains the sample set and the third (output_file) is where do you want the output will be written.

The sample set format is really sample, is a text file where the columns are the variable and the rows are the samples, something like that:

1 0 n 1
n 2 n n
a 0 2 2
2 c 1 2

This is the description of a sample set with 4 samples and 4 variables.
The format for the set_file is really simple too, again a text file where the first number is the length of first subset and all the others are the indexes (starting from 0) of the columns in the subset.

Let’s for example evaluate the conditional entropy between those two subset of the previously given sample set:

X = {0, 2, 3}
Y = {1}

Then we’ll have to write a file (let’s call it example.set) like this one:

3 0 2 3 1

And, if our sample set is called example.txt, call the program in that way:

./ITA -c -n n example.set example.txt out.txt

Enjoy!

Finally I’ve found some time to publish the code I wrote for my BSc thesys, wow! :)

The problem is not in releasing source code but mainly in my lazyness, because I’ve just found the time to write a bash script to download some other code which my code depends on (my ArgumentList library and BlossomV-1.0 from Vladimir Kolmogorov) and create the right objects.

So, the bash script is that one (wget and git needed):

#!/bin/bash

# set the target directory for TSP_approx_algorithms
BASEDIR="./tsp/"

# wget executable
WGET="`which wget`"
# git executable
GIT="`which git`"
# tar executable
TAR="`which tar`"
# g++ executable
GPP="`which g++`"

$GIT clone git://github.com/isazi/TSP-Approximation-Algorithms.git $BASEDIR
cd $BASEDIR
mkdir bin
mkdir lib

mkdir .tmp
cd .tmp

$WGET http://www.cs.ucl.ac.uk/staff/V.Kolmogorov/software/blossom5-v1.0.src.tar.gz
$TAR xzvf blossom5-v1.0.src.tar.gz
cd blossom5-v1.0.src
$GPP -c -o ../../lib/misc.o misc.cpp
$GPP -c -o ../../lib/PMduals.o PMduals.cpp
$GPP -c -o ../../lib/PMexpand.o PMexpand.cpp
$GPP -c -o ../../lib/PMinit.o PMinit.cpp
$GPP -c -o ../../lib/PMinterface.o PMinterface.cpp
$GPP -c -o ../../lib/PMmain.o PMmain.cpp
$GPP -c -o ../../lib/PMrepair.o PMrepair.cpp
$GPP -c -o ../../lib/PMshrink.o PMshrink.cpp
cd MinCost
$GPP -c -o ../../../lib/MinCost.o MinCost.cpp
cd ..
cd ..

$WGET http://alessio.sclocco.eu/wp-content/uploads/2009/02/argumentlist-01tar.gz
$TAR xzvf argumentlist-01tar.gz
cd ArgumentList
$GPP -c -o ../../lib/ArgumentList.o ArgumentList.cpp
cd ..

cd ..
rm -r .tmp

exit 0

If you want, you can download the script already as a file from there, the only thing you must change is the BASEDIR variable; after the execution of the script you have just to change the INCLUDE constant on the Makefile and use make to compile to source.

The proper source code of my thesys is available, as you can see, from GitHUB; sorry but all the comments and strings are in Italian.