-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
82 lines (64 loc) · 2.2 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Travaille TP1 AI
# Gastli Oussama
# Hanana Nour
# GL4
from expression import Expression
import unification as unif
from ChainageAvant import ChainageAvant
import copy
def CLI_app():
a=input("ecrire la 1ere expression a unifier: ")
b=input("ecrire la 2eme expression a unifier: ")
e1=Expression(a)
e2=Expression(b)
x=unif.unifier(e1,e2)
result=unif.beautifulResult(x)
print(result)
def FILE_app():
myFile=open("testExpression.txt","r")
lines = myFile.readlines()
for line in lines:
a=line.split(";")
s1,s2=a[0],a[1].strip('\n')
e1=Expression(s1)
e2=Expression(s2)
x=unif.unifier(e1,e2)
result=unif.beautifulResult(x)
print(s1)
print(s2)
print()
print(result)
print("-----------------------------------------------------")
def chainageAvant_app():
a=ChainageAvant()
oldBF=copy.deepcopy(a.BF)
a.chainage_avant()
newBF=a.newFaits
myFile=open("resultat.txt","w")
myFile.write("============anciens faits=====================\n")
for s in oldBF:
myFile.write(s+"\n")
myFile.write("============nouveaux faits====================\n")
for s in newBF:
myFile.write(s+"\n")
print("un fichier resultat.txt contenant les faits a été généré")
print("l'algorithme de chainage a déduit {} nouveaux faits".format(len(newBF)))
print("====FIN du programme====")
# main function
choice=-1
while(int(choice)<0 or int(choice)>3):
print("============================Menu============================")
print("=1- Unification a partir de la console =")
print("=2- unification a partir du fichier \"testExpression.txt\" =")
print("=3- Algorithme de chainage avant d'ordre 1 =")
print("= =")
print("= Binome: =")
print("= Gastli Oussama & Hanana Nour GL4 =")
print("============================================================")
choice = input()
if(choice=="1"):
CLI_app()
elif(choice=="2"):
FILE_app()
elif(choice=="3"):
chainageAvant_app()