Created
November 22, 2020 18:26
-
-
Save asdkant/3d714d89a244dbda918aa3194ff899ca to your computer and use it in GitHub Desktop.
Band ruiner
This file contains hidden or 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
#!/usr/bin/python | |
from nltk.corpus import words | |
import numpy as np | |
from pyxdameraulevenshtein import ( | |
damerau_levenshtein_distance_ndarray as distance_list) | |
from sys import argv | |
victim = " ".join(argv[1:]).lower() | |
wl = [w.lower() for w in words.words()] | |
def alternatives(v: str) -> list: | |
distances = distance_list(v.lower(), np.array(wl)).tolist() | |
return [i[0] for i in zip(wl, distances) if i[1] == 1] | |
proposals = [] | |
for i in victim.split(" "): | |
proposals = proposals + [victim.replace(i, a) for a in alternatives(i)] | |
for i in proposals: | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment