Dataset Viewer
Auto-converted to Parquet
path
stringlengths
9
117
type
stringclasses
2 values
project
stringclasses
10 values
commit_hash
stringlengths
40
40
commit_message
stringlengths
1
137
ground_truth
stringlengths
0
2.74k
main_code
stringlengths
102
3.37k
context
stringlengths
0
14.7k
LanguageChecker/languageChecker.__init__
Modified
Ciphey~Ciphey
21adbd61fb2fb19bd135b1c0107c82b4f0c704bb
worked on chi squared and started building a new maths helper class
<5>:<add> self.average = 0.0 <add> self.totalDone = 0.0 <add> self.oldAverage = 0.0
# module: LanguageChecker class languageChecker: def __init__(self): <0> self.languages = { <1> "English": <2> [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <3> #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} <4> } <5>
===========unchanged ref 0=========== at: collections OrderedDict(map: Mapping[_KT, _VT], **kwargs: _VT) OrderedDict(**kwargs: _VT) OrderedDict(iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) ===========changed ref 0=========== # module: LanguageChecker + """ + ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗ + ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝ + ██║ ██║██████╔╝███████║█████╗ ╚████╔╝ + ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝ + ╚██████╗██║�</s> ===========changed ref 1=========== # module: LanguageChecker # offset: 1 <s>��█████╗██║██║ ██║ ██║███████╗ ██║ + © Brandon Skerritt + Github: brandonskerritt + + Class to determine whether somethine is English or not. + 1. Calculate the Chi Squared score of a sentence + 2. If the score is significantly lower than the average score, it _might_ be English + 3. + """ + """ {"E": 12.02, "T": 9.10, "A": 8.12, "O": 7.68, "I": 7.31, "N": 6.95, "S": 6.28, "R": 6.02, "H": 5.92, "D": 4.32, "L": 3.98, "U": 2.88, "C": 2.71, "M": 2.61, "F": 2.30, "Y": 2.11, "W": 2.09, "G": 2.03, "P": 1.82, "B": 1.49, "V": 1.11, "K": 0.69, "X": 0.17, "Q": 0.11, "J": 0.10, "Z": 0.07 } """ ===========changed ref 2=========== + # module: env.lib.python3.6.site-packages.pip.utils.appdirs + + ===========changed ref 3=========== + # module: env.lib.python3.6.site-packages.pip.commands.freeze + + ===========changed ref 4=========== + # module: env.lib.python3.6.site-packages.pip.commands.search + + ===========changed ref 5=========== + # module: env.lib.python3.6.site-packages.pip.utils.outdated + + ===========changed ref 6=========== + # module: env.lib.python3.6.site-packages.pip.req.req_file + + ===========changed ref 7=========== + # module: env.lib.python3.6.site-packages.pip.basecommand + + ===========changed ref 8=========== + # module: env.lib.python3.6.site-packages.pip.commands.uninstall + + ===========changed ref 9=========== + # module: env.lib.python3.6.site-packages.setuptools.command.setopt + + ===========changed ref 10=========== + # module: env.lib.python3.6.site-packages.setuptools.extension + + ===========changed ref 11=========== + # module: env.lib.python3.6.site-packages.pip.wheel + + ===========changed ref 12=========== + # module: env.lib.python3.6.site-packages.setuptools.command.bdist_wininst + + ===========changed ref 13=========== + # module: env.lib.python3.6.site-packages.pip.commands.show + + ===========changed ref 14=========== + # module: env.lib.python3.6.site-packages.setuptools.glibc + + ===========changed ref 15=========== + # module: env.lib.python3.6.site-packages.pip.compat + + ===========changed ref 16=========== + # module: env.lib.python3.6.site-packages.pip.req.req_set + + ===========changed ref 17=========== + # module: env.lib.python3.6.site-packages.pip.exceptions + + ===========changed ref 18=========== + # module: env.lib.python3.6.site-packages.pip.utils.packaging + + ===========changed ref 19=========== + # module: env.lib.python3.6.site-packages.setuptools.command.build_py + + ===========changed ref 20=========== + # module: env.lib.python3.6.site-packages.setuptools.msvc + + ===========changed ref 21=========== + # module: env.lib.python3.6.site-packages.setuptools.namespaces + + ===========changed ref 22=========== + # module: env.lib.python3.6.site-packages.setuptools.config + + ===========changed ref 23=========== + # module: env.lib.python3.6.site-packages.pip.commands.help + + ===========changed ref 24=========== + # module: env.lib.python3.6.site-packages.setuptools.command.build_ext + + ===========changed ref 25=========== + # module: env.lib.python3.6.site-packages.pkg_resources._vendor.packaging.requirements + + ===========changed ref 26=========== + # module: env.lib.python3.6.site-packages.pip.utils.deprecation + + ===========changed ref 27=========== + # module: env.lib.python3.6.site-packages.pip.commands.install + + ===========changed ref 28=========== + # module: env.lib.python3.6.site-packages.pkg_resources._vendor.packaging.markers + + ===========changed ref 29=========== + # module: env.lib.python3.6.site-packages.pip.utils.hashes + + ===========changed ref 30=========== + # module: env.lib.python3.6.site-packages.setuptools._vendor.packaging._compat + + ===========changed ref 31=========== + # module: env.lib.python3.6.site-packages.setuptools.command.upload + + ===========changed ref 32=========== + # module: env.lib.python3.6.site-packages.pkg_resources._vendor.packaging._compat + + ===========changed ref 33=========== + # module: env.lib.python3.6.site-packages.setuptools.command.easy_install + + ===========changed ref 34=========== + # module: env.lib.python3.6.site-packages.setuptools.lib2to3_ex + + ===========changed ref 35=========== + # module: env.lib.python3.6.site-packages.pip.commands.wheel + + ===========changed ref 36=========== + # module: env.lib.python3.6.site-packages.pip.utils + + ===========changed ref 37=========== + # module: env.lib.python3.6.site-packages.setuptools.command.install_scripts + + ===========changed ref 38=========== + # module: env.lib.python3.6.site-packages.setuptools.command.register + +
LanguageChecker/languageChecker.chiSquared
Modified
Ciphey~Ciphey
21adbd61fb2fb19bd135b1c0107c82b4f0c704bb
worked on chi squared and started building a new maths helper class
<8>:<add> # if letter is not puncuation, but it is still ascii <add> # it's probably a different language so add it to the dict <add> if letter not in punctuation and self.isAscii(letter) : <add> letterFreq[letter] = 1 <add> <del> continue <30>:<add> # calculates running average <add> self.oldAverage = self.average <add> self.totalDone += 1 <add> self.average = self.average + (chisquare / self.totalDone)
# module: LanguageChecker class languageChecker: def chiSquared(self, text): <0> print(text) <1> # creates letter frequency of the text <2> # do this so it matches up with the list <3> letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} <4> for letter in text: <5> if letter in letterFreq: <6> letterFreq[letter] +=1 <7> else: <8> continue <9> # so we dont have to calculate len more than once <10> # turns them into probabilities (frequency distribution) <11> lenOfString = len(text) <12> for key, value in letterFreq.items(): <13> try: <14> letterFreq[key] = value / lenOfString <15> except ZeroDivisionError as e: <16> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <17> exit(1) <18> <19> # calculates chi squared of each language <20> maxChiSquare = 0.00 <21> languagesChi = {} <22> highestLanguage = "" <23> for language in self.languages: <24> #, list(languages[language].values()) <25> temp = self.myChi(letterFreq, self.languages[language]) <26> languagesChi[language] = temp <27> """if temp >= maxChiSquare: <28> #maxChiSquare = temp <29> highestLanguage = language""" <30> return(languagesChi) </s>
===========unchanged ref 0=========== at: LanguageChecker.languageChecker isAscii(letter) at: LanguageChecker.languageChecker.chiSquared self.oldAverage = self.average self.totalDone += 1 self.average = self.average + (chisquare / self.totalDone) at: string punctuation = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" ===========changed ref 0=========== # module: LanguageChecker class languageChecker: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } + self.average = 0.0 + self.totalDone = 0.0 + self.oldAverage = 0.0 ===========changed ref 1=========== # module: LanguageChecker + """ + ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗ + ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝ + ██║ ██║██████╔╝███████║█████╗ ╚████╔╝ + ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝ + ╚██████╗██║�</s> ===========changed ref 2=========== # module: LanguageChecker # offset: 1 <s>��█████╗██║██║ ██║ ██║███████╗ ██║ + © Brandon Skerritt + Github: brandonskerritt + + Class to determine whether somethine is English or not. + 1. Calculate the Chi Squared score of a sentence + 2. If the score is significantly lower than the average score, it _might_ be English + 3. + """ + """ {"E": 12.02, "T": 9.10, "A": 8.12, "O": 7.68, "I": 7.31, "N": 6.95, "S": 6.28, "R": 6.02, "H": 5.92, "D": 4.32, "L": 3.98, "U": 2.88, "C": 2.71, "M": 2.61, "F": 2.30, "Y": 2.11, "W": 2.09, "G": 2.03, "P": 1.82, "B": 1.49, "V": 1.11, "K": 0.69, "X": 0.17, "Q": 0.11, "J": 0.10, "Z": 0.07 } """ ===========changed ref 3=========== + # module: env.lib.python3.6.site-packages.pip.utils.appdirs + + ===========changed ref 4=========== + # module: env.lib.python3.6.site-packages.pip.commands.freeze + + ===========changed ref 5=========== + # module: env.lib.python3.6.site-packages.pip.commands.search + + ===========changed ref 6=========== + # module: env.lib.python3.6.site-packages.pip.utils.outdated + + ===========changed ref 7=========== + # module: env.lib.python3.6.site-packages.pip.req.req_file + + ===========changed ref 8=========== + # module: env.lib.python3.6.site-packages.pip.basecommand + + ===========changed ref 9=========== + # module: env.lib.python3.6.site-packages.pip.commands.uninstall + + ===========changed ref 10=========== + # module: env.lib.python3.6.site-packages.setuptools.command.setopt + + ===========changed ref 11=========== + # module: env.lib.python3.6.site-packages.setuptools.extension + + ===========changed ref 12=========== + # module: env.lib.python3.6.site-packages.pip.wheel + + ===========changed ref 13=========== + # module: env.lib.python3.6.site-packages.setuptools.command.bdist_wininst + + ===========changed ref 14=========== + # module: env.lib.python3.6.site-packages.pip.commands.show + + ===========changed ref 15=========== + # module: env.lib.python3.6.site-packages.setuptools.glibc + + ===========changed ref 16=========== + # module: env.lib.python3.6.site-packages.pip.compat + + ===========changed ref 17=========== + # module: env.lib.python3.6.site-packages.pip.req.req_set + + ===========changed ref 18=========== + # module: env.lib.python3.6.site-packages.pip.exceptions + + ===========changed ref 19=========== + # module: env.lib.python3.6.site-packages.pip.utils.packaging + + ===========changed ref 20=========== + # module: env.lib.python3.6.site-packages.setuptools.command.build_py + + ===========changed ref 21=========== + # module: env.lib.python3.6.site-packages.setuptools.msvc + + ===========changed ref 22=========== + # module: env.lib.python3.6.site-packages.setuptools.namespaces + + ===========changed ref 23=========== + # module: env.lib.python3.6.site-packages.setuptools.config + + ===========changed ref 24=========== + # module: env.lib.python3.6.site-packages.pip.commands.help + +
LanguageChecker/languageChecker.__init__
Modified
Ciphey~Ciphey
5cc0944997e03729712b9f313350df9f045b7669
added dictionary and worked on english processor
<8>:<add> self.mh = mathsHelper.mathsHelper() <add> self.totalWordsTried = 0.0
# module: LanguageChecker class languageChecker: def __init__(self): <0> self.languages = { <1> "English": <2> [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <3> #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} <4> } <5> self.average = 0.0 <6> self.totalDone = 0.0 <7> self.oldAverage = 0.0 <8>
===========unchanged ref 0=========== at: collections OrderedDict(map: Mapping[_KT, _VT], **kwargs: _VT) OrderedDict(**kwargs: _VT) OrderedDict(iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) at: string punctuation = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" ===========changed ref 0=========== # module: mathsHelper + class mathsHelper: + def __init__(self): + print("nothing") + ===========changed ref 1=========== # module: mathsHelper + class mathsHelper: + def percentage(self, part, whole): + return 100 * float(part)/float(whole) + ===========changed ref 2=========== # module: mathsHelper - def percentage(self, part, whole): - return 100 * float(part)/float(whole) -
LanguageChecker/languageChecker.checkChi
Modified
Ciphey~Ciphey
5cc0944997e03729712b9f313350df9f045b7669
added dictionary and worked on english processor
<0>:<add> # TODO 20% isn't optimal <1>:<add> # the or statement is bc if the program has just started I don't want it to ignore the <add> # ones at the start <add> # TODO is 10 optimal? <add> # TODO is 45 optimal? <add> if self.mh.percentage(self.oldAverage, self.average) >= 20 or self.totalDone < 10: <del> if percentage(self.oldAverage, self.average) >= 20: <2>:<add> percetageOfEnglish = checkEnglish(text) <add> print("Ok, it's significant!") <del> print("Ok, it's significant!") <3>:<add> if percetageOfEnglish > 45: <add> print("I'm pretty sure this is English")
# module: LanguageChecker class languageChecker: def checkChi(self): <0> # runs after every chi squared to see if it's 1 significantly lower than averae <1> if percentage(self.oldAverage, self.average) >= 20: <2> print("Ok, it's significant!") <3>
===========unchanged ref 0=========== at: LanguageChecker.languageChecker.__init__ self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 at: LanguageChecker.languageChecker.chiSquared languagesChi[language] = temp ===========changed ref 0=========== # module: LanguageChecker class languageChecker: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 + self.mh = mathsHelper.mathsHelper() + self.totalWordsTried = 0.0 ===========changed ref 1=========== # module: mathsHelper + class mathsHelper: + def __init__(self): + print("nothing") + ===========changed ref 2=========== # module: mathsHelper + class mathsHelper: + def percentage(self, part, whole): + return 100 * float(part)/float(whole) + ===========changed ref 3=========== # module: mathsHelper - def percentage(self, part, whole): - return 100 * float(part)/float(whole) -
ciphey-main/Ciphey.__init__
Modified
Ciphey~Ciphey
5cc0944997e03729712b9f313350df9f045b7669
added dictionary and worked on english processor
<0>:<del> print("hello!") <4>:<add> parser.add_argument('-g','--greppable', help='Are you grepping this output?', required=False) <add> <5>:<add> print(""" <add> ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗ <add> ██╔════╝██║██╔══██╗██║ ██║██
# module: ciphey-main class Ciphey: def __init__(self): <0> print("hello!") <1> parser = argparse.ArgumentParser(description='Blog') <2> parser.add_argument('-f','--file', help='File you want to decrypt', required=False) <3> parser.add_argument('-l','--level', help='How many levels of decryption you want (the more levels, the slower it is)', required=False) <4> args = vars(parser.parse_args()) <5> LanguageChecker.chisquare("hello this is a test I hope you have a good day") <6>
===========changed ref 0=========== # module: mathsHelper + class mathsHelper: + def __init__(self): + print("nothing") + ===========changed ref 1=========== # module: mathsHelper + class mathsHelper: + def percentage(self, part, whole): + return 100 * float(part)/float(whole) + ===========changed ref 2=========== # module: mathsHelper - def percentage(self, part, whole): - return 100 * float(part)/float(whole) - ===========changed ref 3=========== # module: LanguageChecker class languageChecker: + def checkEnglish(self, text): + # reads through most common words / passwords + # and calculates how much of that is in English + text = text.split(" ") + text = text.sort() + f = open("dictionary.txt", "r") + f = f.readlines() + counter = 0.00 + # dictionary is "word\n" so I remove the "\n" + for word[0:-2] in f: + if word == text: + counter = counter + 1 + counter = mh.percentage(counter, len(text)) + return counter + ===========changed ref 4=========== # module: LanguageChecker class languageChecker: def checkChi(self): + # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae + # the or statement is bc if the program has just started I don't want it to ignore the + # ones at the start + # TODO is 10 optimal? + # TODO is 45 optimal? + if self.mh.percentage(self.oldAverage, self.average) >= 20 or self.totalDone < 10: - if percentage(self.oldAverage, self.average) >= 20: + percetageOfEnglish = checkEnglish(text) + print("Ok, it's significant!") - print("Ok, it's significant!") + if percetageOfEnglish > 45: + print("I'm pretty sure this is English") ===========changed ref 5=========== # module: LanguageChecker class languageChecker: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 + self.mh = mathsHelper.mathsHelper() + self.totalWordsTried = 0.0
app.mathsHelper/mathsHelper.percentage
Modified
Ciphey~Ciphey
4be6c646ae9966d006a1173b63a09e98c42fb417
wow would you believe this chi squared works
<1>:<add> # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea <add> # this if statememt is to stop my stupidity <add> if part or whole <= 0: <add> return 0 <add>
# module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): <0> """Works with percentages""" <1> # works with percentages <2> return 100 * float(part)/float(whole) <3>
===========changed ref 0=========== + # module: mathsHelper + + ===========changed ref 1=========== + # module: mathsHelper + + ===========changed ref 2=========== + # module: mathsHelper + """ + ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗ + ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝ + ██║ ██║██████╔╝███████║█████╗ ╚████╔╝ + ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝ + ╚██████╗██�</s> ===========changed ref 3=========== + # module: mathsHelper # offset: 1 <s>�██████╗██║██║ ██║ ██║███████╗ ██║ + © Brandon Skerritt + Github: brandonskerritt + """ +
app.languageChecker.chisquared/chiSquared.__init__
Modified
Ciphey~Ciphey
4be6c646ae9966d006a1173b63a09e98c42fb417
wow would you believe this chi squared works
<10>:<add> self.totalChi = 0.0 <del>
# module: app.languageChecker.chisquared class chiSquared: def __init__(self): <0> self.languages = { <1> "English": <2> [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <3> #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} <4> } <5> self.average = 0.0 <6> self.totalDone = 0.0 <7> self.oldAverage = 0.0 <8> self.mh = mathsHelper.mathsHelper() <9> self.highestLanguage = "" <10> <11> <12> # these are settings that may impact how the program works overall <13> self.chiSquaredSignificaneThreshold = 20 <14> self.totalDoneThreshold = 10 <15>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.chiSquared self.oldAverage = self.average self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone ===========changed ref 0=========== + # module: mathsHelper + + ===========changed ref 1=========== + # module: mathsHelper + + ===========changed ref 2=========== + # module: app.runTests + test_chi_squared.tests() + ===========changed ref 3=========== + # module: app.runTests + sys.path.append("..") + ===========changed ref 4=========== + # module: app.languageChecker.test + ch = chisquared.chiSquared() + """ + Tests to see whether a sentene is classified as English or not + """ + result = chi.checkChi("Hello my name is Brandon and I'm a top secret message") + print(result) + ===========changed ref 5=========== # module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): """Works with percentages""" + # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea + # this if statememt is to stop my stupidity + if part or whole <= 0: + return 0 + # works with percentages return 100 * float(part)/float(whole) ===========changed ref 6=========== + # module: mathsHelper + """ + ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗ + ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝ + ██║ ██║██████╔╝███████║█████╗ ╚████╔╝ + ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝ + ╚██████╗██�</s> ===========changed ref 7=========== + # module: mathsHelper # offset: 1 <s>�██████╗██║██║ ██║ ██║███████╗ ██║ + © Brandon Skerritt + Github: brandonskerritt + """ +
app.languageChecker.chisquared/chiSquared.checkChi
Modified
Ciphey~Ciphey
4be6c646ae9966d006a1173b63a09e98c42fb417
wow would you believe this chi squared works
<16>:<add> if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: <del> if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < totalDoneThreshold: <17>:<add> print("It's significant!") <del> percetageOfEnglish = checkEnglish(text)
# module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): <0> """Checks to see if the Chi score is good <1> if it is, it returns True <2> Call this when you want to determine whether something is likely to be Chi or not <3> <4> Arguments: <5> * text - the text you want to run a Chi Squared score on <6> <7> Outputs: <8> * True - if it has a significantly lower chi squared score <9> * False - if it doesn't have a significantly lower chi squared score <10> """ <11> # TODO 20% isn't optimal <12> # runs after every chi squared to see if it's 1 significantly lower than averae <13> # the or statement is bc if the program has just started I don't want it to ignore the <14> # ones at the start <15> self.chiSquared(text) <16> if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < totalDoneThreshold: <17> percetageOfEnglish = checkEnglish(text) <18> return(True) <19> else: <20> return(False) <21>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.chiSquared self.highestLanguage = language ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" + self.totalChi = 0.0 - # these are settings that may impact how the program works overall self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 ===========changed ref 1=========== + # module: mathsHelper + + ===========changed ref 2=========== + # module: mathsHelper + + ===========changed ref 3=========== + # module: app.runTests + test_chi_squared.tests() + ===========changed ref 4=========== + # module: app.runTests + sys.path.append("..") + ===========changed ref 5=========== + # module: app.languageChecker.test + ch = chisquared.chiSquared() + """ + Tests to see whether a sentene is classified as English or not + """ + result = chi.checkChi("Hello my name is Brandon and I'm a top secret message") + print(result) + ===========changed ref 6=========== # module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): """Works with percentages""" + # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea + # this if statememt is to stop my stupidity + if part or whole <= 0: + return 0 + # works with percentages return 100 * float(part)/float(whole) ===========changed ref 7=========== + # module: mathsHelper + """ + ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗ + ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝ + ██║ ██║██████╔╝███████║█████╗ ╚████╔╝ + ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝ + ╚██████╗██�</s> ===========changed ref 8=========== + # module: mathsHelper # offset: 1 <s>�██████╗██║██║ ██║ ██║███████╗ ██║ + © Brandon Skerritt + Github: brandonskerritt + """ +
app.languageChecker.chisquared/chiSquared.chiSquared
Modified
Ciphey~Ciphey
4be6c646ae9966d006a1173b63a09e98c42fb417
wow would you believe this chi squared works
<10>:<add> if letter not in punctuation and self.mh.isAscii(letter) : <del> if letter not in punctuation and self.isAscii(letter) :
# module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): <0> """Creates letter frequency of text and compares that to the letter frequency of the language""" <1> <2> # This part creates a letter frequency of the text <3> letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} <4> for letter in text: <5> if letter in letterFreq: <6> letterFreq[letter] +=1 <7> else: <8> # if letter is not puncuation, but it is still ascii <9> # it's probably a different language so add it to the dict <10> if letter not in punctuation and self.isAscii(letter) : <11> letterFreq[letter] = 1 <12> <13> # so we dont have to calculate len more than once <14> # turns them into probabilities (frequency distribution) <15> lenOfString = len(text) <16> for key, value in letterFreq.items(): <17> try: <18> letterFreq[key] = value / lenOfString <19> except ZeroDivisionError as e: <20> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <21> exit(1) <22> <23> # calculates chi squared of each language <24> maxChiSquare = 0.00 <25> languagesChi = {} <26> <27> for language in self.languages: <28> #, list(languages[language].values()) <29> temp = self.</s>
===========below chunk 0=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 languagesChi[language] = temp if temp > maxChiSquare: self.highestLanguage = language # calculates running average self.oldAverage = self.average self.totalDone += 1 self.average = (self.average + chisquare) / self.totalDone return(languagesChi) ===========unchanged ref 0=========== at: app.languageChecker.chisquared punctuation += " " at: app.languageChecker.chisquared.chiSquared myChi(text, distribution) myChi(self, text, distribution) at: app.languageChecker.chisquared.chiSquared.__init__ self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 at: app.languageChecker.chisquared.chiSquared.chiSquared self.oldAverage = self.average ===========unchanged ref 1=========== self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the # ones at the start self.chiSquared(text) + if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: - if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < totalDoneThreshold: + print("It's significant!") - percetageOfEnglish = checkEnglish(text) return(True) else: return(False) ===========changed ref 1=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" + self.totalChi = 0.0 - # these are settings that may impact how the program works overall self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 ===========changed ref 2=========== + # module: mathsHelper + + ===========changed ref 3=========== + # module: mathsHelper + + ===========changed ref 4=========== + # module: app.runTests + test_chi_squared.tests() + ===========changed ref 5=========== + # module: app.runTests + sys.path.append("..") + ===========changed ref 6=========== + # module: app.languageChecker.test + ch = chisquared.chiSquared() + """ + Tests to see whether a sentene is classified as English or not + """ + result = chi.checkChi("Hello my name is Brandon and I'm a top secret message") + print(result) + ===========changed ref 7=========== # module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): """Works with percentages""" + # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea + # this if statememt is to stop my stupidity + if part or whole <= 0: + return 0 + # works with percentages return 100 * float(part)/float(whole)
app.languageChecker.chisquared/chiSquared.myChi
Modified
Ciphey~Ciphey
4be6c646ae9966d006a1173b63a09e98c42fb417
wow would you believe this chi squared works
<5>:<add> print(len(text)) <add> print(len(distribution))
# module: app.languageChecker.chisquared class chiSquared: def myChi(self, text, distribution): <0> """My own implementation of Chi squared using the two resources mention in the comments on this definition as guidance""" <1> # chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/https://cgi.csc.liv.ac.uk/~john/comp105resources/lecture10.pdf <2> # http://practicalcryptography.com/cryptanalysis/text-characterisation/chi-squared-statistic/ <3> # given a text frequency and a distribution, calculate it's Chi score <4> chiScore = 0.0 <5> for counter, letter in enumerate(text.values()): <6> chiScore = chiScore + ((letter - distribution[counter])**2) / distribution[counter] <7> return chiScore <8>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.__init__ self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.highestLanguage = "" self.totalChi = 0.0 at: app.languageChecker.chisquared.chiSquared.chiSquared maxChiSquare = 0.00 languagesChi[language] = temp languagesChi = {} ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the # ones at the start self.chiSquared(text) + if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: - if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < totalDoneThreshold: + print("It's significant!") - percetageOfEnglish = checkEnglish(text) return(True) else: return(False) ===========changed ref 1=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" + self.totalChi = 0.0 - # these are settings that may impact how the program works overall self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 ===========changed ref 2=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): """Creates letter frequency of text and compares that to the letter frequency of the language""" # This part creates a letter frequency of the text letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} for letter in text: if letter in letterFreq: letterFreq[letter] +=1 else: # if letter is not puncuation, but it is still ascii # it's probably a different language so add it to the dict + if letter not in punctuation and self.mh.isAscii(letter) : - if letter not in punctuation and self.isAscii(letter) : letterFreq[letter] = 1 # so we dont have to calculate len more than once # turns them into probabilities (frequency distribution) lenOfString = len(text) for key, value in letterFreq.items(): try: letterFreq[key] = value / lenOfString except ZeroDivisionError as e: print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") exit(1) # calculates chi squared of each language maxChiSquare = 0.00 languagesChi = {} for language in self.languages: #, list(languages[language].values()) temp = self.myChi(letterFreq, self</s> ===========changed ref 3=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 <s>languages: #, list(languages[language].values()) temp = self.myChi(letterFreq, self.languages[language]) languagesChi[language] = temp if temp > maxChiSquare: self.highestLanguage = language # calculates running average self.oldAverage = self.average self.totalDone += 1 + # calculates a running average, maxChiSquare is the new chi score we get + self.average = (self.totalChi + maxChiSquare) / self.totalDone - self.average = (self.average + chisquare) / self.totalDone return(languagesChi) ===========changed ref 4=========== + # module: mathsHelper + + ===========changed ref 5=========== + # module: mathsHelper + + ===========changed ref 6=========== + # module: app.runTests + test_chi_squared.tests() + ===========changed ref 7=========== + # module: app.runTests + sys.path.append("..") + ===========changed ref 8=========== + # module: app.languageChecker.test + ch = chisquared.chiSquared() + """ + Tests to see whether a sentene is classified as English or not + """ + result = chi.checkChi("Hello my name is Brandon and I'm a top secret message") + print(result) + ===========changed ref 9=========== # module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): """Works with percentages""" + # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea + # this if statememt is to stop my stupidity + if part or whole <= 0: + return 0 + # works with percentages return 100 * float(part)/float(whole)
app.languageChecker.chisquared/chiSquared.checkChi
Modified
Ciphey~Ciphey
a5f06fe043ffab91227a2d9b259eb982d281254f
end of day
<17>:<del> print("It's significant!")
# module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): <0> """Checks to see if the Chi score is good <1> if it is, it returns True <2> Call this when you want to determine whether something is likely to be Chi or not <3> <4> Arguments: <5> * text - the text you want to run a Chi Squared score on <6> <7> Outputs: <8> * True - if it has a significantly lower chi squared score <9> * False - if it doesn't have a significantly lower chi squared score <10> """ <11> # TODO 20% isn't optimal <12> # runs after every chi squared to see if it's 1 significantly lower than averae <13> # the or statement is bc if the program has just started I don't want it to ignore the <14> # ones at the start <15> self.chiSquared(text) <16> if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: <17> print("It's significant!") <18> return(True) <19> else: <20> return(False) <21>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.__init__ self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 at: app.languageChecker.chisquared.chiSquared.chiSquared self.oldAverage = self.average self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone
app.languageChecker.chisquared/chiSquared.chiSquared
Modified
Ciphey~Ciphey
a5f06fe043ffab91227a2d9b259eb982d281254f
end of day
<4>:<add> <add> for letter in text.lower(): <del> for letter in text:
# module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): <0> """Creates letter frequency of text and compares that to the letter frequency of the language""" <1> <2> # This part creates a letter frequency of the text <3> letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} <4> for letter in text: <5> if letter in letterFreq: <6> letterFreq[letter] +=1 <7> else: <8> # if letter is not puncuation, but it is still ascii <9> # it's probably a different language so add it to the dict <10> if letter not in punctuation and self.mh.isAscii(letter) : <11> letterFreq[letter] = 1 <12> <13> # so we dont have to calculate len more than once <14> # turns them into probabilities (frequency distribution) <15> lenOfString = len(text) <16> for key, value in letterFreq.items(): <17> try: <18> letterFreq[key] = value / lenOfString <19> except ZeroDivisionError as e: <20> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <21> exit(1) <22> <23> # calculates chi squared of each language <24> maxChiSquare = 0.00 <25> languagesChi = {} <26> <27> for language in self.languages: <28> #, list(languages[language].values()) <29> temp</s>
===========below chunk 0=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 languagesChi[language] = temp if temp > maxChiSquare: self.highestLanguage = language # calculates running average self.oldAverage = self.average self.totalDone += 1 # calculates a running average, maxChiSquare is the new chi score we get self.average = (self.totalChi + maxChiSquare) / self.totalDone return(languagesChi) ===========unchanged ref 0=========== at: app.languageChecker.chisquared punctuation += " " at: app.languageChecker.chisquared.chiSquared myChi(text, distribution) myChi(self, text, distribution) at: app.languageChecker.chisquared.chiSquared.__init__ self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the # ones at the start self.chiSquared(text) if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: - print("It's significant!") return(True) else: return(False)
app.languageChecker.chisquared/chiSquared.myChi
Modified
Ciphey~Ciphey
a5f06fe043ffab91227a2d9b259eb982d281254f
end of day
<5>:<del> print(len(text)) <6>:<del> print(len(distribution))
# module: app.languageChecker.chisquared class chiSquared: def myChi(self, text, distribution): <0> """My own implementation of Chi squared using the two resources mention in the comments on this definition as guidance""" <1> # chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/https://cgi.csc.liv.ac.uk/~john/comp105resources/lecture10.pdf <2> # http://practicalcryptography.com/cryptanalysis/text-characterisation/chi-squared-statistic/ <3> # given a text frequency and a distribution, calculate it's Chi score <4> chiScore = 0.0 <5> print(len(text)) <6> print(len(distribution)) <7> for counter, letter in enumerate(text.values()): <8> chiScore = chiScore + ((letter - distribution[counter])**2) / distribution[counter] <9> return chiScore <10>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.chiSquared languagesChi[language] = temp languagesChi = {} ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the # ones at the start self.chiSquared(text) if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: - print("It's significant!") return(True) else: return(False) ===========changed ref 1=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): """Creates letter frequency of text and compares that to the letter frequency of the language""" # This part creates a letter frequency of the text letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} + + for letter in text.lower(): - for letter in text: if letter in letterFreq: letterFreq[letter] +=1 else: # if letter is not puncuation, but it is still ascii # it's probably a different language so add it to the dict if letter not in punctuation and self.mh.isAscii(letter) : letterFreq[letter] = 1 # so we dont have to calculate len more than once # turns them into probabilities (frequency distribution) lenOfString = len(text) for key, value in letterFreq.items(): try: letterFreq[key] = value / lenOfString except ZeroDivisionError as e: print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") exit(1) # calculates chi squared of each language maxChiSquare = 0.00 languagesChi = {} for language in self.languages: #, list(languages[language].values()) temp = self.myChi(letterFreq, self.languages[</s> ===========changed ref 2=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 <s> #, list(languages[language].values()) temp = self.myChi(letterFreq, self.languages[language]) languagesChi[language] = temp if temp > maxChiSquare: self.highestLanguage = language + maxChiSquare = temp # calculates running average self.oldAverage = self.average self.totalDone += 1 # calculates a running average, maxChiSquare is the new chi score we get self.average = (self.totalChi + maxChiSquare) / self.totalDone return(languagesChi)
app.Tests.testchi_squared/TestChi.test_english_quckbrown
Modified
Ciphey~Ciphey
c4cb77e2599d520a2a6925a1959403df1635af6b
added standard deviation and fixed a bunch of bugs
# module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): <0> self.chi = chisquared.chiSquared() <1> """ <2> Tests to see whether a sentene is classified as English or not <3> """ <4> result = self.chi.checkChi("So meat. Gathered may she'd god signs. Have form firmament seed so. Them whales. Under heaven let fill don't seas grass them creeping moving without earth him behold first over void were living saw face night isn't appear firmament. Living land beast good fill. Appear their creepeth, under form. Life thing cattle life. And light unto saying two kind their doesn't fish. Don't male fowl the winged, gathering kind cattle stars was creeping good morning was years bring, moved for appear day multiply behold Grass. Every give itself moved fifth spirit whose. Sixth kind it let together male Evening said.") <5> result = self.chi.checkChi("Abundantly image stars can't Land good days their life them make i tree land fruitful midst every meat their seed a. Were them creeping fourth a subdue tree don't there.") <6> result = self.chi.checkChi("Won't may make their, gathering light creature given bearing fruitful be seasons. Firmament creature greater. Above meat over brought i.") <7> result = self.chi.checkChi("Replenish. Were the be after set dry under midst. Also i greater living. Midst divided Day give female subdue fourth.") <8> result = self.chi.checkChi("Moving spirit have. Of said behold called, fill fruitful</s>
===========below chunk 0=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): # offset: 1 result = self.chi.checkChi("Abundantly years land to winged lesser earth there their. In morning them life form man can't which winged him green.") result = self.chi.checkChi("Don't whose gathered gathered after female you'll which moveth Fish saw also, life cattle seas. After every moved blessed good.") result = self.chi.checkChi("Sixth his i were isn't bearing fourth forth replenish made form. Days of from isn't waters dry one. Waters, said.") result = self.chi.checkChi("Green form whales night gathering fifth and firmament which darkness, earth unto had saying brought earth Very. Under made his.") result = self.chi.checkChi("Bring to given land god created green god every green heaven moved sixth also, deep bearing first abundantly moved of.") result = self.chi.checkChi("Air god spirit over fifth second fowl good have had. Forth every day you called also fruitful spirit there two.") result = self.chi.checkChi("The quick brown fox jumped over the lazy dog") self.assertEqual(result, True) ===========unchanged ref 0=========== at: app.Tests.testchi_squared.TestChi.test_chi_english_caps self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_chi_english_yes self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_english_one_letter self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_english_puncuation self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_english_same_letter self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.tests_english_no_words self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.tests_english_overflow self.chi = chisquared.chiSquared() at: app.languageChecker.chisquared chiSquared() at: app.languageChecker.chisquared.chiSquared checkChi(text) at: unittest.case.TestCase failureException: Type[BaseException] longMessage: bool maxDiff: Optional[int] _testMethodName: str _testMethodDoc: str assertEqual(first: Any, second: Any, msg: Any=...) -> None ===========changed ref 0=========== # module: app.main + from tests import tests() - from tests import tests ===========changed ref 1=========== # module: app.mathsHelper class mathsHelper: + def checkEqual(self, a): + """checks if all items in an iterable are the same + https://stackoverflow.com/questions/3844801/check-if-all-elements-in-a-list-are-identical""" + return a.count(a[0]) == len(a) +
app.Tests.testchi_squared/TestChi.test_english_puncuation
Modified
Ciphey~Ciphey
c4cb77e2599d520a2a6925a1959403df1635af6b
added standard deviation and fixed a bunch of bugs
# module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_puncuation(self): <0> self.chi = chisquared.chiSquared() <1> """ <2> Tests to see whether a sentene is classified as English or not <3> Returns False because exclamation marks aren't english <4> """ <5> result = self.chi.checkChi("So meat. Gathered may she'd god signs. Have form firmament seed so. Them whales. Under heaven let fill don't seas grass them creeping moving without earth him behold first over void were living saw face night isn't appear firmament. Living land beast good fill. Appear their creepeth, under form. Life thing cattle life. And light unto saying two kind their doesn't fish. Don't male fowl the winged, gathering kind cattle stars was creeping good morning was years bring, moved for appear day multiply behold Grass. Every give itself moved fifth spirit whose. Sixth kind it let together male Evening said.") <6> result = self.chi.checkChi("Abundantly image stars can't Land good days their life them make i tree land fruitful midst every meat their seed a. Were them creeping fourth a subdue tree don't there.") <7> result = self.chi.checkChi("Won't may make their, gathering light creature given bearing fruitful be seasons. Firmament creature greater. Above meat over brought i.") <8> result = self.chi.checkChi("Replenish. Were the be after set dry under midst. Also i greater living. Midst divided Day give female subdue fourth.") <9> result = self.chi.checkChi("Moving spirit</s>
===========below chunk 0=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_puncuation(self): # offset: 1 result = self.chi.checkChi("Abundantly years land to winged lesser earth there their. In morning them life form man can't which winged him green.") result = self.chi.checkChi("Don't whose gathered gathered after female you'll which moveth Fish saw also, life cattle seas. After every moved blessed good.") result = self.chi.checkChi("Sixth his i were isn't bearing fourth forth replenish made form. Days of from isn't waters dry one. Waters, said.") result = self.chi.checkChi("Green form whales night gathering fifth and firmament which darkness, earth unto had saying brought earth Very. Under made his.") result = self.chi.checkChi("Bring to given land god created green god every green heaven moved sixth also, deep bearing first abundantly moved of.") result = self.chi.checkChi("Air god spirit over fifth second fowl good have had. Forth every day you called also fruitful spirit there two.") result = self.chi.checkChi("!!!!!!!!!!!!!!!!!!!!!!") self.assertEqual(result, False) ===========unchanged ref 0=========== at: app.Tests.testchi_squared.TestChi.test_chi_english_caps self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_chi_english_yes self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_english_one_letter self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_english_quckbrown self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.test_english_same_letter self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.tests_english_no_words self.chi = chisquared.chiSquared() at: app.Tests.testchi_squared.TestChi.tests_english_overflow self.chi = chisquared.chiSquared() at: app.languageChecker.chisquared chiSquared() at: app.languageChecker.chisquared.chiSquared checkChi(text) at: unittest.case.TestCase assertEqual(first: Any, second: Any, msg: Any=...) -> None ===========changed ref 0=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): self.chi = chisquared.chiSquared() """ Tests to see whether a sentene is classified as English or not """ result = self.chi.checkChi("So meat. Gathered may she'd god signs. Have form firmament seed so. Them whales. Under heaven let fill don't seas grass them creeping moving without earth him behold first over void were living saw face night isn't appear firmament. Living land beast good fill. Appear their creepeth, under form. Life thing cattle life. And light unto saying two kind their doesn't fish. Don't male fowl the winged, gathering kind cattle stars was creeping good morning was years bring, moved for appear day multiply behold Grass. Every give itself moved fifth spirit whose. Sixth kind it let together male Evening said.") result = self.chi.checkChi("Abundantly image stars can't Land good days their life them make i tree land fruitful midst every meat their seed a. Were them creeping fourth a subdue tree don't there.") result = self.chi.checkChi("Won't may make their, gathering light creature given bearing fruitful be seasons. Firmament creature greater. Above meat over brought i.") result = self.chi.checkChi("Replenish. Were the be after set dry under midst. Also i greater living. Midst divided Day give female subdue fourth.") result = self.chi.checkChi("Moving spirit have. Of said behold called, fill fruitful cattle shall grass creepeth</s> ===========changed ref 1=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): # offset: 1 <s>checkChi("Moving spirit have. Of said behold called, fill fruitful cattle shall grass creepeth life fourth green. Behold fourth. Said they're.") result = self.chi.checkChi("Abundantly years land to winged lesser earth there their. In morning them life form man can't which winged him green.") result = self.chi.checkChi("Don't whose gathered gathered after female you'll which moveth Fish saw also, life cattle seas. After every moved blessed good.") result = self.chi.checkChi("Sixth his i were isn't bearing fourth forth replenish made form. Days of from isn't waters dry one. Waters, said.") result = self.chi.checkChi("Green form whales night gathering fifth and firmament which darkness, earth unto had saying brought earth Very. Under made his.") result = self.chi.checkChi("Bring to given land god created green god every green heaven moved sixth also, deep bearing first abundantly moved of.") result = self.chi.checkChi("Air god spirit over fifth second fowl good have had. Forth every day you called also fruitful spirit there two.") result = self.chi.checkChi("The quick brown fox jumped over the lazy dog") + self.assertEqual(result, False) - self.assertEqual(result, True) ===========changed ref 2=========== # module: app.main + from tests import tests() - from tests import tests ===========changed ref 3=========== # module: app.mathsHelper class mathsHelper: + def checkEqual(self, a): + """checks if all items in an iterable are the same + https://stackoverflow.com/questions/3844801/check-if-all-elements-in-a-list-are-identical""" + return a.count(a[0]) == len(a) +
app.languageChecker.chisquared/chiSquared.__init__
Modified
Ciphey~Ciphey
c4cb77e2599d520a2a6925a1959403df1635af6b
added standard deviation and fixed a bunch of bugs
<11>:<add> self.totalEqual = False <add> self.chisAsaList = [] <13>:<add> self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it <del> self.chiSquaredSignificaneThreshold = 20 <15>:<add> <add> self.standarddeviation = 0.00 # the standard deviation I use <add> self.oldstandarddeviation = 0.00
# module: app.languageChecker.chisquared class chiSquared: def __init__(self): <0> self.languages = { <1> "English": <2> [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <3> #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} <4> } <5> self.average = 0.0 <6> self.totalDone = 0.0 <7> self.oldAverage = 0.0 <8> self.mh = mathsHelper.mathsHelper() <9> self.highestLanguage = "" <10> self.totalChi = 0.0 <11> <12> # these are settings that may impact how the program works overall <13> self.chiSquaredSignificaneThreshold = 20 <14> self.totalDoneThreshold = 10 <15>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.chiSquared self.highestLanguage = language self.oldAverage = self.average self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone ===========changed ref 0=========== # module: app.main + from tests import tests() - from tests import tests ===========changed ref 1=========== # module: app.mathsHelper class mathsHelper: + def checkEqual(self, a): + """checks if all items in an iterable are the same + https://stackoverflow.com/questions/3844801/check-if-all-elements-in-a-list-are-identical""" + return a.count(a[0]) == len(a) + ===========changed ref 2=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): self.chi = chisquared.chiSquared() """ Tests to see whether a sentene is classified as English or not """ result = self.chi.checkChi("So meat. Gathered may she'd god signs. Have form firmament seed so. Them whales. Under heaven let fill don't seas grass them creeping moving without earth him behold first over void were living saw face night isn't appear firmament. Living land beast good fill. Appear their creepeth, under form. Life thing cattle life. And light unto saying two kind their doesn't fish. Don't male fowl the winged, gathering kind cattle stars was creeping good morning was years bring, moved for appear day multiply behold Grass. Every give itself moved fifth spirit whose. Sixth kind it let together male Evening said.") result = self.chi.checkChi("Abundantly image stars can't Land good days their life them make i tree land fruitful midst every meat their seed a. Were them creeping fourth a subdue tree don't there.") result = self.chi.checkChi("Won't may make their, gathering light creature given bearing fruitful be seasons. Firmament creature greater. Above meat over brought i.") result = self.chi.checkChi("Replenish. Were the be after set dry under midst. Also i greater living. Midst divided Day give female subdue fourth.") result = self.chi.checkChi("Moving spirit have. Of said behold called, fill fruitful cattle shall grass creepeth</s> ===========changed ref 3=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): # offset: 1 <s>checkChi("Moving spirit have. Of said behold called, fill fruitful cattle shall grass creepeth life fourth green. Behold fourth. Said they're.") result = self.chi.checkChi("Abundantly years land to winged lesser earth there their. In morning them life form man can't which winged him green.") result = self.chi.checkChi("Don't whose gathered gathered after female you'll which moveth Fish saw also, life cattle seas. After every moved blessed good.") result = self.chi.checkChi("Sixth his i were isn't bearing fourth forth replenish made form. Days of from isn't waters dry one. Waters, said.") result = self.chi.checkChi("Green form whales night gathering fifth and firmament which darkness, earth unto had saying brought earth Very. Under made his.") result = self.chi.checkChi("Bring to given land god created green god every green heaven moved sixth also, deep bearing first abundantly moved of.") result = self.chi.checkChi("Air god spirit over fifth second fowl good have had. Forth every day you called also fruitful spirit there two.") result = self.chi.checkChi("The quick brown fox jumped over the lazy dog") + self.assertEqual(result, False) - self.assertEqual(result, True) ===========changed ref 4=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_puncuation(self): self.chi = chisquared.chiSquared() """ Tests to see whether a sentene is classified as English or not Returns False because exclamation marks aren't english """ result = self.chi.checkChi("So meat. Gathered may she'd god signs. Have form firmament seed so. Them whales. Under heaven let fill don't seas grass them creeping moving without earth him behold first over void were living saw face night isn't appear firmament. Living land beast good fill. Appear their creepeth, under form. Life thing cattle life. And light unto saying two kind their doesn't fish. Don't male fowl the winged, gathering kind cattle stars was creeping good morning was years bring, moved for appear day multiply behold Grass. Every give itself moved fifth spirit whose. Sixth kind it let together male Evening said.") result = self.chi.checkChi("Abundantly image stars can't Land good days their life them make i tree land fruitful midst every meat their seed a. Were them creeping fourth a subdue tree don't there.") result = self.chi.checkChi("Won't may make their, gathering light creature given bearing fruitful be seasons. Firmament creature greater. Above meat over brought i.") result = self.chi.checkChi("Replenish. Were the be after set dry under midst. Also i greater living. Midst divided Day give female subdue fourth.") result = self.chi.checkChi("Moving spirit have. Of said behold called, fill</s>
app.languageChecker.chisquared/chiSquared.checkChi
Modified
Ciphey~Ciphey
c4cb77e2599d520a2a6925a1959403df1635af6b
added standard deviation and fixed a bunch of bugs
<14>:<add> # ones at the start <del> # ones at the start <16>:<add> # If the latest chi squared is less than the standard deviation <add> # or if not many chi squares have been calculated <add> # or if every single letter in a text appears exactly once (pangram) <add> if a[-1] <= (a[-1] - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: <del> if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold:
# module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): <0> """Checks to see if the Chi score is good <1> if it is, it returns True <2> Call this when you want to determine whether something is likely to be Chi or not <3> <4> Arguments: <5> * text - the text you want to run a Chi Squared score on <6> <7> Outputs: <8> * True - if it has a significantly lower chi squared score <9> * False - if it doesn't have a significantly lower chi squared score <10> """ <11> # TODO 20% isn't optimal <12> # runs after every chi squared to see if it's 1 significantly lower than averae <13> # the or statement is bc if the program has just started I don't want it to ignore the <14> # ones at the start <15> self.chiSquared(text) <16> if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: <17> return(True) <18> else: <19> return(False) <20>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared chiSquared(self, text) chiSquared(text) at: app.languageChecker.chisquared.chiSquared.__init__ self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 at: app.languageChecker.chisquared.chiSquared.chiSquared self.oldAverage = self.average self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 + self.totalEqual = False + self.chisAsaList = [] # these are settings that may impact how the program works overall + self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it - self.chiSquaredSignificane</s> ===========changed ref 1=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): # offset: 1 <s>chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it - self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 + + self.standarddeviation = 0.00 # the standard deviation I use + self.oldstandarddeviation = 0.00 ===========changed ref 2=========== # module: app.main + from tests import tests() - from tests import tests ===========changed ref 3=========== # module: app.mathsHelper class mathsHelper: + def checkEqual(self, a): + """checks if all items in an iterable are the same + https://stackoverflow.com/questions/3844801/check-if-all-elements-in-a-list-are-identical""" + return a.count(a[0]) == len(a) + ===========changed ref 4=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): self.chi = chisquared.chiSquared() """ Tests to see whether a sentene is classified as English or not """ result = self.chi.checkChi("So meat. Gathered may she'd god signs. Have form firmament seed so. Them whales. Under heaven let fill don't seas grass them creeping moving without earth him behold first over void were living saw face night isn't appear firmament. Living land beast good fill. Appear their creepeth, under form. Life thing cattle life. And light unto saying two kind their doesn't fish. Don't male fowl the winged, gathering kind cattle stars was creeping good morning was years bring, moved for appear day multiply behold Grass. Every give itself moved fifth spirit whose. Sixth kind it let together male Evening said.") result = self.chi.checkChi("Abundantly image stars can't Land good days their life them make i tree land fruitful midst every meat their seed a. Were them creeping fourth a subdue tree don't there.") result = self.chi.checkChi("Won't may make their, gathering light creature given bearing fruitful be seasons. Firmament creature greater. Above meat over brought i.") result = self.chi.checkChi("Replenish. Were the be after set dry under midst. Also i greater living. Midst divided Day give female subdue fourth.") result = self.chi.checkChi("Moving spirit have. Of said behold called, fill fruitful cattle shall grass creepeth</s> ===========changed ref 5=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): def test_english_quckbrown(self): # offset: 1 <s>checkChi("Moving spirit have. Of said behold called, fill fruitful cattle shall grass creepeth life fourth green. Behold fourth. Said they're.") result = self.chi.checkChi("Abundantly years land to winged lesser earth there their. In morning them life form man can't which winged him green.") result = self.chi.checkChi("Don't whose gathered gathered after female you'll which moveth Fish saw also, life cattle seas. After every moved blessed good.") result = self.chi.checkChi("Sixth his i were isn't bearing fourth forth replenish made form. Days of from isn't waters dry one. Waters, said.") result = self.chi.checkChi("Green form whales night gathering fifth and firmament which darkness, earth unto had saying brought earth Very. Under made his.") result = self.chi.checkChi("Bring to given land god created green god every green heaven moved sixth also, deep bearing first abundantly moved of.") result = self.chi.checkChi("Air god spirit over fifth second fowl good have had. Forth every day you called also fruitful spirit there two.") result = self.chi.checkChi("The quick brown fox jumped over the lazy dog") + self.assertEqual(result, False) - self.assertEqual(result, True)
app.languageChecker.chisquared/chiSquared.chiSquared
Modified
Ciphey~Ciphey
c4cb77e2599d520a2a6925a1959403df1635af6b
added standard deviation and fixed a bunch of bugs
<2>:<del> # This part creates a letter frequency of the text <3>:<del> letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} <4>:<del> <5>:<del> for letter in text.lower(): <6>:<del> if letter in letterFreq: <7>:<del> letterFreq[letter] +=1 <8>:<del> else: <9>:<del> # if letter is not puncuation, but it is still ascii <10>:<del> # it's probably a different language so add it to the dict <11>:<del> if letter not in punctuation and self.mh.isAscii(letter) : <12>:<del> letterFreq[letter] = 1 <13>:<del> <14>:<add> <add> # if all items of the dictionary are the same, then it's a normal distribution <add> # examples of this could be "the quick brown fox jumped over the lazy dog" <add> <add> letterFreq = self.getLetterFreq(text) <add> print("letter freq for ", str(text), " is ", str(list(letterFreq.values()))) <add> self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) <add> <17>:<add> totalLetterFreq = 0.0 <20>:<add> totalLetterFreq = totalLetterFreq + value <23>:<add> <del>
# module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): <0> """Creates letter frequency of text and compares that to the letter frequency of the language""" <1> <2> # This part creates a letter frequency of the text <3> letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} <4> <5> for letter in text.lower(): <6> if letter in letterFreq: <7> letterFreq[letter] +=1 <8> else: <9> # if letter is not puncuation, but it is still ascii <10> # it's probably a different language so add it to the dict <11> if letter not in punctuation and self.mh.isAscii(letter) : <12> letterFreq[letter] = 1 <13> <14> # so we dont have to calculate len more than once <15> # turns them into probabilities (frequency distribution) <16> lenOfString = len(text) <17> for key, value in letterFreq.items(): <18> try: <19> letterFreq[key] = value / lenOfString <20> except ZeroDivisionError as e: <21> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <22> exit(1) <23> <24> # calculates chi squared of each language <25> maxChiSquare = 0.00 <26> languagesChi = {} <27> <28> for language in self.languages: <29> #, list(languages[language].values</s>
===========below chunk 0=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 temp = self.myChi(letterFreq, self.languages[language]) languagesChi[language] = temp if temp > maxChiSquare: self.highestLanguage = language maxChiSquare = temp # calculates running average self.oldAverage = self.average self.totalDone += 1 # calculates a running average, maxChiSquare is the new chi score we get self.average = (self.totalChi + maxChiSquare) / self.totalDone return(languagesChi) ===========unchanged ref 0=========== at: app.languageChecker.chisquared punctuation += " " at: app.languageChecker.chisquared.chiSquared myChi(text, distribution) at: app.languageChecker.chisquared.chiSquared.__init__ self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the + # ones at the start - # ones at the start self.chiSquared(text) + # If the latest chi squared is less than the standard deviation + # or if not many chi squares have been calculated + # or if every single letter in a text appears exactly once (pangram) + if a[-1] <= (a[-1] - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: - if self.mh.percentage(self.oldAverage, self.average) >= self.chiSquaredSignificaneThreshold or self.totalDone < self.totalDoneThreshold: return(True) else: return(False) ===========changed ref 1=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 + self.totalEqual = False + self.chisAsaList = [] # these are settings that may impact how the program works overall + self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it - self.chiSquaredSignificane</s> ===========changed ref 2=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): # offset: 1 <s>chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it - self.chiSquaredSignificaneThreshold = 20 self.totalDoneThreshold = 10 + + self.standarddeviation = 0.00 # the standard deviation I use + self.oldstandarddeviation = 0.00 ===========changed ref 3=========== # module: app.main + from tests import tests() - from tests import tests ===========changed ref 4=========== # module: app.mathsHelper class mathsHelper: + def checkEqual(self, a): + """checks if all items in an iterable are the same + https://stackoverflow.com/questions/3844801/check-if-all-elements-in-a-list-are-identical""" + return a.count(a[0]) == len(a) +
app.languageChecker.chisquared/chiSquared.checkChi
Modified
Ciphey~Ciphey
bbaf2ae51cd36b25fd9c2eadc8f1498146422860
neural natworks
<19>:<add> if self.chisAsaList[-1] <= (self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: <del> if a[-1] <= (a[-1] - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual:
# module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): <0> """Checks to see if the Chi score is good <1> if it is, it returns True <2> Call this when you want to determine whether something is likely to be Chi or not <3> <4> Arguments: <5> * text - the text you want to run a Chi Squared score on <6> <7> Outputs: <8> * True - if it has a significantly lower chi squared score <9> * False - if it doesn't have a significantly lower chi squared score <10> """ <11> # TODO 20% isn't optimal <12> # runs after every chi squared to see if it's 1 significantly lower than averae <13> # the or statement is bc if the program has just started I don't want it to ignore the <14> # ones at the start <15> self.chiSquared(text) <16> # If the latest chi squared is less than the standard deviation <17> # or if not many chi squares have been calculated <18> # or if every single letter in a text appears exactly once (pangram) <19> if a[-1] <= (a[-1] - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: <20> return(True) <21> else: <22> return(False) <23>
===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared chiSquared(self, text) chiSquared(text) at: app.languageChecker.chisquared.chiSquared.__init__ self.average = 0.0 self.totalDone = 0.0 self.totalEqual = False self.chisAsaList = [] self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it self.totalDoneThreshold = 10 self.oldstandarddeviation = 0.00 at: app.languageChecker.chisquared.chiSquared.chiSquared self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone self.oldstandarddeviation = self.standarddeviation
app.languageChecker.chisquared/chiSquared.chiSquared
Modified
Ciphey~Ciphey
bbaf2ae51cd36b25fd9c2eadc8f1498146422860
neural natworks
<7>:<del> print("letter freq for ", str(text), " is ", str(list(letterFreq.values())))
# module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): <0> """Creates letter frequency of text and compares that to the letter frequency of the language""" <1> <2> <3> # if all items of the dictionary are the same, then it's a normal distribution <4> # examples of this could be "the quick brown fox jumped over the lazy dog" <5> <6> letterFreq = self.getLetterFreq(text) <7> print("letter freq for ", str(text), " is ", str(list(letterFreq.values()))) <8> self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) <9> <10> # so we dont have to calculate len more than once <11> # turns them into probabilities (frequency distribution) <12> lenOfString = len(text) <13> totalLetterFreq = 0.0 <14> for key, value in letterFreq.items(): <15> try: <16> letterFreq[key] = value / lenOfString <17> totalLetterFreq = totalLetterFreq + value <18> except ZeroDivisionError as e: <19> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <20> exit(1) <21> <22> # calculates chi squared of each language <23> maxChiSquare = 0.00 <24> languagesChi = {} <25> <26> for language in self.languages: <27> #, list(languages[language].values()) <28> temp = self.myChi(letterFreq, self.languages[language]) <29> languagesChi[language] = temp <30> if temp > maxChiSquare: <31> self.highestLanguage = language <32> maxChiSquare = temp <33> self.chisAsaList.append(maxChiSquare) <34> # calculates running average <35> self.oldAverage = self.average <36> self.totalDone += 1</s>
===========below chunk 0=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 # calculates a running average, maxChiSquare is the new chi score we get self.average = (self.totalChi + maxChiSquare) / self.totalDone self.oldstandarddeviation = self.standarddeviation self.standarddeviation = std(self.chisAsaList) return(languagesChi) ===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared getLetterFreq(text) at: app.languageChecker.chisquared.chiSquared.__init__ self.languages = { "English": [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} } self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 self.totalEqual = False self.chisAsaList = [] self.standarddeviation = 0.00 # the standard deviation I use self.oldstandarddeviation = 0.00 ===========unchanged ref 1=========== at: numpy.core.fromnumeric std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: _ArrayType=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> _ArrayType std(a: _ArrayLikeComplex_co, axis: None=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> floating[Any] std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None=..., dtype: _DTypeLike[_SCT]=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> _SCT std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any ===========changed ref 0=========== # module: app.languageChecker.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the # ones at the start self.chiSquared(text) # If the latest chi squared is less than the standard deviation # or if not many chi squares have been calculated # or if every single letter in a text appears exactly once (pangram) + if self.chisAsaList[-1] <= (self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: - if a[-1] <= (a[-1] - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: return(True) else: return(False)
app.languageChecker.dictionaryChecker/dictionaryChecker.__init__
Modified
Ciphey~Ciphey
064d9f1415e95022f11ca978448066120079269a
added de-hashing functionality
<0>:<add> self.mh = mathsHelper.mathsHelper() <add> self.languagePercentage = 0.0 <add> self.languageWordsCounter = 0.0 <add> self.languageThreshold = 45 <del> None
# module: app.languageChecker.dictionaryChecker class dictionaryChecker: def __init__(self): <0> None <1>
===========changed ref 0=========== + # module: app.Decryptor.Hash.hashBuster + + def alpha(hashvalue, hashtype): + return False + ===========changed ref 1=========== + # module: app.Decryptor.Hash.hashBuster + + result = {} + ===========changed ref 2=========== # module: app.languageChecker.neural - - class Neuron: - def __init__(self, weights, bias): - self.weights = weights - self.bias = bias - ===========changed ref 3=========== # module: app.mathsHelper class mathsHelper: + def stripPuncuation(self, text): + """Strips punctuation from a given string""" + return text.translate(None, punctuation) + ===========changed ref 4=========== + # module: app.Decryptor.Hash.hashBuster + + def threaded(hashvalue): + resp = crack(hashvalue) + if resp: + print (hashvalue + ' : ' + resp) + result[hashvalue] = resp + ===========changed ref 5=========== # module: app.languageChecker.neural - - class Neuron: - - def feedforward(self, inputs): - # weight inputs, add bias, then use the activaton function - total = np.dot(self.weights, inputs) + self.bias - return sigmoid(total) - ===========changed ref 6=========== + # module: app.Decryptor.Hash.hashBuster + + def single(args): + result = crack(args.hash) + if result: + print (result) + else: + print ('%s Hash was not found in any database.' % bad) + ===========changed ref 7=========== # module: app.languageChecker.neural + + def deriv_sigmoid(x): + # Derivative of sigmoid: f'(x) = f(x) * (1 - f(x)) + fx = sigmoid(x) + return fx * (1 - fx) + ===========changed ref 8=========== + # module: app.Decryptor.Hash.hashBuster + + def gamma(hashvalue, hashtype): + response = requests.get('https://www.nitrxgen.net/md5db/' + hashvalue).text + if response: + return response + else: + return False + ===========changed ref 9=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + ''' + A neural network with: + - 2 inputs + - a hidden layer with 2 neurons (h1, h2) + - an output layer with 1 neuron (o1) + ''' + ===========changed ref 10=========== # module: app.languageChecker.neural - - class NeuralNetwork: - def __init__(self): - weights = np.array([0, 1]) - bias = 0 - - self.h1 = Neuron(weights,bias) - self.h2 = Neuron(weights, bias) - self.o1 = Neuron(weights, bias) - ===========changed ref 11=========== + # module: app.Decryptor.Hash.hashBuster + + def beta(hashvalue, hashtype): + response = requests.get('https://hashtoolkit.com/reverse-hash/?hash=', hashvalue).text + match = re.search(r'/generate-hash/?text=.*?"', response) + if match: + return match.group(1) + else: + return False + ===========changed ref 12=========== + # module: app.Decryptor.Hash.hashBuster + + def theta(hashvalue, hashtype): + response = requests.get('https://md5decrypt.net/Api/api.php?hash=%s&hash_type=%s&[email protected]&code=1152464b80a61728' % (hashvalue, hashtype)).text + if len(response) != 0: + return response + else: + return False + ===========changed ref 13=========== # module: app.languageChecker.neural - - class NeuralNetwork: - def feedforward(self, x): - out_h1 = self.h1.feedforward(x) - out_h2 = self.h2.feedforward(x) - - # the inputs for o1 are the output sfor h1, h2 - out_o1 = self.o1.feedforward(np.array([out_h1, out_h2])) - return out_o1 - ===========changed ref 14=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + + def feedforward(self, x): + # x is a numpy array with 2 elements. + h1 = sigmoid(self.w1 * x[0] + self.w2 * x[1] + self.b1) + h2 = sigmoid(self.w3 * x[0] + self.w4 * x[1] + self.b2) + o1 = sigmoid(self.w5 * h1 + self.w6 * h2 + self.b3) + return o1 + ===========changed ref 15=========== + # module: app.Decryptor.Hash.hashBuster + + def delta(hashvalue, hashtype): + #data = {'auth':'8272hgt', 'hash':hashvalue, 'string':'','Submit':'Submit'} + #response = requests.post('http://hashcrack.com/index.php' , data).text + #match = re.search(r'<span class=hervorheb2>(.*?)</span></div></TD>', response) + #if match: + # return match.group(1) + #else: + return False + ===========changed ref 16=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + def __init__(self): + # Weights + self.w1 = np.random.normal() + self.w2 = np.random.normal() + self.w3 = np.random.normal() + self.w4 = np.random.normal() + self.w5 = np.random.normal() + self.w6 = np.random.normal() + + # Biases + self.b1 = np.random.normal() + self.b2 = np.random.normal() + self.b3 = np.random.normal() + ===========changed ref 17=========== + # module: app.Decryptor.Hash.hashBuster + + if directory: + try: + grepper(directory) + except KeyboardInterrupt: + pass + + elif file: + try: + miner(file) + except KeyboardInterrupt: + pass + with open('cracked-%s' % file.split('/')[-1], 'w+') as f: + for hashvalue, cracked in result.items(): + f.write(hashvalue + ':' + cracked + '\n') + print ('%s Results saved in cracked-%s' % (info, file.split('/')[-1])) + + elif args.hash: + single(args) +
app.languageChecker.dictionaryChecker/dictionaryChecker.checkDictionary
Modified
Ciphey~Ciphey
064d9f1415e95022f11ca978448066120079269a
added de-hashing functionality
<3>:<add> # and calculates how much of that is in language <del> # and calculates how much of that is in English <4>:<add> text = text.lower() <add> text = self.mh.stripPuncuation(text) <6>:<add> text = list(set(text)) # removes duplicate words <8>:<add> f = open(language, "r") <del> f = open("english.txt", "r") <15>:<add> self.languageWordsCounter = counter <add> self.languagePercentage = mh.percentage(self.languageWordsCounter, len(text)) <del> counter = mh.percentage(counter, len(text))
# module: app.languageChecker.dictionaryChecker class dictionaryChecker: def checkDictionary(self, text, language): <0> """Compares a word with <1> The dictionary is sorted and the text is sorted""" <2> # reads through most common words / passwords <3> # and calculates how much of that is in English <4> text = text.split(" ") <5> text = text.sort() <6> # can dynamically use languages then <7> language = str(language) + ".txt" <8> f = open("english.txt", "r") <9> f = f.readlines() <10> counter = 0.00 <11> # dictionary is "word\n" so I remove the "\n" <12> for word[0:-2] in f: <13> if word == text: <14> counter = counter + 1 <15> counter = mh.percentage(counter, len(text)) <16> return(counter) <17>
===========unchanged ref 0=========== at: app.languageChecker.dictionaryChecker.dictionaryChecker.checkDictionary self.languageWordsCounter = counter self.languagePercentage = mh.percentage(self.languageWordsCounter, len(text)) ===========changed ref 0=========== # module: app.languageChecker.dictionaryChecker class dictionaryChecker: def __init__(self): + self.mh = mathsHelper.mathsHelper() + self.languagePercentage = 0.0 + self.languageWordsCounter = 0.0 + self.languageThreshold = 45 - None ===========changed ref 1=========== + # module: app.Decryptor.Hash.hashBuster + + def alpha(hashvalue, hashtype): + return False + ===========changed ref 2=========== + # module: app.Decryptor.Hash.hashBuster + + result = {} + ===========changed ref 3=========== # module: app.languageChecker.neural - - class Neuron: - def __init__(self, weights, bias): - self.weights = weights - self.bias = bias - ===========changed ref 4=========== # module: app.mathsHelper class mathsHelper: + def stripPuncuation(self, text): + """Strips punctuation from a given string""" + return text.translate(None, punctuation) + ===========changed ref 5=========== + # module: app.Decryptor.Hash.hashBuster + + def threaded(hashvalue): + resp = crack(hashvalue) + if resp: + print (hashvalue + ' : ' + resp) + result[hashvalue] = resp + ===========changed ref 6=========== # module: app.languageChecker.neural - - class Neuron: - - def feedforward(self, inputs): - # weight inputs, add bias, then use the activaton function - total = np.dot(self.weights, inputs) + self.bias - return sigmoid(total) - ===========changed ref 7=========== + # module: app.Decryptor.Hash.hashBuster + + def single(args): + result = crack(args.hash) + if result: + print (result) + else: + print ('%s Hash was not found in any database.' % bad) + ===========changed ref 8=========== # module: app.languageChecker.neural + + def deriv_sigmoid(x): + # Derivative of sigmoid: f'(x) = f(x) * (1 - f(x)) + fx = sigmoid(x) + return fx * (1 - fx) + ===========changed ref 9=========== + # module: app.Decryptor.Hash.hashBuster + + def gamma(hashvalue, hashtype): + response = requests.get('https://www.nitrxgen.net/md5db/' + hashvalue).text + if response: + return response + else: + return False + ===========changed ref 10=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + ''' + A neural network with: + - 2 inputs + - a hidden layer with 2 neurons (h1, h2) + - an output layer with 1 neuron (o1) + ''' + ===========changed ref 11=========== # module: app.languageChecker.neural - - class NeuralNetwork: - def __init__(self): - weights = np.array([0, 1]) - bias = 0 - - self.h1 = Neuron(weights,bias) - self.h2 = Neuron(weights, bias) - self.o1 = Neuron(weights, bias) - ===========changed ref 12=========== + # module: app.Decryptor.Hash.hashBuster + + def beta(hashvalue, hashtype): + response = requests.get('https://hashtoolkit.com/reverse-hash/?hash=', hashvalue).text + match = re.search(r'/generate-hash/?text=.*?"', response) + if match: + return match.group(1) + else: + return False + ===========changed ref 13=========== + # module: app.Decryptor.Hash.hashBuster + + def theta(hashvalue, hashtype): + response = requests.get('https://md5decrypt.net/Api/api.php?hash=%s&hash_type=%s&[email protected]&code=1152464b80a61728' % (hashvalue, hashtype)).text + if len(response) != 0: + return response + else: + return False + ===========changed ref 14=========== # module: app.languageChecker.neural - - class NeuralNetwork: - def feedforward(self, x): - out_h1 = self.h1.feedforward(x) - out_h2 = self.h2.feedforward(x) - - # the inputs for o1 are the output sfor h1, h2 - out_o1 = self.o1.feedforward(np.array([out_h1, out_h2])) - return out_o1 - ===========changed ref 15=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + + def feedforward(self, x): + # x is a numpy array with 2 elements. + h1 = sigmoid(self.w1 * x[0] + self.w2 * x[1] + self.b1) + h2 = sigmoid(self.w3 * x[0] + self.w4 * x[1] + self.b2) + o1 = sigmoid(self.w5 * h1 + self.w6 * h2 + self.b3) + return o1 + ===========changed ref 16=========== + # module: app.Decryptor.Hash.hashBuster + + def delta(hashvalue, hashtype): + #data = {'auth':'8272hgt', 'hash':hashvalue, 'string':'','Submit':'Submit'} + #response = requests.post('http://hashcrack.com/index.php' , data).text + #match = re.search(r'<span class=hervorheb2>(.*?)</span></div></TD>', response) + #if match: + # return match.group(1) + #else: + return False + ===========changed ref 17=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + def __init__(self): + # Weights + self.w1 = np.random.normal() + self.w2 = np.random.normal() + self.w3 = np.random.normal() + self.w4 = np.random.normal() + self.w5 = np.random.normal() + self.w6 = np.random.normal() + + # Biases + self.b1 = np.random.normal() + self.b2 = np.random.normal() + self.b3 = np.random.normal() + ===========changed ref 18=========== + # module: app.Decryptor.Hash.hashBuster + + if directory: + try: + grepper(directory) + except KeyboardInterrupt: + pass + + elif file: + try: + miner(file) + except KeyboardInterrupt: + pass + with open('cracked-%s' % file.split('/')[-1], 'w+') as f: + for hashvalue, cracked in result.items(): + f.write(hashvalue + ':' + cracked + '\n') + print ('%s Results saved in cracked-%s' % (info, file.split('/')[-1])) + + elif args.hash: + single(args) +
app.languageChecker.chisquared/chiSquared.__init__
Modified
Ciphey~Ciphey
064d9f1415e95022f11ca978448066120079269a
added de-hashing functionality
<2>:<add> #[0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <del> [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <4>:<add> [0.0812, 0.0271, 0.0149, 0.1202, 0.0432, 0.0203, 0.023, 0.0731, 0.0592, 0.0069, 0.001, 0.026099999999999998, 0.0398, 0.0768, 0.0695, 0.0011, 0.0182, 0.06280000000000001, 0.0602, 0.0288, 0
# module: app.languageChecker.chisquared class chiSquared: def __init__(self): <0> self.languages = { <1> "English": <2> [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] <3> #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} <4> } <5> self.average = 0.0 <6> self.totalDone = 0.0 <7> self.oldAverage = 0.0 <8> self.mh = mathsHelper.mathsHelper() <9> self.highestLanguage = "" <10> self.totalChi = 0.0 <11> self.totalEqual = False <12> self.chisAsaList = [] <13> <14> # these are settings that may impact how the program works overall <15> self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go</s>
===========below chunk 0=========== # module: app.languageChecker.chisquared class chiSquared: def __init__(self): # offset: 1 self.totalDoneThreshold = 10 self.standarddeviation = 0.00 # the standard deviation I use self.oldstandarddeviation = 0.00 ===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared.chiSquared self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) self.highestLanguage = language self.oldAverage = self.average self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone self.standarddeviation = std(self.chisAsaList) ===========changed ref 0=========== + # module: app.Decryptor.Hash.hashBuster + + def alpha(hashvalue, hashtype): + return False + ===========changed ref 1=========== + # module: app.Decryptor.Hash.hashBuster + + result = {} + ===========changed ref 2=========== # module: app.languageChecker.neural - - class Neuron: - def __init__(self, weights, bias): - self.weights = weights - self.bias = bias - ===========changed ref 3=========== # module: app.mathsHelper class mathsHelper: + def stripPuncuation(self, text): + """Strips punctuation from a given string""" + return text.translate(None, punctuation) + ===========changed ref 4=========== # module: app.languageChecker.dictionaryChecker class dictionaryChecker: + + def confirmlanguage(self, text, language): + self.checkDictionary(text, language) + if self.languagePercentage > self.languageThreshold: + return True + else: + return False + ===========changed ref 5=========== + # module: app.Decryptor.Hash.hashBuster + + def threaded(hashvalue): + resp = crack(hashvalue) + if resp: + print (hashvalue + ' : ' + resp) + result[hashvalue] = resp + ===========changed ref 6=========== # module: app.languageChecker.neural - - class Neuron: - - def feedforward(self, inputs): - # weight inputs, add bias, then use the activaton function - total = np.dot(self.weights, inputs) + self.bias - return sigmoid(total) - ===========changed ref 7=========== + # module: app.Decryptor.Hash.hashBuster + + def single(args): + result = crack(args.hash) + if result: + print (result) + else: + print ('%s Hash was not found in any database.' % bad) + ===========changed ref 8=========== # module: app.languageChecker.neural + + def deriv_sigmoid(x): + # Derivative of sigmoid: f'(x) = f(x) * (1 - f(x)) + fx = sigmoid(x) + return fx * (1 - fx) + ===========changed ref 9=========== + # module: app.Decryptor.Hash.hashBuster + + def gamma(hashvalue, hashtype): + response = requests.get('https://www.nitrxgen.net/md5db/' + hashvalue).text + if response: + return response + else: + return False + ===========changed ref 10=========== # module: app.languageChecker.dictionaryChecker class dictionaryChecker: def __init__(self): + self.mh = mathsHelper.mathsHelper() + self.languagePercentage = 0.0 + self.languageWordsCounter = 0.0 + self.languageThreshold = 45 - None ===========changed ref 11=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + ''' + A neural network with: + - 2 inputs + - a hidden layer with 2 neurons (h1, h2) + - an output layer with 1 neuron (o1) + ''' + ===========changed ref 12=========== # module: app.languageChecker.neural - - class NeuralNetwork: - def __init__(self): - weights = np.array([0, 1]) - bias = 0 - - self.h1 = Neuron(weights,bias) - self.h2 = Neuron(weights, bias) - self.o1 = Neuron(weights, bias) - ===========changed ref 13=========== + # module: app.Decryptor.Hash.hashBuster + + def beta(hashvalue, hashtype): + response = requests.get('https://hashtoolkit.com/reverse-hash/?hash=', hashvalue).text + match = re.search(r'/generate-hash/?text=.*?"', response) + if match: + return match.group(1) + else: + return False + ===========changed ref 14=========== + # module: app.Decryptor.Hash.hashBuster + + def theta(hashvalue, hashtype): + response = requests.get('https://md5decrypt.net/Api/api.php?hash=%s&hash_type=%s&[email protected]&code=1152464b80a61728' % (hashvalue, hashtype)).text + if len(response) != 0: + return response + else: + return False + ===========changed ref 15=========== # module: app.languageChecker.neural - - class NeuralNetwork: - def feedforward(self, x): - out_h1 = self.h1.feedforward(x) - out_h2 = self.h2.feedforward(x) - - # the inputs for o1 are the output sfor h1, h2 - out_o1 = self.o1.feedforward(np.array([out_h1, out_h2])) - return out_o1 - ===========changed ref 16=========== # module: app.languageChecker.neural + + class OurNeuralNetwork: + + def feedforward(self, x): + # x is a numpy array with 2 elements. + h1 = sigmoid(self.w1 * x[0] + self.w2 * x[1] + self.b1) + h2 = sigmoid(self.w3 * x[0] + self.w4 * x[1] + self.b2) + o1 = sigmoid(self.w5 * h1 + self.w6 * h2 + self.b3) + return o1 + ===========changed ref 17=========== + # module: app.Decryptor.Hash.hashBuster + + def delta(hashvalue, hashtype): + #data = {'auth':'8272hgt', 'hash':hashvalue, 'string':'','Submit':'Submit'} + #response = requests.post('http://hashcrack.com/index.php' , data).text + #match = re.search(r'<span class=hervorheb2>(.*?)</span></div></TD>', response) + #if match: + # return match.group(1) + #else: + return False +
app.mathsHelper/mathsHelper.stripPuncuation
Modified
Ciphey~Ciphey
12f3c58abf0b119ba630066f80913ca4f37d4c5c
ok i fixed it
<1>:<add> return text.translate(str.maketrans('','',punctuation)) <del> return text.translate(None, punctuation)
# module: app.mathsHelper class mathsHelper: def stripPuncuation(self, text): <0> """Strips punctuation from a given string""" <1> return text.translate(None, punctuation) <2>
===========unchanged ref 0=========== at: string punctuation = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
app.languageChecker.LanguageChecker/languageChecker.__add__
Modified
Ciphey~Ciphey
12f3c58abf0b119ba630066f80913ca4f37d4c5c
ok i fixed it
<1>:<add> print("anyhting")
# module: app.languageChecker.LanguageChecker class languageChecker: # todo check chi to see if its significant # if it is, run this # if percetageOfEnglish > 45: # print("I'm pretty sure this is English") def __add__(self, otherLanguageObject): <0> pass <1>
===========changed ref 0=========== + # module: app.neuralNetwork.starter + mnist = tf.keras.datasets.mnist # 28x28 images of hand-written digits 0-9 + ===========changed ref 1=========== # module: app.mathsHelper class mathsHelper: def stripPuncuation(self, text): """Strips punctuation from a given string""" + return text.translate(str.maketrans('','',punctuation)) - return text.translate(None, punctuation) ===========changed ref 2=========== + # module: app.Decryptor.friendsCode.xorencode + plain = input("Enter plaintext: ").strip() + key = input("Enter key: ").strip() + + i = 0 + ciphertext = "" + for char in plain: + if char != " ": + ciphertext += chr((ord(char)) ^ (ord(key[i]))) + i += 1 + else: + ciphertext += " " + + print("Ciphertext (basically useless):\n"+ciphertext) + + print("Ascii Values:") + for x in ciphertext: + if x != " ": + val = ord(x) + print(val,end=" ") + print("In binary: {0:b}".format(val)) +
app.mathsHelper/mathsHelper.percentage
Modified
Ciphey~Ciphey
3296a79e762f70e6e896f0ae8ba3187882873dad
made dictionary changer work
<3>:<add> if part <= 0 or whole <= 0: <del> if part or whole <= 0: <5>:<del>
# module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): <0> """Works with percentages""" <1> # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea <2> # this if statememt is to stop my stupidity <3> if part or whole <= 0: <4> return 0 <5> <6> # works with percentages <7> return 100 * float(part)/float(whole) <8>
app.mathsHelper/mathsHelper.stripPuncuation
Modified
Ciphey~Ciphey
3296a79e762f70e6e896f0ae8ba3187882873dad
made dictionary changer work
<1>:<add> text = text.translate(str.maketrans('','',punctuation)) <del> return text.translate(str.maketrans('','',punctuation)) <2>:<add> return text
# module: app.mathsHelper class mathsHelper: def stripPuncuation(self, text): <0> """Strips punctuation from a given string""" <1> return text.translate(str.maketrans('','',punctuation)) <2>
===========unchanged ref 0=========== at: string punctuation = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" ===========changed ref 0=========== # module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): """Works with percentages""" # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea # this if statememt is to stop my stupidity + if part <= 0 or whole <= 0: - if part or whole <= 0: return 0 - # works with percentages return 100 * float(part)/float(whole)
app.languageChecker.dictionaryChecker/dictionaryChecker.checkDictionary
Modified
Ciphey~Ciphey
3296a79e762f70e6e896f0ae8ba3187882873dad
made dictionary changer work
<7>:<del> text = text.sort() <9>:<add> text.sort() <11>:<add> file = open("languageChecker/{}".format(language), "r") <del> f = open(language, "r") <12>:<add> f = file.readlines() <del> f = f.readlines() <13>:<add> file.close() <15>:<add> <add> # so this should loop until it gets to the point in the @staticmethod <add> # that equals the word :) <add> <add> """ <add> for every single word in main dictionary <add> if that word == text[0] then +1 to counter <add> then +1 to text[0 + i] <add> so say the dict is ordered <add> we just loop through dict <add> and eventually we'll reach a point where word in dict = word in text <add> at that point, we move to the next text point <add> both text and dict are sorted <add> so we only loop once, we can do this in O(n log n) time <add> """ <add> counter = 0 <add> counterPercent = 0 <add>
# module: app.languageChecker.dictionaryChecker class dictionaryChecker: def checkDictionary(self, text, language): <0> """Compares a word with <1> The dictionary is sorted and the text is sorted""" <2> # reads through most common words / passwords <3> # and calculates how much of that is in language <4> text = text.lower() <5> text = self.mh.stripPuncuation(text) <6> text = text.split(" ") <7> text = text.sort() <8> text = list(set(text)) # removes duplicate words <9> # can dynamically use languages then <10> language = str(language) + ".txt" <11> f = open(language, "r") <12> f = f.readlines() <13> counter = 0.00 <14> # dictionary is "word\n" so I remove the "\n" <15> for word[0:-2] in f: <16> if word == text: <17> counter = counter + 1 <18> self.languageWordsCounter = counter <19> self.languagePercentage = mh.percentage(self.languageWordsCounter, len(text)) <20> return(counter) <21>
===========unchanged ref 0=========== at: app.languageChecker.dictionaryChecker.dictionaryChecker.__init__ self.mh = mathsHelper.mathsHelper() self.languagePercentage = 0.0 self.languageWordsCounter = 0.0 at: io.BufferedRandom readlines(self, hint: int=..., /) -> List[bytes] at: typing.IO __slots__ = () readlines(hint: int=...) -> list[AnyStr] ===========changed ref 0=========== # module: app.mathsHelper class mathsHelper: def stripPuncuation(self, text): """Strips punctuation from a given string""" + text = text.translate(str.maketrans('','',punctuation)) - return text.translate(str.maketrans('','',punctuation)) + return text ===========changed ref 1=========== # module: app.mathsHelper class mathsHelper: def percentage(self, part, whole): """Works with percentages""" # yeah uhm sometimes I'm a dummy dum dum and I think dividing by 0 is a good idea # this if statememt is to stop my stupidity + if part <= 0 or whole <= 0: - if part or whole <= 0: return 0 - # works with percentages return 100 * float(part)/float(whole) ===========changed ref 2=========== # module: app.Tests.testchi_squared # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestChi(unittest.TestCase): + def test_my_chi(self): + self.chi = chisquared.chiSquared() + result = self.chi.myChi(self.chi.getLetterFreq("hello this is my test"), [0.0812, 0.0271, 0.0149, 0.1202, 0.0432, 0.0203, 0.023, 0.0731, 0.0592, 0.0069, 0.001, 0.026099999999999998, 0.0398, 0.0768, 0.0695, 0.0011, 0.0182, 0.06280000000000001, 0.0602, 0.0288, 0.091, 0.0209, 0.0111, 0.021099999999999997, 0.0017000000000000001, 0.0007000000000000001]) + self.assertEqual(result, 1424.8873999810571) +
app.languageChecker.chisquared/chiSquared.chiSquared
Modified
Ciphey~Ciphey
efa56c6414b7dfc246195801f3df026972c2ac3b
daily update
<2>:<add> <del>
# module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): <0> """Creates letter frequency of text and compares that to the letter frequency of the language""" <1> <2> <3> # if all items of the dictionary are the same, then it's a normal distribution <4> # examples of this could be "the quick brown fox jumped over the lazy dog" <5> <6> letterFreq = self.getLetterFreq(text) <7> self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) <8> <9> # so we dont have to calculate len more than once <10> # turns them into probabilities (frequency distribution) <11> lenOfString = len(text) <12> totalLetterFreq = 0.0 <13> for key, value in letterFreq.items(): <14> try: <15> letterFreq[key] = value / lenOfString <16> totalLetterFreq = totalLetterFreq + value <17> except ZeroDivisionError as e: <18> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <19> exit(1) <20> <21> # calculates chi squared of each language <22> maxChiSquare = 0.00 <23> languagesChi = {} <24> <25> for language in self.languages: <26> #, list(languages[language].values()) <27> temp = self.myChi(letterFreq, self.languages[language]) <28> languagesChi[language] = temp <29> if temp > maxChiSquare: <30> self.highestLanguage = language <31> maxChiSquare = temp <32> self.chisAsaList.append(maxChiSquare) <33> # calculates running average <34> self.oldAverage = self.average <35> self.totalDone += 1 <36> # calculates a running average, maxChiSquare is the new chi score we get <37> self.</s>
===========below chunk 0=========== # module: app.languageChecker.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 self.oldstandarddeviation = self.standarddeviation self.standarddeviation = std(self.chisAsaList) return(languagesChi) ===========unchanged ref 0=========== at: app.languageChecker.chisquared.chiSquared getLetterFreq(text) myChi(text, distribution) ===========unchanged ref 1=========== at: app.languageChecker.chisquared.chiSquared.__init__ self.languages = { "English": #[0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} [0.0812, 0.0271, 0.0149, 0.1202, 0.0432, 0.0203, 0.023, 0.0731, 0.0592, 0.0069, 0.001, 0.026099999999999998, 0.0398, 0.0768, 0.0695, 0.0011, 0.0182, 0.06280000000000001, 0.0602, 0.0288, 0.091, 0.0209, 0.0111, 0.021099999999999997, 0.0017000000000000001, 0.0007000000000000001] } ===========unchanged ref 2=========== self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 self.totalEqual = False self.chisAsaList = [] self.standarddeviation = 0.00 # the standard deviation I use self.oldstandarddeviation = 0.00 at: numpy.core.fromnumeric std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: _ArrayType=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> _ArrayType std(a: _ArrayLikeComplex_co, axis: None=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> floating[Any] std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None=..., dtype: _DTypeLike[_SCT]=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> _SCT std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any
app.neuralNetwork.nn/neuralNetwork.useNetwork
Modified
Ciphey~Ciphey
3e02f07520fea77ad7ad70cedf09788b2c49a64f
wrote more tests, squashed some bugs, drank soda, ran out of gum, now onto apples"
<0>:<add> """data is a list containing these 3 things (in this order) <add> * length of text <add> * how many letters it has (so, abc = 3. aab = 2) <add> * the normalised chi square score (not relating to a specific language)""" <add> new = [] <add> final.append(data) <add> final = numpy.asarray(final) <add> #print(new.shape) <add> result = model.predict(new) <add> return result <del> pass
# module: app.neuralNetwork.nn class neuralNetwork: def useNetwork(self, data): <0> pass <1>
===========changed ref 0=========== + # module: app.languageCheckerMod.chisquared + + ===========changed ref 1=========== + # module: app.languageCheckerMod.LanguageChecker + + ===========changed ref 2=========== + # module: app.languageCheckerMod.dictionaryChecker + + ===========changed ref 3=========== + # module: app.main + + ===========changed ref 4=========== + # module: app.languageCheckerMod.LanguageChecker + + class languageChecker: + def getChiSquaredObj(self): + return self.chi + ===========changed ref 5=========== + # module: app.languageCheckerMod.chisquared + class chiSquared: + def getMostLikelyLanguage(self): + """Returns what the most likely language is + Only used when the threshold of checkChi is reached""" + return self.highestLanguage + ===========changed ref 6=========== + # module: app.languageCheckerMod.LanguageChecker + + class languageChecker: + def __init__(self): + self.dictionary = languageCheckerMod.dictionaryChecker.dictionaryChecker() + self.chi = languageCheckerMod.chisquared.chiSquared() + ===========changed ref 7=========== + # module: app.languageCheckerMod.chisquared + # I had a bug where empty string was being added to letter freq dictionary + # this solves it :) + punctuation += " " + NUMBERS = "1234567890" + ===========changed ref 8=========== + # module: app.languageCheckerMod.dictionaryChecker + class dictionaryChecker: + + def confirmlanguage(self, text, language): + self.checkDictionary(text, language) + + if self.languagePercentage > self.languageThreshold: + return True + else: + return False + ===========changed ref 9=========== + # module: app.languageCheckerMod.dictionaryChecker + class dictionaryChecker: + def __init__(self): + self.mh = mathsHelper.mathsHelper() + self.languagePercentage = 0.0 + self.languageWordsCounter = 0.0 + self.languageThreshold = 45 + ===========changed ref 10=========== + # module: app.languageCheckerMod.LanguageChecker + + class languageChecker: + def __add__(self, otherLanguageObject): + # sets the added chi squared to be of this one + new = otherLanguageObject.getChiSquaredObj() + self.getChiSquaredObj() + self.chi = new + return self + ===========changed ref 11=========== + # module: app.languageCheckerMod.LanguageChecker + + class languageChecker: + def checkLanguage(self, text): + result = self.chi.checkChi(text) + if result: + result2 = self.dictionary.confirmlanguage(text, "English") + if result2: + return True + else: + return False + else: + return False + ===========changed ref 12=========== + # module: app.languageCheckerMod.chisquared + class chiSquared: + """Class that calculates the Chi squared score and tries to work out what language it might be + to add a new language, go into this class (/app/languageChecker/chisquared.py) + Find "self.languages" and add it to the dictionary like "German":[0.789, 0.651...] + The list is the letter frequency ordered in alphabetical order """ + ===========changed ref 13=========== + # module: app.languageCheckerMod.dictionaryChecker + class dictionaryChecker: + """ + Class designed to confirm whether something is **language** based on how many words of **language** appears + Call confirmlanguage(text, language) + * text: the text you want to confirm + * language: the language you want to confirm + + Find out what language it is by using chisquared.py, the highest chisquared score is the language + languageThreshold = 45 + if a string is 45% **language** words, then it's confirmed to be english + """ + ===========changed ref 14=========== + # module: app.languageCheckerMod.chisquared + class chiSquared: + def __add__(self, otherChiSquared): + """ + each language checker has its own intance of chi squared + so to add 2 languae checkers together we add their chi squared together + """ + addedObject = chiSquared() + addedObject.average = self.average + otherChiSquared.average + addedObject.totalDone = self.totalDone + otherChiSquared.totalDone + addedObject.totalChi = self.totalChi + otherChiSquared.totalChi + addedObject.chisAsaList = self.chisAsaList + otherChiSquared.chisAsaList + return addedObject + ===========changed ref 15=========== + # module: app.languageCheckerMod.chisquared + class chiSquared: + def myChi(self, text, distribution): + """My own implementation of Chi squared using the two resources mention in the comments on this definition as guidance""" + # chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/https://cgi.csc.liv.ac.uk/~john/comp105resources/lecture10.pdf + # http://practicalcryptography.com/cryptanalysis/text-characterisation/chi-squared-statistic/ + # given a text frequency and a distribution, calculate it's Chi score + chiScore = 0.0 + for counter, letter in enumerate(text.values()): + chiScore = chiScore + ((letter - distribution[counter])**2) / distribution[counter] + return chiScore + ===========changed ref 16=========== # module: app.mathsHelper class mathsHelper: + def getAllLetters(self, text): + # This part creates a letter frequency of the text + letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} + + for letter in text.lower(): + if letter in letterFreq: + letterFreq[letter] +=1 + else: + # if letter is not puncuation, but it is still ascii + # it's probably a different language so add it to the dict + if letter not in punctuation and self.mh.isAscii(letter) : + letterFreq[letter] = 1 + return letterFreq + ===========changed ref 17=========== + # module: app.languageCheckerMod.chisquared + class chiSquared: + def getLetterFreq(self, text): + # This part creates a letter frequency of the text + letterFreq = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0} + + for letter in text.lower(): + if letter in letterFreq: + letterFreq[letter] +=1 + else: + # if letter is not puncuation, but it is still ascii + # it's probably a different language so add it to the dict + if letter not in punctuation and self.mh.isAscii(letter) and letter not in NUMBERS: + letterFreq[letter] = 1 + return letterFreq +
app.languageCheckerMod.dictionaryChecker/dictionaryChecker.__init__
Modified
Ciphey~Ciphey
f753829586c2366df64e6b4b74e00a081b4d8fdf
wrote tests
<3>:<add> self.languageThreshold = 25 <del> self.languageThreshold = 45
# module: app.languageCheckerMod.dictionaryChecker class dictionaryChecker: def __init__(self): <0> self.mh = mathsHelper.mathsHelper() <1> self.languagePercentage = 0.0 <2> self.languageWordsCounter = 0.0 <3> self.languageThreshold = 45 <4>
===========unchanged ref 0=========== at: app.languageCheckerMod.dictionaryChecker.dictionaryChecker.checkDictionary self.languageWordsCounter = counter self.languagePercentage = self.mh.percentage(float(self.languageWordsCounter), float(len(text)))
app.languageCheckerMod.LanguageChecker/languageChecker.checkLanguage
Modified
Ciphey~Ciphey
f753829586c2366df64e6b4b74e00a081b4d8fdf
wrote tests
<0>:<add> if text == "": <add> return False
# module: app.languageCheckerMod.LanguageChecker class languageChecker: def checkLanguage(self, text): <0> result = self.chi.checkChi(text) <1> if result: <2> result2 = self.dictionary.confirmlanguage(text, "English") <3> if result2: <4> return True <5> else: <6> return False <7> else: <8> return False <9>
===========unchanged ref 0=========== at: app.languageCheckerMod.LanguageChecker.languageChecker.__add__ self.chi = new at: app.languageCheckerMod.LanguageChecker.languageChecker.__init__ self.dictionary = languageCheckerMod.dictionaryChecker.dictionaryChecker() self.chi = languageCheckerMod.chisquared.chiSquared() at: languageCheckerMod.chisquared.chiSquared checkChi(text) at: languageCheckerMod.dictionaryChecker.dictionaryChecker confirmlanguage(text, language) ===========changed ref 0=========== # module: app.languageCheckerMod.dictionaryChecker class dictionaryChecker: def __init__(self): self.mh = mathsHelper.mathsHelper() self.languagePercentage = 0.0 self.languageWordsCounter = 0.0 + self.languageThreshold = 25 - self.languageThreshold = 45
app.Tests.testintegration_languagechecker/TestLanguageChecker.test_chi_maxima_true
Modified
Ciphey~Ciphey
f753829586c2366df64e6b4b74e00a081b4d8fdf
wrote tests
<4>:<add> result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d") <add> result = lc.checkLanguage("df grtsf a sgrds fgserwqd") <add> result = lc.checkLanguage("fd sa fe safsda srmad sadsa d") <add> result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug") <add> result = lc.checkLanguage("oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv") <add> result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0") <add> result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h") <add> result = lc.checkLanguage("posa idijdsa ije i vi ijerijofdj ouhsaf oi
# module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): def test_chi_maxima_true(self): <0> """ <1> This returns false because s.d is not over 1 as all inputs are English <2> """ <3> lc = LanguageChecker.languageChecker() <4> result = lc.checkLanguage("The quick brown fox jumped over the lazy dog") <5> result = lc.checkLanguage("Hypertext Transfer Protocol (HTTP) parameters, including HTTP headers, allow the client and the server to pass additional information with the request or the response.") <6> result = lc.checkLanguage("Hypertext Transfer Protocol (HTTP) parameters, including HTTP headers, allow the client and the server to pass additional information with the request or the response.") <7> result = lc.checkLanguage("HTTP parameters and headers can often reveal information about how a web application is transmitting data and storing cookies. Clients send parameters including the user agent of the browser.") <8> result = lc.checkLanguage("You probably build websites and think your shit is special. You think your 13 megabyte parallax-ative home page is going to get you some fucking Awwward banner you can glue to the top corner of your site. You think your 40-pound jQuery file and 83 polyfills give IE7 a boner because it finally has box-shadow. Wrong, motherfucker. Let me describe your perfect-ass website:") <9> result = lc.checkLanguage("You. Are. Over-designing. Look at this shit. It's a motherfucking website. Why the fuck do you need to animate a fucking trendy-ass banner flag when I hover over that useless piece of shit? You spent hours on it and added 80 kilobytes to your fucking site, and some motherfucker jabbing at it on their iPad with fat sausage fingers will never see that shit</s>
===========below chunk 0=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): def test_chi_maxima_true(self): # offset: 1 result = lc.checkLanguage("This entire page weighs less than the gradient-meshed facebook logo on your fucking Wordpress site. Did you seriously load 100kb of jQuery UI just so you could animate the fucking background color of a div? You loaded all 7 fontfaces of a shitty webfont just so you could say at 100px height at the beginning of your site? You piece of shit.") result = lc.checkLanguage("You dumbass. You thought you needed media queries to be responsive, but no. Responsive means that it responds to whatever motherfucking screensize it's viewed on. This site doesn't care if you're on an iMac or a motherfucking Tamagotchi.") result = lc.checkLanguage("Like the man who's never grown out his beard has no idea what his true natural state is, you have no fucking idea what a website is. All you have ever seen are shitty skeuomorphic bastardizations of what should be text communicating a fucking message. This is a real, naked website. Look at it. It's fucking beautiful.") result = lc.checkLanguage("Have you guys noticed that sometimes the foremost academic websites with lots of scientific information tend to look like this?") result = lc.checkLanguage("That's because academics do Save as Website from Microsoft Word and call it a day.") result = lc.checkLanguage("In case anyone was interested, fuck is used 33 times in the page.") result = lc.checkLanguage("Hi! I just checked this URL and it appeared to be unavailable or slow loading (Connection timed out after 8113 milliseconds). Here are some mirrors to try:")</s> ===========below chunk 1=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): def test_chi_maxima_true(self): # offset: 2 <s> this URL and it appeared to be unavailable or slow loading (Connection timed out after 8113 milliseconds). Here are some mirrors to try:") result = lc.checkLanguage("There can only be one way to make this work for real and I really do enjoy the long thought out process of drinking milk") self.assertEqual(result, False) ===========unchanged ref 0=========== at: languageCheckerMod.LanguageChecker languageChecker() at: languageCheckerMod.LanguageChecker.languageChecker checkLanguage(text) at: unittest.case.TestCase failureException: Type[BaseException] longMessage: bool maxDiff: Optional[int] _testMethodName: str _testMethodDoc: str assertEqual(first: Any, second: Any, msg: Any=...) -> None ===========changed ref 0=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_chi_maxima_false(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("The quick brown fox jumped over the lazy dog") + result = lc.checkLanguage("Hypertext Transfer Protocol (HTTP) parameters, including HTTP headers, allow the client and the server to pass additional information with the request or the response.") + result = lc.checkLanguage("Hypertext Transfer Protocol (HTTP) parameters, including HTTP headers, allow the client and the server to pass additional information with the request or the response.") + result = lc.checkLanguage("HTTP parameters and headers can often reveal information about how a web application is transmitting data and storing cookies. Clients send parameters including the user agent of the browser.") + result = lc.checkLanguage("You probably build websites and think your shit is special. You think your 13 megabyte parallax-ative home page is going to get you some fucking Awwward banner you can glue to the top corner of your site. You think your 40-pound jQuery file and 83 polyfills give IE7 a boner because it finally has box-shadow. Wrong, motherfucker. Let me describe your perfect-ass website:") + result = lc.checkLanguage("You. Are. Over-designing. Look at this shit. It's a motherfucking website. Why the fuck do you need to animate a fucking trendy-ass banner flag when I hover over that useless piece of shit? You spent hours on it and added 80 kilobytes to your fucking site, and some motherfucker jabbing at it on their iPad with fat sausage fingers will never see that shit. Not to mention blind people will never see that shit, but they don't see any of your shitty shit.") </s> ===========changed ref 1=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_chi_maxima_false(self): # offset: 1 <s>it. Not to mention blind people will never see that shit, but they don't see any of your shitty shit.") + result = lc.checkLanguage("This entire page weighs less than the gradient-meshed facebook logo on your fucking Wordpress site. Did you seriously load 100kb of jQuery UI just so you could animate the fucking background color of a div? You loaded all 7 fontfaces of a shitty webfont just so you could say at 100px height at the beginning of your site? You piece of shit.") + result = lc.checkLanguage("You dumbass. You thought you needed media queries to be responsive, but no. Responsive means that it responds to whatever motherfucking screensize it's viewed on. This site doesn't care if you're on an iMac or a motherfucking Tamagotchi.") + result = lc.checkLanguage("Like the man who's never grown out his beard has no idea what his true natural state is, you have no fucking idea what a website is. All you have ever seen are shitty skeuomorphic bastardizations of what should be text communicating a fucking message. This is a real, naked website. Look at it. It's fucking beautiful.") + result = lc.checkLanguage("Have you guys noticed that sometimes the foremost academic websites with lots of scientific information tend to look like this?") + result = lc.checkLanguage("That's because academics do Save as Website from Microsoft Word and call it a day.") + </s>
app.languageCheckerMod.chisquared/chiSquared.checkChi
Modified
Ciphey~Ciphey
f753829586c2366df64e6b4b74e00a081b4d8fdf
wrote tests
<19>:<add> if self.chisAsaList[-1] <= abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: <del> if self.chisAsaList[-1] <= (self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual:
# module: app.languageCheckerMod.chisquared class chiSquared: def checkChi(self, text): <0> """Checks to see if the Chi score is good <1> if it is, it returns True <2> Call this when you want to determine whether something is likely to be Chi or not <3> <4> Arguments: <5> * text - the text you want to run a Chi Squared score on <6> <7> Outputs: <8> * True - if it has a significantly lower chi squared score <9> * False - if it doesn't have a significantly lower chi squared score <10> """ <11> # TODO 20% isn't optimal <12> # runs after every chi squared to see if it's 1 significantly lower than averae <13> # the or statement is bc if the program has just started I don't want it to ignore the <14> # ones at the start <15> self.chiSquared(text) <16> # If the latest chi squared is less than the standard deviation <17> # or if not many chi squares have been calculated <18> # or if every single letter in a text appears exactly once (pangram) <19> if self.chisAsaList[-1] <= (self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: <20> return(True) <21> else: <22> return(False) <23>
===========unchanged ref 0=========== at: app.languageCheckerMod.chisquared.chiSquared chiSquared(self, text) chiSquared(text) at: app.languageCheckerMod.chisquared.chiSquared.__init__ self.average = 0.0 self.totalDone = 0.0 self.totalEqual = False self.chisAsaList = [] self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it self.totalDoneThreshold = 10 self.oldstandarddeviation = 0.00 at: app.languageCheckerMod.chisquared.chiSquared.chiSquared self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) self.totalDone += 1 self.average = (self.totalChi + maxChiSquare) / self.totalDone self.oldstandarddeviation = self.standarddeviation ===========changed ref 0=========== # module: app.languageCheckerMod.LanguageChecker class languageChecker: + def getChiScore(self): + return self.chi.totalChi + ===========changed ref 1=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_three(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("") + self.assertEqual(result, False) + ===========changed ref 2=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_6(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("\"") + self.assertEqual(result, False) + ===========changed ref 3=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_five(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("#") + self.assertEqual(result, False) + ===========changed ref 4=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_four(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage(".") + self.assertEqual(result, False) + ===========changed ref 5=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_one(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR") + self.assertEqual(result, True) + ===========changed ref 6=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_two(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + self.assertEqual(result, False) + ===========changed ref 7=========== # module: app.languageCheckerMod.dictionaryChecker class dictionaryChecker: def __init__(self): self.mh = mathsHelper.mathsHelper() self.languagePercentage = 0.0 self.languageWordsCounter = 0.0 + self.languageThreshold = 25 - self.languageThreshold = 45 ===========changed ref 8=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_7(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("") + self.assertEqual(result, False) + ===========changed ref 9=========== # module: app.languageCheckerMod.LanguageChecker class languageChecker: def checkLanguage(self, text): + if text == "": + return False result = self.chi.checkChi(text) if result: result2 = self.dictionary.confirmlanguage(text, "English") if result2: return True else: return False else: return False ===========changed ref 10=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_addition(self): + """ + Makes sure you can add 2 lanuggae objecs together + """ + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("hello my darling") + + lc2 = LanguageChecker.languageChecker() + result = lc.checkLanguage("sad as dasr as s") + + temp = lc.getChiScore() + temp2 = lc2.getChiScore() + temp3 = temp + temp2 + print(temp3) + lc3 = lc + lc2 + print(lc3.getChiScore()) + + self.assertAlmostEqual(lc3.getChiScore(), temp3) +
app.languageCheckerMod.chisquared/chiSquared.chiSquared
Modified
Ciphey~Ciphey
f753829586c2366df64e6b4b74e00a081b4d8fdf
wrote tests
# module: app.languageCheckerMod.chisquared class chiSquared: def chiSquared(self, text): <0> """Creates letter frequency of text and compares that to the letter frequency of the language""" <1> <2> <3> # if all items of the dictionary are the same, then it's a normal distribution <4> # examples of this could be "the quick brown fox jumped over the lazy dog" <5> <6> letterFreq = self.getLetterFreq(text) <7> self.totalEqual = self.mh.checkEqual(list(letterFreq.values())) <8> <9> # so we dont have to calculate len more than once <10> # turns them into probabilities (frequency distribution) <11> lenOfString = len(text) <12> totalLetterFreq = 0.0 <13> for key, value in letterFreq.items(): <14> try: <15> letterFreq[key] = value / lenOfString <16> totalLetterFreq = totalLetterFreq + value <17> except ZeroDivisionError as e: <18> print("Error, you have entered an empty string :( The error is \"" + str(e) +"\" on line 34 of LanguageChecker.py (function chiSquared)") <19> exit(1) <20> <21> # calculates chi squared of each language <22> maxChiSquare = 0.00 <23> languagesChi = {} <24> <25> for language in self.languages: <26> #, list(languages[language].values()) <27> temp = self.myChi(letterFreq, self.languages[language]) <28> languagesChi[language] = temp <29> if temp > maxChiSquare: <30> self.highestLanguage = language <31> maxChiSquare = temp <32> self.chisAsaList.append(maxChiSquare) <33> # calculates running average <34> self.oldAverage = self.average <35> self.totalDone += 1 <36> # calculates a running average, maxChiSquare is the new chi score we get <37> </s>
===========below chunk 0=========== # module: app.languageCheckerMod.chisquared class chiSquared: def chiSquared(self, text): # offset: 1 self.oldstandarddeviation = self.standarddeviation self.standarddeviation = std(self.chisAsaList) return(languagesChi) ===========unchanged ref 0=========== at: app.languageCheckerMod.chisquared.chiSquared getLetterFreq(text) myChi(text, distribution) myChi(self, text, distribution) ===========unchanged ref 1=========== at: app.languageCheckerMod.chisquared.chiSquared.__init__ self.languages = { "English": #[0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011] #{'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07} [0.0812, 0.0271, 0.0149, 0.1202, 0.0432, 0.0203, 0.023, 0.0731, 0.0592, 0.0069, 0.001, 0.026099999999999998, 0.0398, 0.0768, 0.0695, 0.0011, 0.0182, 0.06280000000000001, 0.0602, 0.0288, 0.091, 0.0209, 0.0111, 0.021099999999999997, 0.0017000000000000001, 0.0007000000000000001] } ===========unchanged ref 2=========== self.average = 0.0 self.totalDone = 0.0 self.oldAverage = 0.0 self.mh = mathsHelper.mathsHelper() self.highestLanguage = "" self.totalChi = 0.0 self.totalEqual = False self.chisAsaList = [] self.standarddeviation = 0.00 # the standard deviation I use self.oldstandarddeviation = 0.00 at: numpy.core.fromnumeric std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: _ArrayType=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> _ArrayType std(a: _ArrayLikeComplex_co, axis: None=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> floating[Any] std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None=..., dtype: _DTypeLike[_SCT]=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> _SCT std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any ===========changed ref 0=========== # module: app.languageCheckerMod.chisquared class chiSquared: def checkChi(self, text): """Checks to see if the Chi score is good if it is, it returns True Call this when you want to determine whether something is likely to be Chi or not Arguments: * text - the text you want to run a Chi Squared score on Outputs: * True - if it has a significantly lower chi squared score * False - if it doesn't have a significantly lower chi squared score """ # TODO 20% isn't optimal # runs after every chi squared to see if it's 1 significantly lower than averae # the or statement is bc if the program has just started I don't want it to ignore the # ones at the start self.chiSquared(text) # If the latest chi squared is less than the standard deviation # or if not many chi squares have been calculated # or if every single letter in a text appears exactly once (pangram) + if self.chisAsaList[-1] <= abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: - if self.chisAsaList[-1] <= (self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)) or self.totalDone < self.totalDoneThreshold or self.totalEqual: return(True) else: return(False) ===========changed ref 1=========== # module: app.languageCheckerMod.LanguageChecker class languageChecker: + def getChiScore(self): + return self.chi.totalChi + ===========changed ref 2=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_three(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("") + self.assertEqual(result, False) + ===========changed ref 3=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_6(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("\"") + self.assertEqual(result, False) + ===========changed ref 4=========== # module: app.Tests.testintegration_languagechecker # python3 -m unittest Tests.testchi_squared # python -m unittest discover -s tests # python3 -m unittest discover -s Tests -p test*.py class TestLanguageChecker(unittest.TestCase): + def test_integration_unusual_five(self): + lc = LanguageChecker.languageChecker() + result = lc.checkLanguage("#") + self.assertEqual(result, False) +
End of preview. Expand in Data Studio

Dataset Card for "Coeditor-processed-demo2"

More Information needed

Downloads last month
50