Académique Documents
Professionnel Documents
Culture Documents
Introduction:
On veut créer un system expert en utilisent le lunguge du
Prolog mais à travers un interface python, ce système concerne
les sites touristiques Algérien.
Analyse du problème:
Pour créer se system on est bosoin de:
-code un programme qui peut entrer les feuilles et les ragles dans
un ficher Prolog.
-et code le programme pour exécuter les régles et retire les
resultats.
Ce projet a été mis en œuvre en utilisant swipl v8.5, python
v3.10.3 et VS Code v1.67
Solutions techniques:
Dans ce cas, nous voulons remplir un fichier de byte ".pl"
avec des faits et des règles afin que nous utilisions la fonction
prédéfinie en python "write ()", nous demanderons à l'utilisateur
d'entrer les informations sur le wilaya (nom de l'état, son lieux
touristiques dans ...)
On utilisent la même fonction “write()” l'utilisateur il peut
remplir les règles manualmente (tout la regle), example l’image
en sous.
# f = open("prolog.pl", "a")
f = open("prolog.pl", "a")
clear = lambda: os.system('clear')
swipl = lambda: os.system('swipl -s prolog.pl')
def addState():
clear()
print("Name the states are located in Algeria ? ")
state=str(input())
clear()
# sea
print("Is there a sea in "+state+" state ?")
print("If yes click 1 in no click 0")
index=int(input())
if(index==1):
sea="sea"
if(index==0):
sea="no_sea"
clear()
# desert
print("Is there a desert in "+state+" state ?")
print("If yes click 1 in no click 0")
index=int(input())
if(index==1):
desert="desert"
if(index==0):
desert="no_desert"
clear()
# Historical
print("Is there a Historical places in "+state+" state ?")
print("If yes click 1 in no click 0")
index=int(input())
if(index==1):
Historical="historical"
if(index==0):
Historical="no_Historical"
clear()
f.write(" # begining of Facts of "+state+" state.\n")
f.write("in_state("+state+","+sea+","+desert+","+Historical+").\n")
# Parks
print("is there a Green park in " + state + " ? \nif yes ckick 1 if
no click 0")
index=int(input())
if(index==1):
GreenPark="greenPark"
if(index==0):
GreenPark="noGreenPark"
clear()
print("is there a Amusement park in " + state + " ? \nif yes ckick 1
if no click 0")
index=int(input())
if(index==1):
AmusementPark="amusement_park"
if(index==0):
AmusementPark="noAmusement_park"
clear()
f.write("park("+state+","+GreenPark+","+AmusementPark+","+Zoo+").\n")
#les places
print("is there a touristique place in " + state + " ? \nif yes
ckick 1 if no click 0")
index=int(input())
clear()
while (index==1):
print("Entre the name of the touristique place in : "+ state + "
:")
place=str(input())
f.write("place("+ place+ ","+ state+").\n")
clear()
print("do you want to add an other touristique place ?\nif yes
ckick 1 if no click 0")
index=int(input())
clear()
def addRules():
clear()
print("add rule : ")
ans=str(input())
f.write("\n" + ans+"% this's a rule"+"\n")
f.close()
def useQuery():
clear()
swipl()
clear()
x=1
while (x!=0):
clear()
print(" * EXPERT SYSTEM OF ALGERIA TOURIST BIOGRAPHIES * \n")
print("To add state click 1 and hit enter")
print("--------------------")
print("To add Rule click 2 and hit enter")
print("--------------------")
print("To use Queries click 3 and hit enter")
print("--------------------")
print("To exit click 0 and hit enter")
x=int(input())
if (x==1):
addState()
if (x==2):
addRules()
if (x==3):
useQuery()
clear()
Conclusion:
Références:
1. Prolog documentation. SWI. (n.d.). Retrieved May 24,
2022, from https://www.swi-prolog.org/pldoc/index.html
2. Python tutorial. (n.d.). Retrieved May 24, 2022, from
https://www.w3schools.com/python/