def compareinit(self, widget): threshold = self.thresholdtext.get_text() if not threshold.isdigit(): threshold = 1 else: threshold = int(threshold) if len(self.files) == 0: dialog = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, u"No file chosen") dialog.set_title("Error") dialog.run() dialog.destroy() elif len(self.files) < 2: dialog = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, u"Only one file chosen") dialog.set_title("Error") dialog.run() dialog.destroy() else: ngramdict1_1 = sentencer.sentencer(self.files[0]) ngramdict2_1 = sentencer.sentencer(self.files[1]) result1 = comparator.comparator(ngramdict1_1, ngramdict2_1) ngramdict1_2 = sentencer.sentencer(self.files[1]) ngramdict2_2 = sentencer.sentencer(self.files[0]) result2 = comparator.comparator(ngramdict1_2, ngramdict2_2) result = (result1+result2)/2 if result > threshold: dialog = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, u"The percentage similarity is " + str(result) + "%. It is greater than user set threshold. So the documents are near duplicates.") dialog.run() dialog.destroy() else: dialog = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, u"The percentage similarity is " + str(result) + "%. It is less than user set threshold. So the documents are not near duplicates.") dialog.run() dialog.destroy()
def create_modules(self): """ Construct all the required modules """ self.lfsr = lfsr(size=self.addr_size, name="bist_lfsr") self.add_mod(self.lfsr) self.fsm = fsm() self.add_mod(self.fsm) self.xor2 = xor2() self.add_mod(self.xor2) self.inv = pinv() self.add_mod(self.inv) if self.async_bist: self.osc = oscillator(self.delay) self.add_mod(self.osc) else: self.osc = frequency_divider() self.add_mod(self.osc) self.data_pattern = data_pattern(self.data_size) self.add_mod(self.data_pattern) self.comparator = comparator(self.data_size) self.add_mod(self.comparator)
def test_comparator_function(): file = open("test.csv", "w") file.write("images/test_source.png,images/test_target.png") file.close() with open('test.csv', 'r', newline='') as testfile: test_list = comparator.comparator(testfile) assert any(d['SimilarityScore'] == '10134.0' for d in test_list)
def applyDbChanges(self): writer = writerSql() comparator_obj = comparator(writer) results = comparator_obj.compare(self.db_info_from, self.db_info_to) results.runSql(self.db_connection_target)
def compareSql(self): writer = writerSql() comparator_obj = comparator(writer) results = comparator_obj.compare(self.db_info_from, self.db_info_to) print(results.getText())
def compareMessages(self): writer = writerScreen() comparator_obj = comparator(writer) results = comparator_obj.compare(self.db_info_from, self.db_info_to) print(results.getText())
import comparator import bookParser # parse records from elibrary and google scholar parser = bookParser.bookParser() parser.elibrary() # all names for this book # parser.scholar('Устойчивость нелинейных систем с неединственным состоянием равновесия') # parser.scholar('Stability of nonlinear systems with nonunique equilibrium position(Russian book)') # parser.scholar('Ustojcivost\'nelinejnych sistem s needinstvennym sostojaniem ravnovesija') # parser.scholar('Устойчивость систем с неединственным состоянием равновесия') comparator = comparator.comparator() # in scholar and not in elibrary with open('result/sch-elib.txt', 'w', encoding="utf8") as result: for i in comparator.diff('input/sch.txt', 'input/elib.txt'): result.write(comparator.sch_map.get(i)) # in elibrary and not in scholar with open('result/elib-sch.txt', 'w', encoding="utf8") as result: for i in comparator.diff('input/elib.txt', 'input/sch.txt'): result.write(comparator.elib_map.get(i)) comparator.sortRes("result/elib-sch.txt") comparator.sortRes("result/sch-elib.txt")