print("feed tunid " + feed_tunid + " is " + feed_sympy) feed_array.append(feed_sympy) symbol_punid_array = physgraf.convert_tpunid_to_symbol_punid_array( feed_tunid, feedsDB, 'feed') for indx in range(len(symbol_punid_array)): cas_sympy = physgraf.convert_symbol_punid_to_cas_sympy( symbol_punid_array[indx], symbolsDB) symbols_array.append(cas_sympy + " # from feed") else: print("feed label " + feed_tunid + " is missing CAS expansion") check_this_connection = False print(feed_array) return check_this_connection, feed_array, symbols_array inference_rulesDB = physgraf.parse_XML_file(db_path + '/inference_rules_database.xml') connectionsDB = physgraf.parse_XML_file(db_path + '/connections_database.xml') statementsDB = physgraf.parse_XML_file(db_path + '/statements_database.xml') feedsDB = physgraf.parse_XML_file(db_path + '/feed_database.xml') symbolsDB = physgraf.parse_XML_file(db_path + '/symbols_database.xml') counter_array = [] counter_array.append(0) # number_of_rules_not_checkable=0 counter_array.append(0) # number_of_checkable_rules_not_checked=0 counter_array.append(0) # number_of_tested_true_connections=0 counter_array.append(0) # number_of_tested_false_connections=0 counter_array.append(0) # number_of_connection_setups_with_error=0 for this_connection in connectionsDB.getElementsByTagName('connection'): check_this_connection = True #this_connection=physgraf.remove_tags(this_connection.toxml(encoding="ascii"),'connection')
# input: # output: # current bugs: import sys import os lib_path = os.path.abspath('lib') sys.path.append(lib_path) # this has to proceed use of physgraph db_path = os.path.abspath('databases') sys.path.append(lib_path) # this has to proceed use of physgraph import lib_physics_graph as physgraf from xml.dom.minidom import parseString connectionsDB = physgraf.parse_XML_file(db_path + '/connections_database.xml') statementsDB = physgraf.parse_XML_file(db_path + '/statements_database.xml') statement_punid_ary = [] for these_statements in connectionsDB.getElementsByTagName('statement_punid'): statement_punid = physgraf.remove_tags( these_statements.toxml(encoding="ascii"), 'statement_punid') statement_punid_ary.append(statement_punid) #http://stackoverflow.com/questions/2870466/python-histogram-one-liner hist = {} for x in statement_punid_ary: hist[x] = hist.pop(x, 0) + 1 # x=statement_punid #http://stackoverflow.com/questions/613183/python-sort-a-dictionary-by-value for w in sorted(hist, key=hist.get, reverse=True): # w=statement_punid
# use: python sandbox/list_connection_sets.py # input: # output: # current bugs: import sys import os lib_path = os.path.abspath('lib') sys.path.append(lib_path) # this has to proceed use of physgraph db_path = os.path.abspath('databases') sys.path.append(lib_path) # this has to proceed use of physgraph import lib_physics_graph as physgraf from xml.dom.minidom import parseString statementsDB=physgraf.parse_XML_file(db_path+'/statements_database.xml') symbolsDB=physgraf.parse_XML_file(db_path+'/symbols_database.xml') symbol_punid_ary=[] for these_symbols in statementsDB.getElementsByTagName('symbol_punid'): symbol_punid=physgraf.remove_tags(these_symbols.toxml(encoding="ascii"),'symbol_punid') symbol_punid_ary.append(symbol_punid) #http://stackoverflow.com/questions/2870466/python-histogram-one-liner hist = {} for x in symbol_punid_ary: hist[x] = hist.pop(x,0) + 1 # x=symbol_punid #http://stackoverflow.com/questions/613183/python-sort-a-dictionary-by-value for w in sorted(hist, key=hist.get, reverse=True): # w=symbol_punid name=physgraf.convert_symbol_punid_to_name(w,symbolsDB) print (str(hist[w])+" "+w+" "+name)
#!/opt/local/bin/python # Physics Equation Graph # Ben Payne <*****@*****.**> # # use: python sandbox/list_connection_sets.py # input: # output: # current bugs: import sys import os lib_path = os.path.abspath('lib') sys.path.append(lib_path) # this has to proceed use of physgraph db_path = os.path.abspath('databases') sys.path.append(lib_path) # this has to proceed use of physgraph import lib_physics_graph as physgraf from xml.dom.minidom import parseString inference_rulesDB=physgraf.parse_XML_file(db_path+'/inference_rules_database.xml') for these_rules in inference_rulesDB.getElementsByTagName('infrule_name'): print(physgraf.remove_tags(these_rules.toxml(),'infrule_name')) sys.exit("done")
import lib_physics_graph as physgraf # http://stackoverflow.com/questions/6665725/parsing-xml-using-minidom from xml.dom.minidom import parseString # xml parser called minidom: input_stream = file('config.input', 'r') input_data = yaml.load(input_stream) extension = input_data["file_extension_string"] redraw_feed_pictures_boolean = input_data["redraw_feed_pictures_boolean"] redraw_statement_pictures_boolean = input_data[ "redraw_statement_pictures_boolean"] statement_pictures = lib_path + '/images_eq_' + extension feed_pictures = lib_path + '/images_feed_' + extension statementsDB = physgraf.parse_XML_file(db_path + '/statements_database.xml') statementPicsDrawnCount = 0 statementCount = 0 for item in statementsDB.getElementsByTagName('statement'): statementCount = statementCount + 1 statement_indx = physgraf.convert_tag_to_content(item, 'statement_punid', 0) statement_latex = physgraf.convert_tag_to_content(item, 'statement_latex', 0) statement_latex_math = '\\begin{equation*}\n' + statement_latex + '\\end{equation*}\n' # http://stackoverflow.com/questions/82831/how-do-i-check-if-a-file-exists-using-python if ((redraw_statement_pictures_boolean) or ((not redraw_statement_pictures_boolean) and not (os.path.isfile(statement_pictures + '/' + statement_indx + '.' + extension)))): # if file does not exist, redraw physgraf.make_picture_from_latex(statement_indx, statement_pictures,