def txt_ltn(self, step, req_n): with open("./data/Text_Only_Ascii_Coll_MWI_NoSem", "r") as f: start = time.time() parser = Parser() parser.parse(f) print("time execution parsing {}".format(time.time() - start)) start = time.time() parser.createVector() print("time execution create vector {}".format(time.time() - start)) start = time.time() search = {2009011: ["olive", "oil", "health", "benefit"]} search2 = {2009036: ["notting", "hill", "film", "actors"]} search3 = { 2009067: ["probabilistic", "models", "in", "information", "retrieval"] } search4 = {2009073: ["web", "link", "network", "analysis"]} search5 = {2009074: ["web", "ranking", "scoring", "algorithm"]} search6 = { 2009078: ["supervised", "machine", "learning", "algorithm"] } search7 = { 2009085: ["operating", "system", "+mutual", "exclusion"] } parser.scoreAndGenerate("GuillaumeBenoitGauthierTheo", step, req_n, "ltn", "articles", "test", search, search2, search3, search4, search5, search6, search7) print("time execution generate runs {}".format(time.time() - start))
def test_compile(self): raw_str = "" with open("../test_file.ez") as f: raw_str = f.read() parser = Parser(Lexer(raw_str)) compiler = Compiler("test_file", parser) run(compiler)
def run2(re): with open("../src/data/Text_Only_Ascii_Coll_MWI_NoSem", "r") as f: parser = Parser() parser.parse(f) #print(parser.corpusW) #[print(i,j) for i,j in parser.corpusW.items()] parser.createVector() search = {2009011: ["olive", "oil", "health", "benefit"]} search2 = {2009036: ["notting", "hill", "film", "actors"]} search3 = {2009067: ["probabilistic", "models", "in", "information", "retrieval"]} search4 = {2009073: ["web", "link", "network", "analysis"]} search5 = {2009074: ["web", "ranking", "scoring", "algorithm"]} search6 = {2009078: ["supervised", "machine", "learning", "algorithm"]} search7 = {2009085: ["operating", "system", "+mutual", "exclusion"]} parser.scoreAndGenerate("GuillaumeBenoitGauthierTheo", "02", re, "ltn", "articles", "sem_test", search, search2, search3, search4, search5, search6, search7)
def __init__(self): self.parser = Parser.Parser("") self.participantList = [] self.messageList = [] self.conversationList = [] self.dirPath = ""
from src import Parser if __name__ == '__main__': with open('data/data.txt') as data: code = [int(x) for x in data.readline().split(',')] parser = Parser.Parser(code) parser.run() print(parser.outputs[-1])
def main(params, l): time_start = datetime.datetime.fromtimestamp(time.time()) print('<main> time_start: ', time_start) l.url = base_url l.user_Login(Userlogin[params['login']], UserPassword[params['login']]) # l.maximize_window() lo = Logic(l.driver) time.sleep(2) lo.leftSwitchVer() time.sleep(5) lo.runLive() time.sleep(5) lo.openTabs() time.sleep(5) lo.allUnselect() time.sleep(5) lo.js() time.sleep(2) while True: time_old = datetime.datetime.fromtimestamp(time.time()) time.sleep(0.5) matchNum = lo.matchNum() s = fMatchNum(matchNum) cmd = """ var done1 = arguments[0]; window.maxBetTriger = true; setTimeout( function() { //true если есть //$(".category-sportList-main[title=Soccer] div").hasClass( "checkbox-checked" ) try { $(".category-sportList-main[title=" + window.maxBetName + "] div").click(); } catch (err) { }; try { $(".category-sportList-main[title=" + window.maxBetName2 + "] div").click(); } catch (err) { }; try { $(".category-sportList-main[title=" + window.maxBetName3 + "] div").click(); } catch (err) { }; } , 400); done1(1); """ time.sleep(1) try: cmd = """ var done = arguments[0]; (window.foo=function foo(){ if (window.maxBetTriger == false){ return done(window.maxBetData);}; delay = 1000; setTimeout(foo, delay);})(); """ done = l.execute_async_script(cmd) time.sleep(1) pa = Parser() rez, fsource, fmatch = pa.pars(done) previous = matchNum current = rez previous = sum([ int(previous[key]) for key in previous if previous[key] != "" ]) current = sum( [int(current[key]) for key in current if current[key] != ""]) rezik = get_change(current, previous) if previous > 8 and int(rezik) >= 20: pass else: time_current = datetime.datetime.fromtimestamp(time.time()) time_old = time_current red.set("maxbet", json.dumps(fsource)) red.set("maxbetList", json.dumps(fmatch)) cmd = """ var done1 = arguments[0]; window.maxBetData=[]; window.maxBetTriger = true; setTimeout( function() { try { $(".category-sportList-main[title=" + window.maxBetName + "] div").click(); } catch (err) { }; try { $(".category-sportList-main[title=" + window.maxBetName2 + "] div").click(); } catch (err) { }; try { $(".category-sportList-main[title=" + window.maxBetName3 + "] div").click(); } catch (err) { }; } , 400); done1(1); """ # done1 = l.execute_script(cmd) done1 = l.execute_async_script(cmd) time.sleep(1) except: l.exit() l.close() l.exit() l.close()
except ModuleNotFoundError: SettingsGUI.invoke_settings_window() import settings if not settings.login or not settings.password: raise ExceptionHandlers.SettingsEmptyError elif len(sys.argv) > 2: raise ExceptionHandlers.TooManyDirectories elif len(sys.argv) == 1: path = easygui.diropenbox() if path == None: raise ExceptionHandlers.NoDirectoryProvided else: path = sys.argv[1] if __name__ == '__main__': try: folder_name = os.path.basename(os.path.dirname(path)) folder_name = folder_name.replace("\'", "") folder_name = folder_name.replace("\"", "") fileConfig('logging_config.ini', defaults={'logfilename': "logs/{}.log".format(folder_name)}) log = logging.getLogger() Parser.main(path, log) except Exception: import traceback log.debug(traceback.format_exc()) print("Something gone wrong! Check {}.log file for more information.". format(folder_name)) print("Press Enter to continue ...") input()
class ParserTestCase(unittest.TestCase): """ Feature (end-to-end) tests for the SMILES parser. A SMILES string is given as input and the received molecule is tested to ensure it has been created correctly. """ def setUp(self): self.parser = Parser() def tearDown(self): self.parser = Parser() def test_organic_creation(self): self.m = self.parser.parse_smiles('CN') first = self.m.vertex_from_position(0) second = self.m.vertex_from_position(1) self.assertEqual(first.label, 'C') self.assertEqual(second.label, 'N') self.assertTrue(self.m.adjacency_dictionary[first][second].single) def test_square_attributes(self): self.m = self.parser.parse_smiles('[12C@H2--][N@@H+3]') first = self.m.vertex_from_position(0) second = self.m.vertex_from_position(1) self.assertEqual(first.label, 'C') self.assertEqual(first.isotope, '12') self.assertEqual(first.hydrogen, '2') self.assertEqual(first.charge, '-2') self.assertEqual(second.label, 'N') self.assertEqual(second.hydrogen, '1') self.assertEqual(second.charge, '+3') self.assertTrue(self.m.adjacency_dictionary[first][second].single) def test_aromatic_bonds(self): self.m = self.parser.parse_smiles('ccN') first = self.m.vertex_from_position(0) second = self.m.vertex_from_position(1) third = self.m.vertex_from_position(2) self.assertTrue(first.aromatic) self.assertTrue(second.aromatic) first_bond = self.m.get_edge_if_exists(first, second) self.assertTrue(first_bond.aromatic) second_bond = self.m.get_edge_if_exists(second, third) self.assertTrue(second_bond.single) def test_ring_bond(self): self.m = self.parser.parse_smiles('C1CCC1') first = self.m.vertex_from_position(0) last = self.m.vertex_from_position(3) self.assertTrue(self.m.get_edge_if_exists(first, last)) self.assertTrue(self.m.adjacency_dictionary[first][last].single) def test_branch(self): self.m = self.parser.parse_smiles('C(OC)C') first = self.m.vertex_from_position(0) root = self.m.vertex_from_position(1) branch_end = self.m.vertex_from_position(2) last = self.m.vertex_from_position(3) self.assertTrue(self.m.get_edge_if_exists(first, root)) self.assertTrue(self.m.get_edge_if_exists(first, last)) self.assertTrue(self.m.get_edge_if_exists(root, branch_end)) self.assertFalse(self.m.get_edge_if_exists(branch_end, last)) def test_bond(self): self.m = self.parser.parse_smiles('C-C=C#C$C:C') first = self.m.vertex_from_position(0) second = self.m.vertex_from_position(1) third = self.m.vertex_from_position(2) fourth = self.m.vertex_from_position(3) fifth = self.m.vertex_from_position(4) sixth = self.m.vertex_from_position(5) self.assertTrue(self.m.get_edge_if_exists(first, second).single) self.assertTrue(self.m.get_edge_if_exists(second, third).double) self.assertTrue(self.m.get_edge_if_exists(third, fourth).triple) self.assertTrue(self.m.get_edge_if_exists(fourth, fifth).quadruple) self.assertTrue(self.m.get_edge_if_exists(fifth, sixth).aromatic) def test_dot(self): self.m = self.parser.parse_smiles('C.N') self.c = self.m.vertex_from_position(0) self.n = self.m.vertex_from_position(1) self.assertFalse(self.m.get_edge_if_exists(self.c, self.n))
def tearDown(self): self.parser = Parser()
def setUp(self): self.parser = Parser()
for parser in parsers: if parser.state != Parser.Parser.STATE_HALT: return False return True if __name__ == '__main__': with open('data/data.txt') as data: code = [int(x) for x in data.readline().split(',')] max = 0 perm = [] for permutation in permutations(range(5, 10)): # print(permutation) codeCopy = code[:] parserA = Parser.Parser(code[:]) parserB = Parser.Parser(code[:]) parserC = Parser.Parser(code[:]) parserD = Parser.Parser(code[:]) parserE = Parser.Parser(code[:]) parsers = (parserA, parserB, parserC, parserD, parserE) for index, parser in enumerate(parsers): parser.inputs.append(permutation[index]) nextAmplifierValue = 0 parserIndex = 0 while not allParserHalted(parsers): parser = parsers[parserIndex % 5] # print(f'Using parser: {parserIndex % 5}') end = parser.run()