Description
Sehban Fazili
M Tech CSE: MT21143
NL interface for your electives advisory system.
Steps:
1) Downloading swi-prolog and pyswip in Google Colaboratory using the commands:
!apt install swi-prolog
!pip install pyswip
2) Importing important libraries import nltk nltk.download(‘punkt’) from nltk.tokenize import word_tokenize from nltk.stem import PorterStemmer from pyswip import Prolog
3) Input txt file is generated using the code below:
def output(var):
if var == “MachineLearning&ArtificialIntelligence”:
print(‘AI,ML,DMG,SML,GradAlgo’)
if var == “GraphicDesigning”: print(‘ComputerArchitecture,ComputerGraphics,GradAlgo’)
if var == “InformationSecurity”:
print(‘EthicalHacking,ProgramAnalysis,GradAlgo’)
if var == “Networking”:
print(‘MobileComputing,EmbeddedSystems,Mobileandcellularnetworksecurity,GradAlgo’) else:
print(“We recommend you to explore more about your interests and come back
again.”) ps = PorterStemmer() f = open(“/content/nlinterface.txt”, ‘w’)
inplist = [] inp1 = input(‘Enter branch: ‘) tok1 = word_tokenize(inp1) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “cse” in inplist:
f.write(“branch(cse). “)
inplist = [] inp2 = input(‘Enter CGPA: ‘) tok1 = word_tokenize(inp2) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “9” in inplist:
f.write(“cgpa(9.0). “)
elif “8” in inplist:
f.write(“cgpa(8.0). “)
elif “7” in inplist:
f.write(“cgpa(7.0). “)
elif “6” in inplist:
f.write(“cgpa(6.0). “)
elif “6.5” in inplist:
f.write(“cgpa(6.5). “)
else:
f.write(“cgpa(7.5). “)
inplist = [] inp3 = input(‘Do you have a strong grasp of mathematics and statistics?’) tok1 = word_tokenize(inp3) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“maths(y). “)
inplist = []
inp4 = input(“Do you like programming? “) tok1 = word_tokenize(inp4) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“programming(y). “)
inplist = [] inp5 = input(‘Are you considering a career in ML?’) tok1 = word_tokenize(inp5) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“machine_learning(y). “)
inplist = [] inp6 = input(‘Are you considering a career in AI?’) tok1 = word_tokenize(inp6) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“artificial_intelligence(y). “)
inplist = [] inp7 = input(‘Are you considering a career in Data Mining?’) tok1 = word_tokenize(inp7) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“data_mining(y). “)
inplist = [] inp8 = input(‘Are you considering a career in Networking?’) tok1 = word_tokenize(inp8) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“networking(y). “)
inplist = [] inp9 = input(‘Are you considering a career in Graphic Designing?’) tok1 = word_tokenize(inp9) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“graphic_designing(y). “)
inplist = [] inp10 = input(‘Are you considering a career in Information Security?’) tok1 = word_tokenize(inp10) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“information_security(y). “)
inplist = [] inp11 = input(‘Are you considering to study further?’) tok1 = word_tokenize(inp) for wod in tok1:
stem1 = ps.stem(wod) inplist.append(stem1) if “y” in inplist:
f.write(“higher_studies(y). “)
f.close()
4) Output is generated using the command given below:
swipl = Prolog() swipl.consult(“/content/electiveAdvisory.pl”) electives_suggested = list(swipl.query(“generate_electives(Electives)”)) for i in range(len(electives_suggested)):
var = electives_suggested[i][‘Electives’].decode(‘utf-8’) output(var) 5) Outputs:
Reviews
There are no reviews yet.