def analyze(self, sentence): current_sentence = sentence.Get("analysis") for sentence in current_sentence: if not sentence: continue if not sentence[0]: continue if not sentence[1]: continue ## per sentence instances hg = HG(sentence) word_set = self.each_word(sentence) if not word_set: return features = self.relex.parse_features(sentence) frames = self.relex.parse_frames(sentence) ## this will be for analysis if False: self.dump_to_file((features, frames)) if not self.options: hg.features_in(features) else: if self.options.graph_tags: hg.features_in(features) if self.options: if self.options.graph_frame: hg.frames_in(frames) RE = rule_engine(features, hg.get_hypergraph()) RE.run_rules() if self.options: if self.options.graph: hg.analysis()
def main(self): semantics = Semantics() logParser = irc_logParser() log_data = logParser.loadLogs("logs/2009-08-1*", limit=200) for sentences in log_data: rule_eng = rule_engine() if not sentences: continue if self.options.relex: r = relex.relex() sentence = r.process(sentences) for x in sentence: y = x.split("\n") for z in y: if z: print z if self.options.default: from tagger import braubt_tagger analogy = analysis.Analogies() s = linkGrammar.sentence(sentences) if s: normal_words = sentences.split(" ") container = sentence(s, normal_words) container.atom = semantics.semanticsToAtoms(container) test_rules(container) for a in container.diagram: debug(a) analogy.similar(container)
def main(self): semantics = Semantics() logParser = irc_logParser() log_data = logParser.loadLogs('logs/2009-08-1*', limit=200) for sentences in log_data: rule_eng = rule_engine() if not sentences: continue if self.options.relex: r = relex.relex() sentence = r.process(sentences) for x in sentence: y = x.split('\n') for z in y: if z: print z if self.options.default: from tagger import braubt_tagger analogy = analysis.Analogies() s = linkGrammar.sentence(sentences) if s: normal_words = sentences.split(' ') container = sentence(s, normal_words) container.atom = semantics.semanticsToAtoms(container) test_rules(container) for a in container.diagram: debug(a) analogy.similar(container)
def transformation_1(project, dataset, table_prefix): sql = rule_engine(1) table_name = "end_temp" output = create_table_name(project, dataset, table_prefix, table_name) run_query(bigquery, sql, output)
def run(self, available_components, system_input, controller_name): system_valves = self.intf.get_system_valves() system_pipes = self.intf.get_system_pipes() system_pumps = self.intf.get_system_pumps() system_sensors = self.intf.get_system_sensors() system_busbars = self.intf.build_busbars(system_pipes) system_connected_devices = self.intf.get_connected_devices() system_components = { **system_sensors, **system_busbars, **system_connected_devices, **system_valves, **system_pumps } unique_nodes = {} config = configparser.ConfigParser() config.read( "/home/federico/Desktop/SwitchBoard/SwitchBoard/src/config_controller.txt" ) #self.shut_the_pumps_up(available_components["Pumps_active"], self.comms) pumps_of_circuit = [ pump.ID for pump in available_components["Pumps_active"] ] # try: valves_of_circuit = self.components_name_translator( [valve.ID for valve in available_components["Valves_active"]]) #print(valves_of_circuit) engine = rule_engine() ideal_components = engine.run(system_input, available_components) act_circulator = self.pump_selector( ideal_components["Ideal_Pump"], available_components["Pumps_active"]) #print(act_circulator) actuators = self.actuator_selector( ideal_components["Ideal_Actuator"], available_components["Valves_active"], available_components["Pumps_active"]) #print(actuators) feedback_sensors = self.sensor_selector( ideal_components["Ideal_Sensor"], available_components["Sensors_active"], system_input["parameters"]) #print(feedback_sensors) act_circulator["pumps"] = self.components_name_translator( act_circulator["pumps"]) pumps_of_circuit = self.components_name_translator(pumps_of_circuit) #print(act_circulator) feedback_sensors["sensors"] = self.components_name_translator( feedback_sensors["sensors"]) #print(feedback_sensors) actuators["actuators"] = self.components_name_translator( actuators["actuators"]) actuators["secondary_actuators"] = self.components_name_translator( actuators["secondary_actuators"]) #print(actuators) controller_mode = act_circulator["mode"] # self.controller_name = act_circulator["mode"] input_for_controller = { "controller_name": controller_name, _DESCRIPTION: _CREATOR, "gain": config.get(controller_mode, "gain"), "kp": config.get(controller_mode, "kp"), "ki": config.get(controller_mode, "ki"), "kd": config.get(controller_mode, "kd"), "ki_valve": config.get(controller_mode, "ki_valve"), "pumps_of_circuit": pumps_of_circuit, "circulator": act_circulator["pumps"], "circulator_mode": act_circulator["mode"], "actuator": actuators["actuators"], "setpoint": system_input['setpoints'], "feedback_sensor": feedback_sensors["sensors"], "valves": valves_of_circuit, "secondary_actuators": actuators["secondary_actuators"] } print(input_for_controller) #except Exception: #print("There is a failure in calculate the components to be used") #return _CONTROLLER_DEACTIVED #return _CONTROLLER_DEACTIVED try: feedback = self.comms.send(input_for_controller) print("Message Sent") print("Feedback: ", feedback) return _CONTROLLER_ACTIVATED except Exception: print("Message sending failed") return _CONTROLLER_DEACTIVED
def main(f): #f = open('../packets/tcp.txt','r') while (True): f.readline() f.readline() s = f.readline() s = s[6:len(s) - 2].split("|") #print("Is coming in: ", end='') #print(isIncoming(['f8','34','41','21','87','7a'],s[6:12])) MACaddress = s[6] + ":" + s[7] + ":" + s[8] + ":" + s[9] + ":" + s[ 10] + ":" + s[11] if (s[23] == "06"): packet = tcp_packet(MACaddress,\ getIpAddress(s[26:30]), \ getIpAddress(s[30:34]),\ getPort(s[34:36]), \ getPort(s[36:38]) ) if (s[23] == "11"): packet = udp_packet(MACaddress,\ getIpAddress(s[26:30]), \ getIpAddress(s[30:34]),\ getPort(s[34:36]), \ getPort(s[36:38]) ) print(packet.String()) f.readline() r = rule_engine() #Check if the src of the packet is my device #Then the packet is travelling outside my network isSuccess = False if (isSrc(['f8', '34', '41', '21', '87', '7a'], s[6:12])): print("packet going out of our server..") print("source ip:{} and port:{} will {}".format(packet.getSrcIP(),\ packet.getSrcPort(),\ r.checkOutboundRules(packet.getSrcIP(), packet.getSrcPort()))) print("Destination ip:{} and port:{} will {}".format(packet.getDstIP(),\ packet.getDstPort(),\ r.checkOutboundRules(packet.getDstIP(), packet.getDstPort()))) isSuccess = r.checkOutboundRules(packet.getSrcIP(), packet.getSrcPort()) == 'Accept' and \ r.checkOutboundRules(packet.getDstIP(), packet.getDstPort()) == 'Accept' else: print("packet comes to our server..") print("source ip:{} and port:{} will {}".format(packet.getSrcIP(),\ packet.getSrcPort(),\ r.checkInboundRules(packet.getSrcIP(), packet.getSrcPort()))) print("Destination ip:{} and port:{} will {}".format(packet.getDstIP(),\ packet.getDstPort(),\ r.checkInboundRules(packet.getDstIP(), packet.getDstPort()))) isSuccess = r.checkInboundRules(packet.getSrcIP(), packet.getSrcPort()) == 'Accept' and \ r.checkInboundRules(packet.getDstIP(), packet.getDstPort()) == 'Accept' if (isSuccess): print("Packet transmission successfull") else: print("Packet transmission unsuccessfull!!! Packet Dropped") print("\n\n")