Book Image

Artificial Intelligence with Python

Book Image

Artificial Intelligence with Python

Overview of this book

Artificial Intelligence is becoming increasingly relevant in the modern world. By harnessing the power of algorithms, you can create apps which intelligently interact with the world around you, building intelligent recommender systems, automatic speech recognition systems and more. Starting with AI basics you'll move on to learn how to develop building blocks using data mining techniques. Discover how to make informed decisions about which algorithms to use, and how to apply them to real-world scenarios. This practical book covers a range of topics including predictive analytics and deep learning.
Table of Contents (23 chapters)
Artificial Intelligence with Python
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Parsing a family tree


Now that we are more familiar with logic programming, let's use it to solve an interesting problem. Consider the following family tree:

John and Megan have three sons - William, David, and Adam. The wives of William, David, and Adam are Emma, Olivia, and Lily respectively. William and Emma have two children - Chris and Stephanie. David and Olivia have five children - Wayne, Tiffany, Julie, Neil, and Peter. Adam and Lily have one child - Sophia. Based on these facts, we can create a program that can tell us the name of Wayne's grandfather or  Sophia's uncles are. Even though we have not explicitly specified anything about the grandparent or uncle relationships, logic programming can infer them.

These relationships are specified in a file called relationships.json provided for you. The file looks like the following:

{ 
      "father":  
      [ 
            {"John": "William"}, 
            {"John": "David"}, 
            {"John": "Adam"}, 
            {"William": "Chris...