|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "fdfa1e8f", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "import sys, os\n", |
| 11 | + "cwd = os.getcwd()\n", |
| 12 | + "frameworkDir = os.path.abspath(os.path.join(cwd, os.pardir, os.pardir))\n", |
| 13 | + "sys.path.append(frameworkDir)\n", |
| 14 | + "\n", |
| 15 | + "import pandas as pd\n", |
| 16 | + "\n", |
| 17 | + "from dackar.knowledge_graph.KGconstruction import KG" |
| 18 | + ] |
| 19 | + }, |
| 20 | + { |
| 21 | + "cell_type": "code", |
| 22 | + "execution_count": null, |
| 23 | + "id": "69114812", |
| 24 | + "metadata": {}, |
| 25 | + "outputs": [], |
| 26 | + "source": [ |
| 27 | + "cause_dict= {'A': ['alpha','beta','gamma'], \n", |
| 28 | + " 'B': [1.,2.,3.]}\n", |
| 29 | + "cause_df = pd.DataFrame(cause_dict)" |
| 30 | + ] |
| 31 | + }, |
| 32 | + { |
| 33 | + "cell_type": "code", |
| 34 | + "execution_count": null, |
| 35 | + "id": "fe9186d3", |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [], |
| 38 | + "source": [ |
| 39 | + "config_file_path = '/Users/mandd/Library/Application Support/Neo4j Desktop/Application/relate-data/dbmss/dbms-666d9aa2-b0c5-4903-9f08-1cad30136945/conf/neo4j.conf'\n", |
| 40 | + "uri = \"bolt://localhost:7687\"\n", |
| 41 | + "pwd = \"123456789\"\n", |
| 42 | + "user='neo4j'\n", |
| 43 | + "\n", |
| 44 | + "knowledgeGraph = KG(config_file_path, uri, pwd, user)\n", |
| 45 | + "\n", |
| 46 | + "knowledgeGraph.resetGraph()" |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "execution_count": null, |
| 52 | + "id": "e4f8adfe", |
| 53 | + "metadata": {}, |
| 54 | + "outputs": [], |
| 55 | + "source": [ |
| 56 | + "knowledgeGraph.importGraphSchema('condition_report','schemas/conditionReportSchema.toml')" |
| 57 | + ] |
| 58 | + }, |
| 59 | + { |
| 60 | + "cell_type": "code", |
| 61 | + "execution_count": null, |
| 62 | + "id": "12cd86d0", |
| 63 | + "metadata": {}, |
| 64 | + "outputs": [], |
| 65 | + "source": [ |
| 66 | + "nodeConstSchemaCause = {'cause': {'prop1': 'A', 'prop2': 'B'}}\n", |
| 67 | + "constSchemaCause = {'nodes': nodeConstSchemaCause}\n", |
| 68 | + "\n", |
| 69 | + "knowledgeGraph.genericWorkflow(cause_df, constSchemaCause)" |
| 70 | + ] |
| 71 | + }, |
| 72 | + { |
| 73 | + "cell_type": "code", |
| 74 | + "execution_count": null, |
| 75 | + "id": "2ff8376c", |
| 76 | + "metadata": {}, |
| 77 | + "outputs": [], |
| 78 | + "source": [ |
| 79 | + "conseq_dict = {'C': ['x','y','z'], \n", |
| 80 | + " 'D': [1.1,1.2,1.3],\n", |
| 81 | + " 'prop_rel': [2.1,2.2,2.3],\n", |
| 82 | + " 'A': ['alpha','beta','gamma']} # link to cause\n", |
| 83 | + "conseq_df = pd.DataFrame(conseq_dict)\n", |
| 84 | + "\n", |
| 85 | + "nodeConstSchemaConseq = {'consequence': {'ID_A': 'C', 'ID_B': 'D'}}\n", |
| 86 | + "relConstSchemaConseq = [{'source': {'cause.prop1':'A'},\n", |
| 87 | + " 'target': {'consequence.ID_A':'C'},\n", |
| 88 | + " 'type' : 'causality',\n", |
| 89 | + " 'properties': {'amplitude': 'prop_rel'}}] \n", |
| 90 | + "\n", |
| 91 | + "constSchemaConseq= {'nodes' : nodeConstSchemaConseq,\n", |
| 92 | + " 'relations': relConstSchemaConseq}\n", |
| 93 | + "\n", |
| 94 | + "knowledgeGraph.genericWorkflow(conseq_df, constSchemaConseq)" |
| 95 | + ] |
| 96 | + }, |
| 97 | + { |
| 98 | + "cell_type": "code", |
| 99 | + "execution_count": null, |
| 100 | + "id": "128e96b8", |
| 101 | + "metadata": {}, |
| 102 | + "outputs": [], |
| 103 | + "source": [ |
| 104 | + "node_properties=[{'name': 'date', 'type': 'string', 'optional': False},\n", |
| 105 | + " {'name': 'ID', 'type': 'string', 'optional': False}]\n", |
| 106 | + "\n", |
| 107 | + "df = pd.DataFrame(node_properties)\n", |
| 108 | + "df" |
| 109 | + ] |
| 110 | + } |
| 111 | + ], |
| 112 | + "metadata": { |
| 113 | + "kernelspec": { |
| 114 | + "display_name": "dackar_libs", |
| 115 | + "language": "python", |
| 116 | + "name": "python3" |
| 117 | + }, |
| 118 | + "language_info": { |
| 119 | + "codemirror_mode": { |
| 120 | + "name": "ipython", |
| 121 | + "version": 3 |
| 122 | + }, |
| 123 | + "file_extension": ".py", |
| 124 | + "mimetype": "text/x-python", |
| 125 | + "name": "python", |
| 126 | + "nbconvert_exporter": "python", |
| 127 | + "pygments_lexer": "ipython3", |
| 128 | + "version": "3.11.8" |
| 129 | + } |
| 130 | + }, |
| 131 | + "nbformat": 4, |
| 132 | + "nbformat_minor": 5 |
| 133 | +} |
0 commit comments