This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tasked at work to clean user typed company name data (over 5k 'unique' companies), I needed to programmaticaly combine | |
# entries like 'E Trade', 'E*Trade', and 'E*Trade Financial'. Initial thought was to use Levenshtein ratios and other computer | |
# sciency heuristics. | |
# On second thought, the cleaned data was needed quickly, so I found an API that would autocomplete company names and leveraged it. | |
import requests | |
import csv | |
import Levenshtein | |
from tqdm import tqdm | |
import pickle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import consts | |
RHO_MATRICES = {tuple(np.linalg.matrix_power(np.array([[0,1],[2,3]]), t).dot(np.array([1,0])) % 5): t for t in range(0,24)} | |
RHO_MATRICES[(0,0)] = -1 | |
def arrTransform1(arr): | |
output = [[[0 for _ in range(64)] for _ in range(5)] for _ in range(5)] | |
for i in range(5): | |
for j in range(5): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Trie: | |
""" | |
Trie data structure implemented using dictionary | |
Parameters | |
---------- | |
dictioanry : array | |
An array of all the strings to be included in the trie | |
Attributes |