SIOC Post profile for "AI3:::Adaptive Information"
type: Document
description: A SIOC profile describes the structure and contents of a weblog in a machine readable form. For more information please refer to http://sioc-project.org/.
primary topic: CWPK #32: Iterating Over a Full Extraction
generator agent: http://rdfs.org/sioc/wp-sioc.php

CWPK #32: Iterating Over a Full Extraction
type: Post
has container: weblog
has creator: Mike Bergman
maker: Mike Bergman
created: 2020-09-09T14:38:17Z
content: It is Time to Explore Python Dictionaries and Packaging In our last coding installments in this Cooking with Python and KBpedia series, prior to our single-installment detour to learn about files, we developed extraction routines for both structure (rdfs:subClassOf) and annotations (of various properties) using the fantastic package owlready2. In practice, these generic routines will loop over populations of certain object types in KBpedia, such as typologies or property types. We want a way to feed these variations to the generic routines in an efficient and understandable way. Python lists are one way to do so, and we have begun to gain a bit of experience in our prior work with lists and sets. But there is another structure in Python called a 'dictionary' that sets up key-value pairs of 2-tuples that promises more flexibility and power. The 2-tuple sets up a relationship between an attribute name (a variable name) with a value, quite similar to the associative arrays in JSON. The values in a dictionary can be any object in Python, including functions or other dictionaries, the latter which allows 'record'-like data structures. However, there may not be duplicate names for keys within a given dictionary (but names may be used again in other dictionaries without global reference). Dictionaries ('dicts') are like Python lists except list elements are accessed by their position in the list using a numeric index, while we access dict elements via keys. This makes tracing the code easier. We have also indicated that dictionary structures may be forthcoming in other uses of KBpedia, such as CSV or master data. So, I decided to start gaining experience with 'dicts' in this installment. (Other apparent advantages of dictionaries not directly related to our immediate needs include: Dictionaries can be expanded without altering what is already there From Python 3.7 onward, the order entered into a dict is preserved in loops Dictionaries can handle extremely large data sets …
encoded: It is Time to Explore Python Dictionaries and Packaging In our last coding installments in this Cooking with Python and KBpedia series, prior to our single-installment detour to learn about files, we developed extraction routines for both structure (rdfs:subClassOf) and annotations (of various properties) using the fantastic package owlready2. In practice, these generic routines will loop over populations of certain object types in KBpedia, such as typologies or property types. We want a way to feed these variations to the generic routines in an efficient and understandable way. Python lists are one way to do so, and we have begun to gain a bit of experience in our prior work with lists and sets. But there is another structure in Python called a ‘dictionary’ that sets up key-value pairs of 2-tuples that promises more flexibility and power. The 2-tuple sets up a relationship between an attribute name (a variable name) with a value, quite similar to the associative arrays in JSON. The values in a dictionary can be any object in Python, including functions or other dictionaries, the latter which allows ‘record’-like data structures. However, there may not be duplicate names for keys within a given dictionary (but names may be used again in other dictionaries without global reference). Dictionaries ('dicts') are like Python lists except list elements are accessed by their position in the list using a numeric index, while we access dict elements via keys. This makes tracing the code easier. We have also indicated that dictionary structures may be forthcoming in other uses of KBpedia, such as CSV or master data. So, I decided to start gaining experience with 'dicts' in this installment. (Other apparent advantages of dictionaries not directly related to our immediate needs include: Dictionaries can be expanded without altering what is already there From Python 3.7 onward, the order entered into a dict is preserved in loops Dictionaries can handle extremely large data sets …
topic: CWPK
topic: KBpedia
topic: Semantic Web Tools
links to: Cooking with Python and KBpedia
links to: owlready2
links to: KBpedia
links to: Python
links to: key-value pairs
links to: tuples
links to: associative arrays
links to: JSON
links to: CSV
links to: master data
links to: hash table
links to: Pandas DataFrame
links to: cb1-1
links to: CWPK #28
links to: CWPK #29
links to: CWPK #30
links to: cb2-1
links to: cb2-2
links to: cb2-3
links to: cb2-4
links to: cb2-5
links to: cb2-6
links to: cb2-7
links to: cb2-8
links to: cb2-9
links to: cb2-10
links to: cb2-11
links to: cb2-12
links to: cb2-13
links to: cb2-14
links to: cb2-15
links to: cb2-16
links to: cb2-17
links to: cb2-18
links to: cb3-1
links to: cb3-2
links to: cb3-3
links to: cb3-4
links to: cb3-5
links to: cb4-1
links to: cb4-2
links to: cb4-3
links to: cb4-4
links to: cb4-5
links to: cb4-6
links to: cb4-7
links to: cb4-8
links to: cb4-9
links to: cb4-10
links to: cb4-11
links to: cb4-12
links to: cb4-13
links to: cb4-14
links to: cb4-15
links to: cb4-16
links to: cb4-17
links to: cb4-18
links to: cb4-19
links to: cb4-20
links to: cb4-21
links to: cb4-22
links to: cb4-23
links to: cb4-24
links to: cb4-25
links to: cb4-26
links to: cb4-27
links to: cb4-28
links to: cb4-29
links to: cb4-30

Mike Bergman
type: User

Mike Bergman
type: Person

Cooking with Python and KBpedia
label: CWPK listing

dict

dictionaries

Using Python dictionary as a database

how to interate dictionaries

KBpedia

direct download

notify me