def no_record(show=False): name = input("Name of file to read: ") plt.subplot(211) plt.title("Decibel Level") amp.graphThis(name) plt.subplot(212) plt.title("Frequency Graph") freq.frequencyThis(name) plt.tight_layout() save(name) if show: plt.show()
def record_and_graph(show=False): name = input("Name to save files as: ") time = input("Time of sample to take in seconds: ") rec.recordThis(name, int(time)) plt.subplot(211) plt.title("Decibel Level") amp.graphThis(name) plt.subplot(212) plt.title("Frequency Graph") freq.frequencyThis(name) plt.tight_layout() save(name) if show: plt.show()
def main(): originalImage = Image.open('./resource/characters_test_pattern.tif') radius = 160 plt.subplot(2, 2, 1) plt.imshow(originalImage, cmap=plt.get_cmap('gray')) plt.title('Original') plt.subplot(2, 2, 2) idealLowpassImage = Frequency.idealLowpass(originalImage, radius) plt.imshow(idealLowpassImage, cmap=plt.get_cmap('gray')) plt.title('Ideal Lowpass With Radius = %s' % radius) plt.subplot(2, 2, 3) butterworthLowpassImage = Frequency.butterworthLowpass( originalImage, radius, 2) plt.imshow(butterworthLowpassImage, cmap=plt.get_cmap('gray')) plt.title('Butterworth Lowpass With Radius = %s' % radius) plt.subplot(2, 2, 4) gaussianLowpassImage = Frequency.gaussianLowpass(originalImage, radius) plt.imshow(gaussianLowpassImage, cmap=plt.get_cmap('gray')) plt.title('Gaussian Lowpass With Radius = %s' % radius) plt.show() plt.subplot(2, 2, 1) plt.imshow(originalImage, cmap=plt.get_cmap('gray')) plt.title('Original') plt.subplot(2, 2, 2) idealHighpassImage = Frequency.idealHighpass(originalImage, radius) plt.imshow(idealHighpassImage, cmap=plt.get_cmap('gray')) plt.title('Ideal Highpass With Radius = %s' % radius) plt.subplot(2, 2, 3) butterworthHighpassImage = Frequency.butterworthHighpass( originalImage, radius, 2) plt.imshow(butterworthHighpassImage, cmap=plt.get_cmap('gray')) plt.title('Butterworth Highpass With Radius = %s' % radius) plt.subplot(2, 2, 4) gaussianHighpassImage = Frequency.gaussianHighpass(originalImage, radius) plt.imshow(gaussianHighpassImage, cmap=plt.get_cmap('gray')) plt.title('Gaussian Highpass With Radius = %s' % radius) plt.show()
print('<Summary>\n') print(summaries[index]) print('\n<Article>\n\n') print('<' + list_title[index] + '>' + '\n') print(list_contents[index]) #Find the similarity and output the articles in the order of the highest similarity list_sim = Cosine_Similarity.get_similar(list_title[index], list_title, list_contents) print("\n\n<Similar Articles>\n") for i in range(0, len(list_sim)): print(str(i + 1) + ". " + list_sim[i]) #Prints the words that appear the most in the article in order print("\n\n<High Frequency Word>\n") rank_word = Frequency.get_FrequencyWord(index) for i in range(0, len(rank_word)): print(str(i + 1) + ". " + rank_word[i]) print("\n\n") data = input( "Move Main Page or Exit Program? (Enter Yes or Exit) : ") if data.lower() == 'yes'.lower(): page = 1 os.system('cls') elif data.lower() == 'exit'.lower(): break elif ' ' not in data: os.system('cls') rank_title = Frequency.get_FrequencyTitle(data)
#################### root = tk.Tk() root.title('CSC-11300 Final Project') root.geometry('600x600') #Prompt the user to enter n prompt = tk.Label(text='How many most frequent letters to display:', font=('Calibri', 18)) prompt.grid(column=0, row=0) #Entry field entry_field = tk.Entry() entry_field.grid(column=0, row=1) #Button button = tk.Button(text='Submit', command=draw) #Once button clicked, draw() is called button.grid(column=0, row=2) #Canvas for turtle to draw on canvas = tk.Canvas(root, width=600, height=500, background='white') canvas.grid(column=0, row=3) #Read all the info to myFrequency myFrequency = Frequency() #n most frequent letters to display n = 0 root.mainloop
m.AnnotationBracket1 = ann.getAnnotationDetailsfromSoup(s1, 4) m.AnnotationBracket2 = ann.getAnnotationDetailsfromSoup(s1, 5) else: m.AnnotationCodon1 = "" m.AnnotationCodon2 = "" m.AnnotationBracket1 = "" m.AnnotationBracket2 = "" #print annotation ######################################################################################################################## if (collen == 8): #This one extract freq soup = bs.BeautifulSoup(unicode(rows.pop()), 'lxml') m.Coverage = fre.getFrequencyDetailsfromSoup(soup.text) #print(freq) else: m.Coverage = 100 ######################################################################################################################## #This one extract mutation(Only TEXT) soup = bs.BeautifulSoup(unicode(rows.pop()), 'lxml') m.Mutation = soup.text.replace(',', '') # print m.Mutation #print unicode(rows.pop()) ######################################################################################################################## #This one extract position soup = bs.BeautifulSoup(unicode(rows.pop()), 'lxml')
def play_back(filename): wf = wave.open(filename, 'rb') p = pyaudio.PyAudio() stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(CHUNK) while data: stream.write(data) data = wf.readframes(CHUNK) stream.stop_stream() stream.close() if __name__ == '__main__': filename = "sine.wav" #record(filename) f = Frequency.get_freq(filename) print(f, "kHz") play_back(filename) fnew = DopplerShift.shift(f, 50) print(fnew, "kHz") PitchShift.pitch_shift(filename, (fnew - f) * 1000) print(Frequency.get_freq("output" + filename), "kHz") play_back("output" + filename)
else: print('Key Value must be between 1 to 25, Please restart' ) #### print out the cipher text if menu_input == '3': #### activate the bruteforcing module CipheredText = input( 'Enter The Ciphered text:') #### enter the ciphered value VALUES = [ ] #### in following for loop, we will calculate the frequencies of most used letters in english, and add the coefficient values of each possible key 1-26, append in in this array. for x in KeyMAX: #### let's bruteforce with every possible value in KeyMAX BruteForce = [chr((ord(i) - int(x))) for i in CipheredText] #### Bruteforce Function RecoveredText = ''.join( map(str, BruteForce) ) #### the deciphered text is placed seperated, the join function allow to combine text in readable format Score = FrequencyChecker.englishFreqMatchScore( RecoveredText ) #### using the Frequency.py, englishFreqMatchScore function for the text, we get the score of possible decryption. VALUES.append( Score ) #### append calculated score value in the VALUES array HighestFrequancyScore = max( VALUES ) #### determine what is the highest score calculated during bruteforce operation. CorrectKeyIndex = VALUES.index( HighestFrequancyScore ) #### determine the index of the highest score in the array CorrectKeyValue = CorrectKeyIndex + 1 #### add +1 to the index value, this because the array calculation starts with 0,1,2 - and as bruteforce run sequential, then score will be predictable by getting the index of value after adding 1. print('This Cipher Text is Encrypted with Key value of', CorrectKeyValue) #### show the key used for encryption. Decryption = [ chr((ord(i) - int(CorrectKeyValue))) for i in CipheredText
for f in self.sort_freq: print(f"{f[0]}:{f[1]}") else: print(self.freq) def getNth(self,n): if self.sort_freq: return self.sort_freq[n][0] return None #opens up the text to be read then counts the frequency of each letter if __name__=='__main__': opencipher=open("ciphertext2", "r") ciphertext2 = opencipher.read() F=Frequency() F.count(ciphertext2) ################################################################### # looks at every letter in the ciphertext and calculates the total IC and gives a score. total = 0 for k,v in F.freq.items(): #print(f"{k} , {v}") p = (v / len(ciphertext2)) # percentage of how often letter occurs in ciphertext #print(p,end=" ") sqdiff = ((typical_frequency[k]/100) - p)**2 # compare it to typical # total += float(v)/len(ciphertext2) #print(f"{k} , {sqdiff} , {p}, {v} ") total += sqdiff #print(f"Total: {total}") #Calculates the I.C of the ciphertext #in the end this will be compared to the indivisual I.C. from the key length that occurs at the highest percentage