وبلاگ بلیان

Ontologies with Python: Programming OWL 2. 0 Ontologies with Python and Owlready 2

جلد کتاب Ontologies with Python: Programming OWL 2. 0 Ontologies with Python and Owlready 2

معرفی کتاب «Ontologies with Python: Programming OWL 2. 0 Ontologies with Python and Owlready 2» نوشتهٔ Jean-Baptiste, Lamy، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2021. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

Use ontologies in Python, with the Owlready2 module developed for ontology-oriented programming. You will start with an introduction and refresher on Python and OWL ontologies. Then, you will dive straight into how to access, create, and modify ontologies in Python. Next, you will move on to an overview of semantic constructs and class properties followed by how to perform automatic reasoning. You will also learn about annotations, multilingual texts, and how to add Python methods to OWL classes and ontologies. Using medical terminologies as well as direct access to RDF triples is also covered. Python is one of the most used programming languages, especially in the biomedical field, and formal ontologies are also widely used. However, there are limited resources for the use of ontologies in Python. Owlready2, downloaded more than 60,000 times, is a response to this problem, and this book is the first one on the topic of using ontologies with Python. What You Will Learn • Use Owlready2 to access and modify OWL ontologies in Python • Publish ontologies on dynamic websites • Perform automatic reasoning in Python • Use well-known ontologies, including DBpedia and Gene Ontology, and terminological resources, such as UMLS (Unified Medical Language System) • Integrate Python methods in OWL ontologies Who Is This Book For Beginner to experienced readers from biomedical sciences and artificial intelligence fields would find the book useful. Table of Contents 4 About the Author 13 About the Technical Reviewers 14 Acknowledgments 15 Chapter 1: Introduction 16 1.1 Who is this book for? 17 1.2 Why ontologies? 17 1.3 Why Python? 19 1.4 Why Owlready? 20 1.5 Book outline 22 1.6 Summary 23 Chapter 2: The Python language: Adopt a snake! 24 2.1 Installing Python 25 2.2 Starting Python 25 2.3 Syntax 28 2.3.1 Comments 28 2.3.2 Writing on screen 29 2.3.3 Help 29 2.3.4 Variables 29 2.3.5 Indentation 30 2.4 Main datatypes 31 2.4.1 Integer (int) and floating-point numbers (float) 31 2.4.2 Booleans (bool) 33 2.4.3 Character strings (str) 33 2.4.4 Lists (list) 36 2.4.5 Tuples (tuple) 37 2.4.6 Dictionaries (dict and defaultdict) 38 2.4.7 Sets (set) 41 2.4.8 Files (open) 41 2.4.9 Conversion between datatypes 42 2.5 Conditions (if) 43 2.6 Loops (for) 45 2.7 Generators 49 2.8 Functions (def) 49 2.9 Classes (class) 51 2.9.1 Classes and instances 51 2.9.2 Inheritance 54 2.9.3 Special method names 56 2.9.4 Functions and operators for object-oriented programming 57 2.10 Python modules 59 2.10.1 Importing a module 59 2.10.2 Installing additional modules 60 2.11 Installing Owlready2 60 2.11.1 Installing Owlready2 from terminal 61 2.11.2 Installing Owlready2 from IDLE or Spyder (or any Python shell) 61 2.11.3 Manual installation of Owlready2 62 2.12 Summary 63 Chapter 3: OWL ontologies 64 3.1 An ontology... what does it look like? 65 3.2 Creating ontologies manually with the Protégé editor 67 3.3 Example: An ontology of bacteria 68 3.4 Creating a new ontology 71 3.4.1 Classes 73 3.4.2 Disjoints 73 3.4.3 Partitions 76 3.4.4 Data properties 77 3.4.5 Object properties 79 3.4.6 Restrictions 82 3.4.7 Union, intersection, and complement 86 3.4.8 Definitions (equivalent-to relations) 87 3.4.9 Individuals 89 3.4.10 Other constructs 91 3.5 Automatic reasoning 92 3.6 Modeling exercises 95 3.7 Summary 97 Chapter 4: Accessing ontologies in Python 98 4.1 Importing Owlready 98 4.2 Loading an ontology 98 4.3 Imported ontologies 101 4.4 Listing the content of the ontology 101 4.5 Accessing entities 103 4.5.1 Individuals 104 4.5.2 Relations 105 4.5.3 Classes 109 4.5.4 Existential restrictions 111 4.5.5 Properties 111 4.6 Searching for entities 113 4.7 Huge ontologies and disk cache 116 4.8 Namespaces 117 4.9 Modifying entity rendering as text 118 4.10 Local directory of ontologies 120 4.11 Reloading an ontology in the quadstore 121 4.12 Example: creating a dynamic website from an ontology 122 4.13 Summary 127 Chapter 5: Creating and modifying ontologies in Python 128 5.1 Creating an empty ontology 128 5.2 Creating classes 129 5.2.1 Creating classes dynamically 131 5.3 Creating properties 132 5.4 Creating individuals 133 5.5 Modifying entities: relations and existential restrictions 135 5.6 Creating entities within a namespace 136 5.7 Renaming entities (refactoring) 137 5.8 Multiple definitions and forward declarations 138 5.9 Destroying entities 139 5.10 Destroying an ontology 139 5.11 Saving an ontology 139 5.12 Importing ontologies 140 5.13 Synchronization 140 5.14 Example: populating an ontology from a CSV file 141 5.14.1 Populating with individuals 142 5.14.2 Populating with classes 145 5.15 Summary 148 Chapter 6: Constructs, restrictions, and class properties 149 6.1 Creating constructs 149 6.2 Accessing construct parameters 152 6.3 Restrictions as class properties 154 6.4 Defined classes 160 6.5 Example: creating the ontology of bacteria in Python 161 6.6 Example: populating an ontology with defined classes 164 6.6.1 Populating using class properties 165 6.6.2 Populating using constructs 167 6.7 Summary 170 Chapter 7: Automatic reasoning 171 7.1 Disjoints 171 7.2 Reasoning with the Open-World assumption 172 7.3 Reasoning in a closed world or in a local closed world 174 7.4 Inconsistent classes and inconsistent ontologies 177 7.5 Restriction and reasoning on numbers and strings 179 7.6 SWRL rules 183 7.6.1 SWRL syntax 184 7.6.2 SWRL rules with Protégé 187 7.6.3 SWRL rules with Owlready 188 7.6.4 Advantages and limits of SWRL rules 192 7.7 Example: an ontology-based decision support system 193 7.8 Summary 199 Chapter 8: Annotations, multilingual texts, and full-text search 200 8.1 Annotating entities 200 8.2 Multilingual texts 202 8.3 Annotating constructs 203 8.4 Annotating properties and relations 203 8.5 Creating new annotation classes 204 8.6 Ontology metadata 204 8.7 Full-text search 205 8.8 Example: Using DBpedia in Python 207 8.8.1 Loading DBpedia 208 8.8.2 A search engine for DBpedia 215 8.9 Summary 218 Chapter 9: Using medical terminologies with PyMedTermino and UMLS 219 9.1 UMLS 219 9.2 Importing terminologies from UMLS 220 9.3 Loading terminologies after initial importation 222 9.4 Using ICD10 222 9.5 Using SNOMED CT 229 9.6 Using UMLS unified concepts (CUI) 234 9.7 Mapping between terminologies 235 9.8 Manipulating sets of concepts 237 9.9 Importing all terminologies in UMLS 242 9.10 Example: Linking the ontology of bacteria with UMLS 243 9.11 Example: A multi-terminology browser 245 9.12 Summary 251 Chapter 10: Mixing Python and OWL 252 10.1 Adding Python methods to OWL classes 252 10.2 Associating a Python module to an ontology 254 10.2.1 Manual import 255 10.2.2 Automatic import 256 10.3 Polymorphism with type inference 257 10.4 Introspection 258 10.5 Reading restrictions backward 261 10.6 Example: Using Gene Ontology and managing “part-of” relations 262 10.7 Example: A “dating site” for proteins 266 10.8 Summary 275 Chapter 11: Working with RDF triples and worlds 276 11.1 RDF triples 276 11.2 Manipulating RDF triples with RDFlib 278 11.2.1 Reading RDF triples 278 11.2.2 Creating new RDF triples with RDFlib 280 11.2.3 Removing RDF triples with RDFlib 282 11.3 Performing SPARQL requests 282 11.3.1 Searching with SPARQL 283 11.3.2 SPARQL prefixes 285 11.3.3 Creating RDF triples with SPARQL 286 11.3.4 Removing RDF triples with SPARQL 287 11.4 Accessing RDF triples with Owlready 288 11.5 Interrogating the SQLite3 database directly 294 11.6 Adding support for custom datatypes 296 11.7 Creating several isolated worlds 298 11.8 Summary 300 Appendix A: Description logics 301 Appendix B: Notations for formal ontologies 305 Appendix C: Reference manual 312 C.1 World class 312 C.2 Ontology class 316 C.3 Classes (ThingClass class) 320 C.4 Individuals (Thing class) 324 C.5 Properties (PropertyClass class and its descendants) 326 C.6 Constructs (Contruct class and its descendants) 331 C.6.1 Restriction class 331 C.6.2 Intersection (And class) 332 C.6.3 Union (Or class) 332 C.6.4 Complement (Not class) 332 C.6.5 Property inverse (Inverse class) 332 C.6.6 Individual set (OneOf class) 332 C.7 SWRL rules 333 C.7.1 Variable class 333 C.7.2 Rules (Imp class) 333 C.7.3 Class assertion atom (ClassAtom class) 334 C.7.4 Datatype assertion atom (DataRangeAtom class) 335 C.7.5 Object property value atom (IndividualPropertyAtom class) 335 C.7.6 Data property value atom (DatavaluedPropertyAtom class) 336 C.7.7 Same individual atom (SameIndividualAtom class) 336 C.7.8 Distinct individual atom (DifferentIndividualAtom class) 337 C.7.9 Built-in function atom (BuiltinAtom class) 337 C.8 PyMedTermino2 338 C.8.1 Terminology class 338 C.8.2 Concept in a terminology 339 C.8.3 Set of concepts (Concepts class) 341 C.9 Global functions 345 Index 348 Front Matter ....Pages i-xvii Introduction (Lamy Jean-Baptiste)....Pages 1-8 The Python language: Adopt a snake! (Lamy Jean-Baptiste)....Pages 9-48 OWL ontologies (Lamy Jean-Baptiste)....Pages 49-82 Accessing ontologies in Python (Lamy Jean-Baptiste)....Pages 83-112 Creating and modifying ontologies in Python (Lamy Jean-Baptiste)....Pages 113-133 Constructs, restrictions, and class properties (Lamy Jean-Baptiste)....Pages 135-156 Automatic reasoning (Lamy Jean-Baptiste)....Pages 157-185 Annotations, multilingual texts, and full-text search (Lamy Jean-Baptiste)....Pages 187-205 Using medical terminologies with PyMedTermino and UMLS (Lamy Jean-Baptiste)....Pages 207-239 Mixing Python and OWL (Lamy Jean-Baptiste)....Pages 241-264 Working with RDF triples and worlds (Lamy Jean-Baptiste)....Pages 265-289 Back Matter ....Pages 291-344
دانلود کتاب Ontologies with Python: Programming OWL 2. 0 Ontologies with Python and Owlready 2