Skip to content

Instantly share code, notes, and snippets.

import time
import re
import unicodedata
'''
listado de palabras que quiero descartar
'''
pal_comunes = ['los','las','sin','con','tan','por']
lista_categorias = ['lacteos','comestibles','auto','hogar']
lista_productos = ['leche','huevo','aceite','yerba']
@sanchezg
sanchezg / download_and_pickle_stories.py
Created October 22, 2015 12:46 — forked from glarrain/download_and_pickle_stories.py
Exporting data from Pivotal Tracker is a pain in the ass. The following scripts let you download all the stories of a given project, and then (optionally) extract all the attachments linked to those, and download them
"""Download stories of a Pivotal Tracker project.
You need the project ID (an int) and your API token. The latter can be
obtained in ``https://www.pivotaltracker.com/profile``, or using curl::
$ curl -u username:password -X GET https://www.pivotaltracker.com/services/v3/tokens/active
"""
import getpass
import pickle
/* Merge sort in C */
#include<stdio.h>
#include<stdlib.h>
// Function to Merge Arrays L and R into A.
// lefCount = number of elements in L
// rightCount = number of elements in R.
void Merge(int *A,int *L,int leftCount,int *R,int rightCount) {
int i,j,k;
@sanchezg
sanchezg / twoBases.cpp
Created February 5, 2016 15:03
Problem with multiple inheritance: the vtable get lost!
#include <iostream>
using namespace std;
struct Base1
{
virtual void hola() = 0;
};
struct Base2
{
def classify_elements(dataset, interest_key, classifications_number):
"""
This function tries to classify a set of continuous features from a
dataset into a
"""
keys = dataset.keys()
if interest_key not in keys:
print 'The feature is not in the dataset'
return
count_elements = len(dataset)
@sanchezg
sanchezg / hal9000.py
Last active March 9, 2016 23:05
Script to pick and print a random quote from HAL9000.
#!/usr/bin/python
"""
Random HAL9000 quotes generator. Quotes are taken from quotes.hal file.
"""
from random import randint
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
import numpy as np
class DirectTransformer:
"""Utility for building class-like features from a single-point function, but that may need
some general configuration first (you usually override __init__ for that)
"""
def fit(self, X, y=None):
return self
import numpy as np
class OneHotTransformer:
def __init__(self, func):
self.f = func
def fit(self, X, y=None):
unseen = object()
seen = set()
for x in X:
from sklearn.feature_extraction.text import CountVectorizer
class ProjectionCountVectorizer(CountVectorizer):
def __init__(self, projection_path, *args, **kwargs):
self.projection_path = projection_path.split('/')
super().__init__(*args, **kwargs)
def build_preprocessor(self):
built = super().build_preprocessor()
@sanchezg
sanchezg / singleton1.py
Created December 12, 2016 12:46
Differents singletons implementation in python. From http://stackoverflow.com/a/6798042 & http://stackoverflow.com/a/7346105
class Singleton(object):
_instances = {}
def __new__(class_, *args, **kwargs):
if class_ not in class_._instances:
class_._instances[class_] = super(Singleton, class_).__new__(class_, *args, **kwargs)
return class_._instances[class_]
class MyClass(Singleton):
pass