From 4ea9a2c1340b3eca507b08fdd4594f2e42ac1d35 Mon Sep 17 00:00:00 2001 From: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Date: Sat, 9 Mar 2024 18:39:00 +0100 Subject: [PATCH] Prepare for the presentation, add info --- Demo_graph.ipynb | 308 ++++++++++-------- .../api/v1/cognify/cognify.py | 115 +++++++ .../cognify/graph/add_classification_nodes.py | 48 +++ .../modules/cognify/graph/add_propositions.py | 97 ++++++ .../modules/cognify/graph/create.py | 209 ++++++++++++ .../cognify/graph/create_semantic_graph.py | 146 --------- 6 files changed, 645 insertions(+), 278 deletions(-) create mode 100644 cognitive_architecture/api/v1/cognify/cognify.py create mode 100644 cognitive_architecture/modules/cognify/graph/add_classification_nodes.py create mode 100644 cognitive_architecture/modules/cognify/graph/add_propositions.py create mode 100644 cognitive_architecture/modules/cognify/graph/create.py delete mode 100644 cognitive_architecture/modules/cognify/graph/create_semantic_graph.py diff --git a/Demo_graph.ipynb b/Demo_graph.ipynb index ca4148543..1b998bbf7 100644 --- a/Demo_graph.ipynb +++ b/Demo_graph.ipynb @@ -582,15 +582,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "id": "42dbf97d-79b9-4627-b307-b64ac22db4f7", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "{'data_type': 'text',\n", + " 'context_name': 'TEXT',\n", + " 'layer_name': 'Articles, essays, and reports'}" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "transformed_dict_1" + ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 51, "id": "25adeeb7-cce2-4eac-8fb5-4ff47029d77d", "metadata": {}, "outputs": [], @@ -622,7 +637,7 @@ }, { "cell_type": "code", - "execution_count": 262, + "execution_count": 52, "id": "b59a52d7-d82b-4546-b0b1-a3d0f62a2a65", "metadata": {}, "outputs": [], @@ -700,6 +715,27 @@ "import ast \n" ] }, + { + "cell_type": "code", + "execution_count": 47, + "id": "de3bdbb7-0b2b-46fa-a42f-3ca288c4d875", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'{\"layer\": \"Semantic Layer\"}': KnowledgeGraph(nodes=[Node(id=1, description='Britons have a significant affection for animals and treat pet-keeping as an integral part of life', category='people', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='Keeping pets is considered a serious and passionate activity in Britain, not merely a leisure activity', category='culturalPractice', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='Dogs are particularly treasured in Britain and are seen as outlets for emotions and social interaction', category='animal', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=4, description='British society is accommodating of dogs, with public spaces and services being dog-friendly', category='socialNorm', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=5, description='The COVID-19 pandemic caused a surge in pet ownership, particularly dogs, leading to increased numbers and issues like dog attacks', category='event', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=6, description='Pets, especially dogs, are increasingly being treated as commodities and status symbols, with a focus on aesthetic breeds', category='socialIssue', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=7, description='Fashionable dog breeds, such as French bulldogs and American XL bullies, are in high demand regardless of health issues they may face', category='animal', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=8, description='Pets are increasingly treated like substitute children or used to project personal identities', category='socialTrend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=9, description='Spending on pets in the UK has doubled in the last decade, with a trend towards non-essential luxury items for pets', category='economicTrend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=10, description='There is a discrepancy between what pets truly need and the human projection of desires onto them', category='animalWelfare', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=11, description='Modern lifestyles can conflict with the needs of pets, leading to behavioral issues and insufficient care', category='animalWelfare', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=12, description='The relationship with pets should prioritize their wellbeing and recognize their distinct nature', category='ethicalPrinciple', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=2, description='Britons are known for their serious approach to keeping pets', color='green', created_at=None, summarized=None), Edge(source=2, target=3, description='Dogs are a central part of the pet-keeping practice in Britain', color='green', created_at=None, summarized=None), Edge(source=3, target=4, description='Dogs are widely accepted in public spaces and services due to British social norms', color='green', created_at=None, summarized=None), Edge(source=5, target=6, description='The pandemic surge in pet ownership led to an increase in the commodification of pets', color='green', created_at=None, summarized=None), Edge(source=7, target=6, description='Designer dog breeds are part of the trend of pets being commodified', color='green', created_at=None, summarized=None), Edge(source=9, target=8, description='Increased spending on pet luxuries is related to treating pets as substitutes for children or personal identity projections', color='green', created_at=None, summarized=None), Edge(source=10, target=11, description='The conflict between pet needs and human desires is evident in modern pet care', color='green', created_at=None, summarized=None)])}" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "layer_1_graph[0]" + ] + }, { "cell_type": "code", "execution_count": 31, @@ -721,86 +757,27 @@ }, { "cell_type": "code", - "execution_count": 261, + "execution_count": 54, "id": "142f4bd8-ec50-4715-ba58-981bda65116c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nodes and their data:\n", - "GraphModel:user123 {'id': 'user123', 'user_properties': {'custom_properties': {'age': '30'}, 'location': {'location_id': 'ny', 'description': 'New York', 'default_relationship': {'type': 'located_in', 'properties': None}}}, 'documents': [{'doc_id': 'doc1', 'title': 'Document 1', 'summary': 'Summary of Document 1', 'content_id': 'content_id_for_doc1', 'doc_type': {'type_id': 'PDF', 'description': 'Portable Document Format', 'default_relationship': {'type': 'is_type', 'properties': None}}, 'categories': [{'category_id': 'finance', 'name': 'Finance', 'default_relationship': {'type': 'belongs_to', 'properties': None}}, {'category_id': 'tech', 'name': 'Technology', 'default_relationship': {'type': 'belongs_to', 'properties': None}}], 'default_relationship': {'type': 'has_document', 'properties': None}}, {'doc_id': 'doc2', 'title': 'Document 2', 'summary': 'Summary of Document 2', 'content_id': 'content_id_for_doc2', 'doc_type': {'type_id': 'TXT', 'description': 'Text File', 'default_relationship': {'type': 'is_type', 'properties': None}}, 'categories': [{'category_id': 'health', 'name': 'Health', 'default_relationship': {'type': 'belongs_to', 'properties': None}}, {'category_id': 'wellness', 'name': 'Wellness', 'default_relationship': {'type': 'belongs_to', 'properties': None}}], 'default_relationship': {'type': 'has_document', 'properties': None}}], 'default_fields': {'created_at': '2024-03-09 12:30:06', 'updated_at': '2024-03-09 12:30:06'}}\n", - "UserProperties:default {'custom_properties': {'age': '30'}, 'location': {'location_id': 'ny', 'description': 'New York', 'default_relationship': {'type': 'located_in', 'properties': None}}}\n", - "UserLocation:ny {'location_id': 'ny', 'description': 'New York'}\n", - "Relationship:default {'type': 'has_document', 'properties': None}\n", - "Document:doc1 {'doc_id': 'doc1', 'title': 'Document 1', 'summary': 'Summary of Document 1', 'content_id': 'content_id_for_doc1', 'doc_type': {'type_id': 'PDF', 'description': 'Portable Document Format', 'default_relationship': {'type': 'is_type', 'properties': None}}, 'categories': [{'category_id': 'finance', 'name': 'Finance', 'default_relationship': {'type': 'belongs_to', 'properties': None}}, {'category_id': 'tech', 'name': 'Technology', 'default_relationship': {'type': 'belongs_to', 'properties': None}}]}\n", - "DocumentType:PDF {'type_id': 'PDF', 'description': 'Portable Document Format'}\n", - "Category:default {'category_id': 'wellness', 'name': 'Wellness'}\n", - "Document:doc2 {'doc_id': 'doc2', 'title': 'Document 2', 'summary': 'Summary of Document 2', 'content_id': 'content_id_for_doc2', 'doc_type': {'type_id': 'TXT', 'description': 'Text File', 'default_relationship': {'type': 'is_type', 'properties': None}}, 'categories': [{'category_id': 'health', 'name': 'Health', 'default_relationship': {'type': 'belongs_to', 'properties': None}}, {'category_id': 'wellness', 'name': 'Wellness', 'default_relationship': {'type': 'belongs_to', 'properties': None}}]}\n", - "DocumentType:TXT {'type_id': 'TXT', 'description': 'Text File'}\n", - "LLM_LAYER_CLASSIFICATION:TEXT:123 {'data_type': 'text', 'context_name': 'TEXT', 'layer_name': 'News stories and blog posts'}\n", - "123 {}\n", - "LLM_CLASSIFICATION:LAYER:News stories and blog posts:123 {'data_type': 'text', 'context_name': 'TEXT', 'layer_name': 'News stories and blog posts'}\n", - "LLM_LAYER_CLASSIFICATION:TEXT:doc1 {'data_type': 'text', 'context_name': 'TEXT', 'layer_name': 'News stories and blog posts'}\n", - "doc1 {}\n", - "LLM_CLASSIFICATION:LAYER:News stories and blog posts:doc1 {'data_type': 'text', 'context_name': 'TEXT', 'layer_name': 'News stories and blog posts'}\n", - "\n", - "Edges and their data:\n", - "GraphModel:user123 -> UserProperties:default {}\n", - "GraphModel:user123 -> Document:doc1 {'type': 'has_document', 'properties': None}\n", - "GraphModel:user123 -> Document:doc2 {'type': 'has_document', 'properties': None}\n", - "UserProperties:default -> UserLocation:ny {'type': 'located_in', 'properties': None}\n", - "UserLocation:ny -> Relationship:default {}\n", - "Relationship:default -> DocumentType:PDF {}\n", - "Relationship:default -> Category:default {}\n", - "Relationship:default -> Document:doc1 {}\n", - "Relationship:default -> DocumentType:TXT {}\n", - "Relationship:default -> Document:doc2 {}\n", - "Document:doc1 -> DocumentType:PDF {'type': 'is_type', 'properties': None}\n", - "Document:doc1 -> Category:default {'type': 'belongs_to', 'properties': None}\n", - "Category:default -> Document:doc2 {'type': 'belongs_to', 'properties': None}\n", - "Document:doc2 -> DocumentType:TXT {'type': 'is_type', 'properties': None}\n", - "LLM_LAYER_CLASSIFICATION:TEXT:123 -> 123 {'relationship': 'classified_as'}\n", - "LLM_LAYER_CLASSIFICATION:TEXT:123 -> LLM_CLASSIFICATION:LAYER:News stories and blog posts:123 {'relationship': 'contains_analysis'}\n", - "LLM_LAYER_CLASSIFICATION:TEXT:doc1 -> doc1 {'relationship': 'classified_as'}\n", - "LLM_LAYER_CLASSIFICATION:TEXT:doc1 -> LLM_CLASSIFICATION:LAYER:News stories and blog posts:doc1 {'relationship': 'contains_analysis'}\n" - ] - } - ], + "outputs": [], "source": [ - " print(\"Nodes and their data:\")\n", - " for node, data in U.nodes(data=True):\n", - " print(node, data)\n", + " # print(\"Nodes and their data:\")\n", + " # for node, data in U.nodes(data=True):\n", + " # print(node, data)\n", "\n", - " # Print edges with their data\n", - " print(\"\\nEdges and their data:\")\n", - " for source, target, data in U.edges(data=True):\n", - " print(f\"{source} -> {target} {data}\")" + " # # Print edges with their data\n", + " # print(\"\\nEdges and their data:\")\n", + " # for source, target, data in U.edges(data=True):\n", + " # print(f\"{source} -> {target} {data}\")" ] }, { "cell_type": "code", - "execution_count": 268, + "execution_count": null, "id": "58644c64-7ef0-415f-8e41-e2edcf5fd15b", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[KnowledgeGraph(nodes=[Node(id=1, description='British society', category='society', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='Animals', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='Pets', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=4, description='Kate Fox', category='person', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=5, description='Dogs', category='animal', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=6, description='Public transport', category='transport', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=7, description='Dog owners', category='people', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=8, description='Pandemic', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=9, description='Increase in number of pet dogs in the UK from about 9 million to 13 million between 2019 and 2022', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=10, description='Rise in number of dog attacks', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=11, description='Designer dog breeds in fashion', category='trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=12, description='Pets treated as substitutes for children', category='trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=13, description='Total spend on pets in the UK has more than doubled in the past decade, reaching nearly £10bn last year', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=14, description='Pet boutiques selling luxury pet products', category='business', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=15, description='Basic needs and desires of pets', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=16, description='Dog-friendly establishments like restaurants, cinemas, churches', category='places', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=17, description='Behavioral problems in dogs', category='condition', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=18, description='Wellbeing of dogs', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=2, description=\"British society's fondness for animals\", color='blue', created_at=None, summarized=None), Edge(source=6, target=5, description='Dogs are welcomed on public transport in the UK', color='blue', created_at=None, summarized=None), Edge(source=3, target=4, description='Kate Fox observed pet keeping as a way of life in British society', color='blue', created_at=None, summarized=None), Edge(source=7, target=8, description='Dog ownership increased during the pandemic', color='blue', created_at=None, summarized=None), Edge(source=9, target=1, description='British society saw an increase in the number of pet dogs', color='blue', created_at=None, summarized=None), Edge(source=10, target=6, description='Increase in dog attacks may be correlated with dogs in public spaces', color='blue', created_at=None, summarized=None), Edge(source=12, target=1, description='Shift in British society to treat pets similarly to children', color='blue', created_at=None, summarized=None), Edge(source=13, target=7, description='Dog owners spending more on pets', color='blue', created_at=None, summarized=None), Edge(source=14, target=16, description='Pet boutiques and dog-friendly establishments part of the same trend', color='blue', created_at=None, summarized=None), Edge(source=17, target=18, description='Behavioral problems can affect dog wellbeing', color='blue', created_at=None, summarized=None), Edge(source=1, target=11, description=\"British society's interest in designer dog breeds\", color='blue', created_at=None, summarized=None)]),\n", - " KnowledgeGraph(nodes=[Node(id=1, description='Britons show a strong affection for animals, viewing pet-keeping as a way of life.', category='people', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='In British culture, pets are an outlet for emotions and serve as connectors with others.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='Dogs in the UK are seen as emotional outlets and receive welcoming treatment in public spaces.', category='animals', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=4, description='In the UK, dogs are encouraged to accompany owners on public transport.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=5, description='The COVID-19 pandemic led to a surge in dog ownership in the UK.', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=6, description='Pet dog population in the UK rose from about 9 million to 13 million between 2019 and 2022.', category='data', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=7, description='Green spaces have been declining, impacting dog-friendly areas.', category='entity', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=8, description='Dog attacks in England and Wales increased by over a third between 2018 and 2022.', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=9, description='Designer dog breeds in the UK often face health issues due to their physical features.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=10, description='A portion of pet owners in the UK enjoy keeping up with pet trends and products.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=11, description='Expenditure on pets in the UK has doubled in the past decade, with non-essential items becoming popular.', category='data', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=12, description='The health and wellbeing of dogs are often compromised due to human lifestyle and consumerism.', category='concept', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=2, description='have a strong affection for', color='blue', created_at=None, summarized=None), Edge(source=2, target=3, description='are particularly significant as', color='blue', created_at=None, summarized=None), Edge(source=3, target=4, description='are encouraged on', color='blue', created_at=None, summarized=None), Edge(source=5, target=6, description='caused an increase in', color='blue', created_at=None, summarized=None), Edge(source=7, target=6, description='are contrasted with the rise in', color='blue', created_at=None, summarized=None), Edge(source=8, target=7, description='increase may be affected by the decline in', color='blue', created_at=None, summarized=None), Edge(source=9, target=10, description='are part of', color='blue', created_at=None, summarized=None), Edge(source=10, target=11, description='contribute to', color='blue', created_at=None, summarized=None), Edge(source=12, target=9, description='is impacted by the promotion of', color='blue', created_at=None, summarized=None)]),\n", - " KnowledgeGraph(nodes=[Node(id=1, description='Britons have a special relationship with animals, considering them an integral part of their lifestyle and an outlet for emotions and social engagement.', category='cultural practice', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='In the UK, dogs are allowed and encouraged to ride on public transport.', category='policy', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='Many UK establishments are pet-friendly, often displaying signs that humorously prioritize dogs over people.', category='social norm', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=4, description='The number of pet dogs in the UK surged from about nine million to 13 million between 2019 and 2022, partly influenced by the COVID-19 pandemic.', category='event', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=5, description=\"The Dogs Trust charity coined the slogan 'A dog is for life, not just for Christmas' to combat impulsive pet adoption.\", category='campaign', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=6, description='Dog attacks recorded by police in England and Wales have risen by more than a third from 2018 to 2022.', category='statistic', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=7, description=\"Living beings such as pets are increasingly being treated as commodities, evident in the popularity of 'designer' breeds and the aesthetic-driven breeding choices.\", category='trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=8, description='The total spending on pets in the UK has surpassed nearly £10bn, with a significant part going to non-essential items and services.', category='economic statistic', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=9, description='Modern lifestyles involve leaving dogs alone for extended periods, which can lead to behavioral problems.', category='social issue', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=10, description='There is a shift in pet parenting, with pets increasingly treated as child substitutes rather than valued for the qualities inherent to their species.', category='social change', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=2, description='The relationship Britons have with animals extends to policies such as allowing dogs on public transport.', color='blue', created_at=None, summarized=None), Edge(source=2, target=3, description='The pet-friendly nature of public transport in the UK is echoed in the pet-friendly approach of many establishments.', color='blue', created_at=None, summarized=None), Edge(source=4, target=5, description=\"The increase in pet adoption during the pandemic highlights the relevance of Dogs Trust's long-standing slogan.\", color='blue', created_at=None, summarized=None), Edge(source=4, target=6, description='The surge in pet dog numbers during the pandemic correlates with an increase in dog attacks.', color='blue', created_at=None, summarized=None), Edge(source=7, target=8, description='The commodification of pets is mirrored in the increased expenditure on them.', color='blue', created_at=None, summarized=None), Edge(source=9, target=6, description='Behavioral problems due to modern lifestyle impacts on dogs may contribute to the rise in dog attacks.', color='blue', created_at=None, summarized=None), Edge(source=10, target=8, description='The shift in pet parenting attitudes towards treating pets as child substitutes drives up pet-related spending.', color='blue', created_at=None, summarized=None)]),\n", - " KnowledgeGraph(nodes=[Node(id=1, description='Britons have a notable fondness for keeping pets, particularly dogs which serve as outlets for affection and social interaction.', category='cultural behavior', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='The UK is accommodating to dogs in public spaces, with establishments often welcoming dogs and integrating them into social norms.', category='cultural practice', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='Pet ownership surged during the COVID-19 pandemic, with the number of pet dogs in the UK rising significantly.', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=4, description='The Dogs Trust charity has long advocated for the lifelong commitment to pets, emphasizing that dogs are not just for temporary companionship.', category='organization message', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=5, description='The increase in dog ownership has led to various consequences, including a rise in dog attacks and dogs being listed for rehoming after the pandemic.', category='societal issue', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=6, description='Pets are increasingly treated as commodities or status symbols, leading to ethical concerns and health issues for certain breeds.', category='ethical concern', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=7, description='The humanization of pets is on the rise, with dogs being treated more like human children and less like animals with their own specific needs.', category='behavioral trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=8, description='Consumerism related to pets has grown drastically in the UK, with a significant amount of spending on non-essential pet products and services.', category='economic trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=9, description='There is a disconnect between how people treat their pets and what pets actually need, manifesting in overlooked animal welfare and indulgence in human-like treats.', category='welfare issue', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=10, description='Pets often suffer from behavior problems due to inadequate exercise, social interaction, and consistent routines, which can be mitigated with better pet care practices.', category='animal behavior', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=2, description='The cultural affinity for pets in the UK translates into dog-friendly public spaces and societal norms.', color='blue', created_at=None, summarized=None), Edge(source=3, target=1, description='The COVID-19 pandemic led to a marked increase in pet ownership in the UK, reflecting the cultural behavior of Britons towards pets.', color='blue', created_at=None, summarized=None), Edge(source=4, target=3, description='The Dogs Trust charity message echoes the need for long-term responsibility taken by new pet owners during the pandemic.', color='blue', created_at=None, summarized=None), Edge(source=5, target=3, description='The surge in pet ownership during the pandemic has resulted in societal challenges, including dog attacks and rehoming issues.', color='blue', created_at=None, summarized=None), Edge(source=6, target=7, description='The commodification of pets correlates with the trend of treating them as human substitutes, raising ethical and health concerns.', color='blue', created_at=None, summarized=None), Edge(source=8, target=7, description='Increased pet consumerism is evident in the humanization and indulgence of pets, leading to unnecessary spending on pet trends and products.', color='blue', created_at=None, summarized=None), Edge(source=9, target=8, description='The misalignment between human treatment of pets and their actual needs is mirrored in the increase in consumerism and pet indulgence.', color='blue', created_at=None, summarized=None), Edge(source=10, target=9, description='Behavior problems in pets often arise from the disconnect in pet care, highlighting the need for addressing their true needs and welfare.', color='blue', created_at=None, summarized=None)]),\n", - " KnowledgeGraph(nodes=[Node(id=1, description='Britons have always been a bit silly about animals', category='cultural trait', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='Keeping pets is an entire way of life in England', category='culture', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='Dogs serve as an acceptable outlet for British emotions', category='societal behavior', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=4, description='In the UK, dogs are permitted and encouraged on public transport', category='policy', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=5, description='The number of pet dogs in the UK increased from about nine million to 13 million between 2019 and 2022', category='statistic', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=6, description='Dog attacks in England and Wales rose by over a third between 2018 and 2022', category='statistic', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=7, description='The pandemic led to an increase in dog ownership as people spent more time at home', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=8, description='Pets are being treated as commodities in modern times', category='social issue', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=9, description='Certain dog breeds are chosen as a signifier of masculinity or for their aesthetic appeal', category='trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=10, description='Pets are increasingly treated as substitutes for children in Britain', category='social trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=11, description='The total spend on pets in the UK has more than doubled in the past decade, reaching nearly £10bn last year', category='economic statistic', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=12, description='There is a rise in dog-friendly establishments like restaurants, cinemas, and churches', category='trend', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=13, description='Modern busy schedules lead to dogs suffering daily deprivation and behavioral issues', category='societal issue', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=3, description='reflects', color='blue', created_at=None, summarized=None), Edge(source=2, target=4, description='leads to', color='blue', created_at=None, summarized=None), Edge(source=7, target=5, description='caused', color='blue', created_at=None, summarized=None), Edge(source=8, target=9, description='associated with', color='blue', created_at=None, summarized=None), Edge(source=10, target=11, description='contributes to', color='blue', created_at=None, summarized=None), Edge(source=13, target=6, description='leads to', color='blue', created_at=None, summarized=None), Edge(source=6, target=12, description='in contrast to', color='blue', created_at=None, summarized=None)]),\n", - " KnowledgeGraph(nodes=[Node(id=1, description='Keeping pets is seen as an entire way of life in Britain, with dogs as an acceptable outlet for emotions', category='cultural practice', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=2, description='Dogs in the UK are accommodated in society and considered friends, with allowances in public spaces', category='social norm', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=3, description='The pandemic led to a rise in pet dogs from about 9 million to 13 million between 2019 and 2022', category='event', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=4, description=\"The Dogs Trust charity coined the slogan 'A dog is for life, not just for Christmas' in 1978\", category='campaign', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=5, description='Green spaces have been declining, affecting dog-friendly areas', category='environment change', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=6, description='Dog attacks recorded by police in England and Wales rose by over a third between 2018 and 2022', category='statistic', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=7, description=\"Post-pandemic adjustments lead to increase in dogs being rehomed as they no longer fit owners' lifestyles\", category='social issue', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=8, description=\"Living beings are being downgraded to commodities, influenced by 'designer' breeds in fashion and pets treated as children substitutes\", category='cultural shift', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=9, description='Modern human lifestyles often do not align with the needs of dogs, leading to behavioral problems', category='social problem', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=10, description='Pet spending in the UK reached nearly £10bn with a trend towards nonessential indulgences for pets', category='economic trend', color='blue', memory_type='episodic', created_at=None, summarized=None), Node(id=11, description=\"The rise of pet 'boutiques' and dog-friendly businesses is an indicator of gentrification\", category='social phenomenon', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=12, description='There is a trend of overindulging pets with nonessential items and services', category='social behavior', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=13, description='Dogs have basic needs that are often overshadowed by human projection of indulgences', category='animal welfare', color='blue', memory_type='semantic', created_at=None, summarized=None), Node(id=14, description='Proper pet care requires sacrifices and prioritizing the wellbeing of pets', category='ethical principle', color='blue', memory_type='semantic', created_at=None, summarized=None)], edges=[Edge(source=1, target=2, description='reflects', color='blue', created_at=None, summarized=None), Edge(source=2, target=3, description='facilitated the increase in', color='blue', created_at=None, summarized=None), Edge(source=3, target=6, description='contributed to the', color='blue', created_at=None, summarized=None), Edge(source=8, target=10, description='leads to growth in', color='blue', created_at=None, summarized=None), Edge(source=9, target=7, description='resulting in', color='blue', created_at=None, summarized=None), Edge(source=12, target=10, description='drives', color='blue', created_at=None, summarized=None), Edge(source=14, target=13, description='based on understanding', color='blue', created_at=None, summarized=None)])]" - ] - }, - "execution_count": 268, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [] }, { @@ -900,35 +877,51 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 50, "id": "4dab2ff0-0d12-4a00-a4e4-fb901e701bd3", "metadata": {}, - "outputs": [], - "source": [ - "B = create_user_content_graph(user_id, custom_user_properties, transformed_dict_2, existing_graph=G)" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "id": "627d42fd-d2ce-4ccd-a2a1-2f7ac2f463cf", - "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "MultiDiGraph with 15 nodes and 14 edges\n" + "ename": "NameError", + "evalue": "name 'create_user_content_graph' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[50], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m B \u001b[38;5;241m=\u001b[39m \u001b[43mcreate_user_content_graph\u001b[49m(user_id, custom_user_properties, transformed_dict_2, existing_graph\u001b[38;5;241m=\u001b[39mG)\n", + "\u001b[0;31mNameError\u001b[0m: name 'create_user_content_graph' is not defined" ] } ], "source": [ - "print(B)" + "# B = create_user_content_graph(user_id, custom_user_properties, transformed_dict_2, existing_graph=G)" ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 48, + "id": "627d42fd-d2ce-4ccd-a2a1-2f7ac2f463cf", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'B' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[48], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mB\u001b[49m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'B' is not defined" + ] + } + ], + "source": [ + "# print(B)" + ] + }, + { + "cell_type": "code", + "execution_count": 53, "id": "512f15be-0114-4c8c-9754-e82f2fa16344", "metadata": {}, "outputs": [ @@ -936,7 +929,7 @@ "data": { "text/html": [ "\n", - "