# -----------------------------
# LEGAL EXPERT SYSTEM
# -----------------------------
# KNOWLEDGE BASE
knowledge_base = {
"facts": [
"fir",
"bail",
"ipc",
"rti",
"cyber crime",
"consumer court"
],
"rules": {
"fir": "FIR stands for First Information Report. It is filed when police receive information about a cognizable offence.",
"bail": "Bail is the temporary release of an accused person awaiting trial, sometimes with conditions imposed by the court.",
"ipc": "IPC stands for Indian Penal Code. It defines criminal offences and punishments in India.",
"rti": "RTI stands for Right to Information. It empowers citizens to request information from public authorities.",
"cyber crime": "Cyber crime involves illegal activities conducted using computers or the internet such as hacking, identity theft, or fraud.",
"consumer court": "Consumer Court handles cases related to consumer complaints against unfair trade practices or defective goods/services."
}
}
# INFERENCE ENGINE (Forward Chaining)
def inference_engine(user_input):
user_input = user_input.lower()
for fact in knowledge_base["facts"]:
if fact in user_input:
return knowledge_base["rules"][fact]
return "Sorry, I do not have knowledge about that legal issue."
# USER INTERFACE
print("⚖ Welcome to Legal Expert System")
print("Type 'exit' to quit\n")
while True:
user_input = input("You: ")
if user_input.lower() == "exit":
print("Expert System: Stay informed about your legal rights. Goodbye!")
break
response = inference_engine(user_input)
print("Expert System:", response)