Untitled
unknown
plain_text
7 months ago
1.1 kB
0
Indexable
Never
def run(input_file): if not os.path.exists(OUTPUT_DIR): os.mkdir(OUTPUT_DIR) try: if not os.path.exists(INPUT_DIR + input_file): raise FileNotFoundError except FileNotFoundError: print("FILE IS NOT FOUND !") exit(0) file = open(INPUT_DIR + '/' + input_file, 'r') KB = knowledgebase() alpha = file.readline() numClauses = file.readline() clauses = file.readlines() KB.buildKB(alpha, clauses) file.close() entail, newClauses = KB.PL_Resolution() des = os.path.join(OUTPUT_DIR, input_file.replace('input', 'output')) file = open(des, 'w') for clauses in newClauses: file.write('{}\n'.format(len(clauses))) for clause in clauses: file.write('{}\n'.format(clause)) if entail == True: file.write('YES') else: file.write('NO') file.close() if __name__ == '__main__': if len(sys.argv) < 2: raise Exception("Wrong input!!!") input = str(sys.argv[1]) run(input)