{"id":14361,"date":"2022-02-14T10:00:14","date_gmt":"2022-02-14T15:00:14","guid":{"rendered":"https:\/\/enterprise-knowledge.com\/?p=14361"},"modified":"2025-09-05T10:47:01","modified_gmt":"2025-09-05T14:47:01","slug":"content-personalization-with-knowledge-graphs-in-python","status":"publish","type":"post","link":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/","title":{"rendered":"Content Personalization with Knowledge Graphs in Python"},"content":{"rendered":"\n<p>In a recent blog post, my colleague Joe Hilger <a href=\"https:\/\/enterprise-knowledge.com\/taking-content-personalization-to-the-next-level-graphs-and-componentized-content-management\/\">described<\/a> how a knowledge graph can be used in conjunction with a componentized content management system (CCMS) to provide personalized content to customers. This post will show the example data from Hilger\u2019s post being loaded into a knowledge graph and queried to find the content appropriate for each customer, using Python and the <a href=\"https:\/\/rdflib.readthedocs.io\/en\/stable\/\">rdflib<\/a> package. In doing so, it will help make these principles more concrete, and help you in your journey towards content personalization.<\/p>\n\n\n\n<p>To follow along, a basic understanding of Python programming is required.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Aggregating Data<\/h2>\n\n\n\n<p>Hilger\u2019s article shows the following visualization of a knowledge graph to illustrate how the graph connects data from many different sources and encodes the relationship between them.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1248\" height=\"588\" src=\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\" alt=\"Diagram showing customers, products and parts\" class=\"wp-image-14362\" srcset=\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png 1248w, https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2-336x158.png 336w, https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2-771x363.png 771w, https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2-768x362.png 768w\" sizes=\"auto, (max-width: 1248px) 100vw, 1248px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>To show this system in action, we will start out with a few sets of data about:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Customers and the products they own<\/li>\n\n\n\n<li>Products and the parts they are composed of<\/li>\n\n\n\n<li>Parts and the actions that need to be taken on them<\/li>\n<\/ul>\n\n\n\n<p>In practice, this information would be pulled from the sales tracking, product support, and other systems it lives in via APIs or database queries, as described by Hilger.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">customers_products = [\n    {\"customer\": \"Stephen Smith\", \"product\": \"Product A\"},\n    {\"customer\": \"Lisa Lu\", \"product\": \"Product A\"},\n]\n\nproducts_parts = [\n    {\"product\": \"Product A\", \"part\": \"Part X\"},\n    {\"product\": \"Product A\", \"part\": \"Part Y\"},\n    {\"product\": \"Product A\", \"part\": \"Part Z\"},\n]\nparts_actions = [{\"part\": \"Part Z\", \"action\": \"Recall\"}]<\/pre>\n\n\n\n<p>We will enter this data into a graph as a series of subject-predicate-object triples, each of which represents a node (the subject) and its relationship (the predicate) to another node (the object). RDF graphs use uniform resource identifiers (URIs) to provide a unique identifier for both nodes and relationships, though an object can also be a literal value.<\/p>\n\n\n\n<p>Unlike the traditional identifiers you may be used to in a relational database, URIs in RDF always use a URL format (meaning they begin with http:\/\/), although a URI is not required to point to an existing website. The base part of this URI is referred to as a namespace, and it\u2019s common to use your organization\u2019s domain as part of this. For this tutorial we will use http:\/\/example.com as our namespace.<\/p>\n\n\n\n<p>We also need a way to represent these relationship predicates. For most enterprise RDF knowledge graphs, we start with an <a href=\"https:\/\/enterprise-knowledge.com\/whats-the-difference-between-an-ontology-and-a-knowledge-graph\/\">ontology<\/a>, which is a data model that defines the types of things in our graph, their attributes, and the relationships between them. For this example, we will use the following relationships:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Relationship<\/td><td>URI<\/td><\/tr><tr><td>Customer\u2019s ownership of a product<\/td><td>http:\/\/example.com\/owns<\/td><\/tr><tr><td>Product being composed of a part<\/td><td>http:\/\/example.com\/isComposedOf<\/td><\/tr><tr><td>Part requiring an action<\/td><td>http:\/\/example.com\/needs<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Note the use of camelCase in the name &#8211; for more best practices in ontology design, including how to incorporate open standard vocabularies like SKOS and OWL into your graph, see <a href=\"https:\/\/enterprise-knowledge.com\/keys-to-successful-ontology-design\/\">here<\/a>.<\/p>\n\n\n\n<p>The triple representing Stephen Smith\u2019s ownership of Product A in rdflib would then look like this, using the <code>URIRef<\/code> class to encode each URI:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from rdflib import URIRef\n\ntriple = (\n    URIRef(\"http:\/\/example.com\/Stephen_Smith\"),\n    URIRef(\"http:\/\/example.com\/owns\"),\n    URIRef(\"http:\/\/example.com\/Product_A\"),\n)<\/pre>\n\n\n\n<p>Because typing out full URLs every time you want to add or reference a component of a graph can be cumbersome, most RDF-compliant tools and development resources provide some shorthand way to refer to these URIs. In rdflib that\u2019s the <code>Namespace<\/code> module. Here we create our own namespace for example.com, and use it to more concisely create that triple:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from rdflib import Namespace\n\nEG = Namespace(\"http:\/\/example.com\/\")\n\ntriple = (EG[\"Stephen_Smith\"], EG[\"owns\"], EG[\"Product_A\"])<\/pre>\n\n\n\n<p>We can further simplify this process by defining a function to transform these strings into valid URIs using the <code>quote<\/code> function from the <a href=\"https:\/\/docs.python.org\/3\/library\/urllib.parse.html#url-quoting\">urlparse module<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from urllib.parse import quote\n\ndef create_eg_uri(name: str) -&gt; URIRef:\n&nbsp;&nbsp;&nbsp;&nbsp;\"\"\"Take a string and return a valid example.com URI\"\"\"\n&nbsp;&nbsp;&nbsp;&nbsp;quoted = quote(name.replace(\" \", \"_\"))\n&nbsp;&nbsp;&nbsp;&nbsp;return EG[quoted]\n<\/pre>\n\n\n\n<p>Now, let\u2019s create a new <code>Graph<\/code> object and add these relationships to it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from rdflib import Graph\n\ngraph = Graph()\n\nowns = create_eg_uri(\"owns\")\nfor item in customers_products:\n&nbsp;&nbsp;&nbsp;&nbsp;customer = create_eg_uri(item[\"customer\"])\n&nbsp;&nbsp;&nbsp;&nbsp;product = create_eg_uri(item[\"product\"])\n&nbsp;&nbsp;&nbsp;&nbsp;graph.add((customer, owns, product))\n\nis_composed_of = create_eg_uri(\"isComposedOf\")\nfor item in products_parts:\n&nbsp;&nbsp;&nbsp;&nbsp;product = create_eg_uri(item[\"product\"])\n&nbsp;&nbsp;&nbsp;&nbsp;part = create_eg_uri(item[\"part\"])\n&nbsp;&nbsp;&nbsp;&nbsp;graph.add((product, is_composed_of, part))\n\nneeds = create_eg_uri(\"needs\")\nfor item in parts_actions:\n&nbsp;&nbsp;&nbsp;&nbsp;part = create_eg_uri(item[\"part\"])\n&nbsp;&nbsp;&nbsp;&nbsp;action = create_eg_uri(item[\"action\"])\n&nbsp;&nbsp;&nbsp;&nbsp;graph.add((part, needs, action))\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Querying the Graph<\/h2>\n\n\n\n<p>Now we are able to query the graph, in order to find all of the customers that own a product containing a part that requires a recall. To do this, we\u2019ll construct a query in SPARQL, the query language for RDF graphs.<\/p>\n\n\n\n<p>SPARQL has some features in common with SQL, but <a href=\"https:\/\/enterprise-knowledge.com\/why-am-i-mr-sparql\/\">works quite differently<\/a>. Instead of selecting from a table and joining others, we will describe a path through the graph based on the relationships each kind of node has to another:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sparql_query = \"\"\"SELECT ?customer ?product\nWHERE {\n  ?customer eg:owns ?product .\n  ?product eg:isComposedOf ?part .\n  ?part eg:needs eg:Recall .\n}\"\"\"<\/pre>\n\n\n\n<p>The WHERE clause asks for:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Any node that has an owns relationship to another &#8211; the subject is bound to the variable <code>?customer<\/code> and the object to <code>?product<\/code><\/li>\n\n\n\n<li>Any node that has an isComposedOf relationship to the <code>?product<\/code> from the previous line, the subject of which is then bound to <code>?part<\/code><\/li>\n\n\n\n<li>Any node where the object has a needs relationship to an object which is a Recall.<\/li>\n<\/ol>\n\n\n\n<p>Note that we did not at any point tell the graph which of the URIs in our graph referred to a customer. By simply looking for any node that owns something, we were able to find the customers automatically. If we had a requirement to be more explicit about typing, we could add triples to our graph describing the type of each entity using the <a href=\"https:\/\/www.w3.org\/TR\/rdf-schema\/#ch_type\">RDF type<\/a> relationship, then refer to these in the query.<\/p>\n\n\n\n<p>We can then execute this query against the graph, using the <a href=\"https:\/\/rdflib.readthedocs.io\/en\/stable\/namespaces_and_bindings.html#namespaces-in-sparql-queries\">initNs argument<\/a> to map the \u201ceg:\u201d prefixes in the query string to our example.com namespace, and print the results:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">results = graph.query(sparql_query, initNs={\"eg\": EG})\n \nfor row in results:\n    print(row)<\/pre>\n\n\n\n<p>This shows us the URIs for the affected customers and the products they own:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">(rdflib.term.URIRef('http:\/\/example.com\/Stephen_Smith'), rdflib.term.URIRef('http:\/\/example.com\/Product_A'))\n(rdflib.term.URIRef('http:\/\/example.com\/Lisa_Lu'), rdflib.term.URIRef('http:\/\/example.com\/Product_A'))<\/pre>\n\n\n\n<p>These fields could then be sent back to our componentized content management system, allowing it to send the appropriate recall messages to those customers!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>The concepts and steps described in this post are generally applicable to setting up a knowledge graph in any environment, whether in-memory using Python or Java, or with a commercial graph database product. By breaking your organization&#8217;s content down into chunks inside a componentized content management system and using the graph to aggregate this data with your other systems, you can ensure that the exact content each customer needs to see gets delivered to them at the right time. You can also use your graph to create effective <a href=\"https:\/\/enterprise-knowledge.com\/five-steps-to-implement-search-with-a-knowledge-graph\/\">enterprise search systems<\/a>, among many <a href=\"https:\/\/enterprise-knowledge.com\/what-is-an-enterprise-knowledge-graph-and-why-do-i-want-one\/\">other applications<\/a>.<\/p>\n\n\n\n<p>Interested in best in class personalization using a CCMS plus a knowledge graph? <a href=\"https:\/\/enterprise-knowledge.com\/contact-us\/\">Contact us<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a recent blog post, my colleague Joe Hilger described how a knowledge graph can be used in conjunction with a componentized content management system (CCMS) to provide personalized content to customers. This post will show the example data from Hilger\u2019s post being loaded into a knowledge graph and queried to find the content appropriate &#8230; <a href=\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\"  class=\"with-arrow\">Continue reading<\/a><\/p>\n","protected":false},"author":60,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"_uag_custom_page_level_css":"","footnotes":""},"categories":[187,512,186],"tags":[1062,1064,1063,428,427,714,678],"article-type":[100],"solution":[1091],"ppma_author":[1389],"class_list":["post-14361","post","type-post","status-publish","format-standard","hentry","category-advanced-content","category-knowledge-graphs-data-modeling","category-software-development","tag-ccms","tag-componentized-content-management-system","tag-content-personalization","tag-enterprise-knowledge-graph","tag-knowledge-graph","tag-rdf","tag-sparql","article-type-blog","solution-content-assembly"],"acf":[],"featured_image_urls_v2":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":"","slideshow":"","slideshow-2x":"","banner":"","home-large":"","home-medium":"","home-small":"","gform-image-choice-sm":"","gform-image-choice-md":"","gform-image-choice-lg":""},"post_excerpt_stackable_v2":"<p>In a recent blog post, my colleague Joe Hilger described how a knowledge graph can be used in conjunction with a componentized content management system (CCMS) to provide personalized content to customers. This post will show the example data from Hilger\u2019s post being loaded into a knowledge graph and queried to find the content appropriate &#8230;<\/p>\n","category_list_v2":"<a href=\"https:\/\/enterprise-knowledge.com\/category\/advanced-content\/\" rel=\"category tag\">Content Strategy and Operations<\/a>, <a href=\"https:\/\/enterprise-knowledge.com\/category\/knowledge-graphs-data-modeling\/\" rel=\"category tag\">Knowledge Graphs &amp; Data Modeling<\/a>, <a href=\"https:\/\/enterprise-knowledge.com\/category\/software-development\/\" rel=\"category tag\">Technology Solutions<\/a>","author_info_v2":{"name":"Neil Quinn","url":"https:\/\/enterprise-knowledge.com\/author\/nquinnenterprise-knowledge-com\/"},"comments_num_v2":"0 comments","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Content Personalization with Knowledge Graphs in Python - Enterprise Knowledge<\/title>\n<meta name=\"description\" content=\"How to create a knowledge graph using rdflib and Python to provide personalized content for your customers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Content Personalization with Knowledge Graphs in Python - Enterprise Knowledge\" \/>\n<meta property=\"og:description\" content=\"How to create a knowledge graph using rdflib and Python to provide personalized content for your customers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Enterprise Knowledge\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Enterprise-Knowledge-359618484181651\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-14T15:00:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-05T14:47:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\" \/>\n<meta name=\"author\" content=\"Neil Quinn\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EKConsulting\" \/>\n<meta name=\"twitter:site\" content=\"@EKConsulting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Neil Quinn\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\"},\"author\":{\"name\":\"Neil Quinn\",\"@id\":\"https:\/\/enterprise-knowledge.com\/#\/schema\/person\/1c5874772638c216f0c8105d36e4147a\"},\"headline\":\"Content Personalization with Knowledge Graphs in Python\",\"datePublished\":\"2022-02-14T15:00:14+00:00\",\"dateModified\":\"2025-09-05T14:47:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\"},\"wordCount\":976,\"publisher\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\",\"keywords\":[\"CCMS\",\"Componentized Content Management System\",\"Content Personalization\",\"enterprise knowledge graph\",\"knowledge graph\",\"RDF\",\"SPARQL\"],\"articleSection\":[\"Content Strategy and Operations\",\"Knowledge Graphs &amp; Data Modeling\",\"Technology Solutions\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\",\"url\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\",\"name\":\"Content Personalization with Knowledge Graphs in Python - Enterprise Knowledge\",\"isPartOf\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\",\"datePublished\":\"2022-02-14T15:00:14+00:00\",\"dateModified\":\"2025-09-05T14:47:01+00:00\",\"description\":\"How to create a knowledge graph using rdflib and Python to provide personalized content for your customers.\",\"breadcrumb\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage\",\"url\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\",\"contentUrl\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png\",\"width\":1248,\"height\":588,\"caption\":\"Diagram showing customers, products and parts\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/enterprise-knowledge.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Content Personalization with Knowledge Graphs in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/enterprise-knowledge.com\/#website\",\"url\":\"https:\/\/enterprise-knowledge.com\/\",\"name\":\"Enterprise Knowledge\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/enterprise-knowledge.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/enterprise-knowledge.com\/#organization\",\"name\":\"Enterprise Knowledge\",\"url\":\"https:\/\/enterprise-knowledge.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/enterprise-knowledge.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2013\/09\/favicon.jpg\",\"contentUrl\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2013\/09\/favicon.jpg\",\"width\":69,\"height\":69,\"caption\":\"Enterprise Knowledge\"},\"image\":{\"@id\":\"https:\/\/enterprise-knowledge.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Enterprise-Knowledge-359618484181651\/\",\"https:\/\/x.com\/EKConsulting\",\"https:\/\/www.linkedin.com\/company\/enterprise-knowledge-llc\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/enterprise-knowledge.com\/#\/schema\/person\/1c5874772638c216f0c8105d36e4147a\",\"name\":\"Neil Quinn\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/enterprise-knowledge.com\/#\/schema\/person\/image\/6d1554ce5a1f90ff4d87da9fe7a874cd\",\"url\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2025\/05\/NeilHeadshot-scaled.jpg\",\"contentUrl\":\"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2025\/05\/NeilHeadshot-scaled.jpg\",\"caption\":\"Neil Quinn\"},\"description\":\"Neil Quinn is a software developer with experience building front and back-end web applications using Python, ReactJS, and other technologies. Quinn works closely with clients to fully understand their needs, and pays attention to the user experience.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/neilsquinn\/\"],\"url\":\"https:\/\/enterprise-knowledge.com\/author\/nquinnenterprise-knowledge-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Content Personalization with Knowledge Graphs in Python - Enterprise Knowledge","description":"How to create a knowledge graph using rdflib and Python to provide personalized content for your customers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Content Personalization with Knowledge Graphs in Python - Enterprise Knowledge","og_description":"How to create a knowledge graph using rdflib and Python to provide personalized content for your customers.","og_url":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/","og_site_name":"Enterprise Knowledge","article_publisher":"https:\/\/www.facebook.com\/Enterprise-Knowledge-359618484181651\/","article_published_time":"2022-02-14T15:00:14+00:00","article_modified_time":"2025-09-05T14:47:01+00:00","og_image":[{"url":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png","type":"","width":"","height":""}],"author":"Neil Quinn","twitter_card":"summary_large_image","twitter_creator":"@EKConsulting","twitter_site":"@EKConsulting","twitter_misc":{"Written by":"Neil Quinn","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#article","isPartOf":{"@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/"},"author":{"name":"Neil Quinn","@id":"https:\/\/enterprise-knowledge.com\/#\/schema\/person\/1c5874772638c216f0c8105d36e4147a"},"headline":"Content Personalization with Knowledge Graphs in Python","datePublished":"2022-02-14T15:00:14+00:00","dateModified":"2025-09-05T14:47:01+00:00","mainEntityOfPage":{"@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/"},"wordCount":976,"publisher":{"@id":"https:\/\/enterprise-knowledge.com\/#organization"},"image":{"@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png","keywords":["CCMS","Componentized Content Management System","Content Personalization","enterprise knowledge graph","knowledge graph","RDF","SPARQL"],"articleSection":["Content Strategy and Operations","Knowledge Graphs &amp; Data Modeling","Technology Solutions"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/","url":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/","name":"Content Personalization with Knowledge Graphs in Python - Enterprise Knowledge","isPartOf":{"@id":"https:\/\/enterprise-knowledge.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage"},"image":{"@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png","datePublished":"2022-02-14T15:00:14+00:00","dateModified":"2025-09-05T14:47:01+00:00","description":"How to create a knowledge graph using rdflib and Python to provide personalized content for your customers.","breadcrumb":{"@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#primaryimage","url":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png","contentUrl":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2022\/02\/EK-content-personalization-blog-2.png","width":1248,"height":588,"caption":"Diagram showing customers, products and parts"},{"@type":"BreadcrumbList","@id":"https:\/\/enterprise-knowledge.com\/content-personalization-with-knowledge-graphs-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/enterprise-knowledge.com\/"},{"@type":"ListItem","position":2,"name":"Content Personalization with Knowledge Graphs in Python"}]},{"@type":"WebSite","@id":"https:\/\/enterprise-knowledge.com\/#website","url":"https:\/\/enterprise-knowledge.com\/","name":"Enterprise Knowledge","description":"","publisher":{"@id":"https:\/\/enterprise-knowledge.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/enterprise-knowledge.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/enterprise-knowledge.com\/#organization","name":"Enterprise Knowledge","url":"https:\/\/enterprise-knowledge.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/enterprise-knowledge.com\/#\/schema\/logo\/image\/","url":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2013\/09\/favicon.jpg","contentUrl":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2013\/09\/favicon.jpg","width":69,"height":69,"caption":"Enterprise Knowledge"},"image":{"@id":"https:\/\/enterprise-knowledge.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Enterprise-Knowledge-359618484181651\/","https:\/\/x.com\/EKConsulting","https:\/\/www.linkedin.com\/company\/enterprise-knowledge-llc"]},{"@type":"Person","@id":"https:\/\/enterprise-knowledge.com\/#\/schema\/person\/1c5874772638c216f0c8105d36e4147a","name":"Neil Quinn","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/enterprise-knowledge.com\/#\/schema\/person\/image\/6d1554ce5a1f90ff4d87da9fe7a874cd","url":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2025\/05\/NeilHeadshot-scaled.jpg","contentUrl":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2025\/05\/NeilHeadshot-scaled.jpg","caption":"Neil Quinn"},"description":"Neil Quinn is a software developer with experience building front and back-end web applications using Python, ReactJS, and other technologies. Quinn works closely with clients to fully understand their needs, and pays attention to the user experience.","sameAs":["https:\/\/www.linkedin.com\/in\/neilsquinn\/"],"url":"https:\/\/enterprise-knowledge.com\/author\/nquinnenterprise-knowledge-com\/"}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"slideshow":false,"slideshow-2x":false,"banner":false,"home-large":false,"home-medium":false,"home-small":false,"gform-image-choice-sm":false,"gform-image-choice-md":false,"gform-image-choice-lg":false},"uagb_author_info":{"display_name":"Neil Quinn","author_link":"https:\/\/enterprise-knowledge.com\/author\/nquinnenterprise-knowledge-com\/"},"uagb_comment_info":0,"uagb_excerpt":"In a recent blog post, my colleague Joe Hilger described how a knowledge graph can be used in conjunction with a componentized content management system (CCMS) to provide personalized content to customers. This post will show the example data from Hilger\u2019s post being loaded into a knowledge graph and queried to find the content appropriate&hellip;","authors":[{"term_id":1389,"user_id":60,"is_guest":0,"slug":"nquinnenterprise-knowledge-com","display_name":"Neil Quinn","avatar_url":{"url":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2025\/05\/NeilHeadshot-scaled.jpg","url2x":"https:\/\/enterprise-knowledge.com\/wp-content\/uploads\/2025\/05\/NeilHeadshot-scaled.jpg"},"first_name":"Neil","last_name":"Quinn","user_url":"","job_title":"","description":"Neil Quinn is a software developer with experience building front and back-end web applications using Python, ReactJS, and other technologies. Quinn works closely with clients to fully understand their needs, and pays attention to the user experience."}],"_links":{"self":[{"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/posts\/14361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/users\/60"}],"replies":[{"embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/comments?post=14361"}],"version-history":[{"count":22,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/posts\/14361\/revisions"}],"predecessor-version":[{"id":25282,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/posts\/14361\/revisions\/25282"}],"wp:attachment":[{"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/media?parent=14361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/categories?post=14361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/tags?post=14361"},{"taxonomy":"article-type","embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/article-type?post=14361"},{"taxonomy":"solution","embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/solution?post=14361"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/enterprise-knowledge.com\/wp-json\/wp\/v2\/ppma_author?post=14361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}