<commit_before>'''
Created on May 8, 2017

@author: Raz
'''

import numpy as np
import getopt
import sys
import os


def init_levenshtein_mat(notes1, notes2):
    levenshtein_mat = np.zeros((len(notes1)+1, len(notes2)+1))
    levenshtein_mat[0, :] = np.arange(0, len(notes2)+1)
    levenshtein_mat[:, 0] = np.arange(0, len(notes1)+1)
    return levenshtein_mat


def shift_notes(notes, shift):
    import copy
    notes = copy.deepcopy(notes)
    for curr_notes_idx in xrange(len(notes)):
        curr_notes = np.array(list(notes[curr_notes_idx]))
        curr_notes += shift
        notes[curr_notes_idx] = set(curr_notes)
    return notes


def run(notes1, notes2):
    num_diff_notes = 12
    scores = []
    for shift in xrange(num_diff_notes):
        print 'running shift%d:' % shift
        notes1_shift = shift_notes(notes1, shift)
        levenshtein_mat = run_levenshtein(notes1_shift, notes2)
        score = levenshtein_mat[
            levenshtein_mat.shape[0], levenshtein_mat.shape[1]]<commit_msg>fixed indexing for getting levenshtein score<commit_after>'''
Created on May 8, 2017

@author: Raz
'''

import numpy as np
import getopt
import sys
import os


def init_levenshtein_mat(notes1, notes2):
    levenshtein_mat = np.zeros((len(notes1)+1, len(notes2)+1))
    levenshtein_mat[0, :] = np.arange(0, len(notes2)+1)
    levenshtein_mat[:, 0] = np.arange(0, len(notes1)+1)
    return levenshtein_mat


def shift_notes(notes, shift):
    import copy
    notes = copy.deepcopy(notes)
    for curr_notes_idx in xrange(len(notes)):
        curr_notes = np.array(list(notes[curr_notes_idx]))
        curr_notes += shift
        notes[curr_notes_idx] = set(curr_notes)
    return notes


def run(notes1, notes2):
    num_diff_notes = 12
    scores = []
    for shift in xrange(num_diff_notes):
        print 'running shift%d:' % shift
        notes1_shift = shift_notes(notes1, shift)
        levenshtein_mat = run_levenshtein(notes1_shift, notes2)
        score = levenshtein_mat[
            levenshtein_mat.shape[0] - 1, levenshtein_mat.shape[1] - 1]
{'fraction_non_alphanumeric': 0.11245758603974794, 'fraction_numerical': 0.029083858458555503, 'mean_word_length': 3.607142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3777315', 'n_tokens_mistral': 791, 'n_tokens_neox': 746, 'n_words': 158}