|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "28cb6338-0997-46f9-bf71-31ccfc71a976", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Disambiguate Triple\n", |
| 9 | + "\n", |
| 10 | + "Here is a short guide to disambiguating triples on the Golden protocol. Disambiguating triples is a core step in the data submission process. Before submitting any triples, you should disambiguate against any pre-existing triples that are similar if not identical to what you are submitting. This prevents duplicates from being submitted." |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "markdown", |
| 15 | + "id": "f7598da8-46d9-421e-a861-60e88c42c42a", |
| 16 | + "metadata": {}, |
| 17 | + "source": [ |
| 18 | + "## Prerequisite\n", |
| 19 | + "\n", |
| 20 | + "[Authentication](https://docs.golden.xyz/guides/authentication)\n", |
| 21 | + "\n", |
| 22 | + "[Godel Authentication](https://docs.golden.xyz/godel-python-sdk/authentication)" |
| 23 | + ] |
| 24 | + }, |
| 25 | + { |
| 26 | + "cell_type": "markdown", |
| 27 | + "id": "bee98a0e-31e7-40cc-88ab-5164413c17dc", |
| 28 | + "metadata": {}, |
| 29 | + "source": [ |
| 30 | + "### 1. Connect to Golden Web3 API\n", |
| 31 | + "\n", |
| 32 | + "Let's connect the python wrapper to the Golden GraphQL API.\n", |
| 33 | + "\n", |
| 34 | + "Make sure you ran through the prerequisites for this guide and have learned to authenticate and retrieve your JWT token in Godel." |
| 35 | + ] |
| 36 | + }, |
| 37 | + { |
| 38 | + "cell_type": "code", |
| 39 | + "execution_count": 1, |
| 40 | + "id": "1311f6af-03c5-4067-9bf1-c1667813e611", |
| 41 | + "metadata": {}, |
| 42 | + "outputs": [], |
| 43 | + "source": [ |
| 44 | + "from godel import GoldenAPI\n", |
| 45 | + "\n", |
| 46 | + "JWT_TOKEN = \"ey098sd908v79899789877986567967845jh567hj5679568df678678daf6786789s569ghm567457hm8g567n8678fb8790678sd56756n456h8d4f5gn865648\"\n", |
| 47 | + "JWT_TOKEN = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMHhkODZiNTM0QzAyOUFhZjg0MjcyYTNjNzI1Rjk0MDhlMDNERUY0YjgwIiwicm9sZSI6InVzZXJfcm9sZSIsImF1ZCI6InBvc3RncmFwaGlsZSIsImlhdCI6MTY2NjIxODM1NX0.TdXheV61u-yYTTcl2Pcp945dUWxMxuDMXeN8v6A9P8o\"\n", |
| 48 | + "goldapi = GoldenAPI(jwt_token=JWT_TOKEN)" |
| 49 | + ] |
| 50 | + }, |
| 51 | + { |
| 52 | + "cell_type": "markdown", |
| 53 | + "id": "5b3ee311-36e2-4ebf-9b99-e6a01ffe0df6", |
| 54 | + "metadata": {}, |
| 55 | + "source": [ |
| 56 | + "### 2. Disambiguate triple\n", |
| 57 | + "\n", |
| 58 | + "In order to disambiguate a triple, you'll need a specify a the predicate and object value or entityID you'd like to add to your own subject." |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "code", |
| 63 | + "execution_count": 2, |
| 64 | + "id": "f994e866-764f-467c-813c-cb533493bc32", |
| 65 | + "metadata": {}, |
| 66 | + "outputs": [], |
| 67 | + "source": [ |
| 68 | + "predicate = \"Website\"\n", |
| 69 | + "object = \"https://golden.com\"" |
| 70 | + ] |
| 71 | + }, |
| 72 | + { |
| 73 | + "cell_type": "code", |
| 74 | + "execution_count": 3, |
| 75 | + "id": "115e6fa1-0261-4811-87dd-f6fb266a87ab", |
| 76 | + "metadata": {}, |
| 77 | + "outputs": [], |
| 78 | + "source": [ |
| 79 | + "# Get disambiguated triple\n", |
| 80 | + "data = goldapi.disambiguate_triples(\n", |
| 81 | + " predicate=predicate,\n", |
| 82 | + " object=object,\n", |
| 83 | + " validation_status=\"ACCEPTED\"\n", |
| 84 | + ")" |
| 85 | + ] |
| 86 | + }, |
| 87 | + { |
| 88 | + "cell_type": "code", |
| 89 | + "execution_count": 4, |
| 90 | + "id": "36bb6806-b858-4c5c-abca-1570a41bede9", |
| 91 | + "metadata": {}, |
| 92 | + "outputs": [ |
| 93 | + { |
| 94 | + "data": { |
| 95 | + "text/plain": [ |
| 96 | + "{'data': {'disambiguateTriples': {'errors': None,\n", |
| 97 | + " 'entities': [{'distance': 0,\n", |
| 98 | + " 'id': '07c8ce4d-a5db-44af-9ffe-2ea137725488',\n", |
| 99 | + " 'reputation': 0},\n", |
| 100 | + " {'distance': 0,\n", |
| 101 | + " 'id': '88e5cf8e-c0bf-4e11-addf-27d54260a93e',\n", |
| 102 | + " 'reputation': 0},\n", |
| 103 | + " {'distance': 0,\n", |
| 104 | + " 'id': '378b1487-041e-4c1c-8c21-9cbf359d2d61',\n", |
| 105 | + " 'reputation': 0},\n", |
| 106 | + " {'distance': 0,\n", |
| 107 | + " 'id': '2e05170c-b044-4d4d-90a1-bca3769a7c9e',\n", |
| 108 | + " 'reputation': 0},\n", |
| 109 | + " {'distance': 0,\n", |
| 110 | + " 'id': '5c0d11ad-b6e7-4d08-a0f1-6a224d93f3a1',\n", |
| 111 | + " 'reputation': 0}]}}}" |
| 112 | + ] |
| 113 | + }, |
| 114 | + "execution_count": 4, |
| 115 | + "metadata": {}, |
| 116 | + "output_type": "execute_result" |
| 117 | + } |
| 118 | + ], |
| 119 | + "source": [ |
| 120 | + "data" |
| 121 | + ] |
| 122 | + } |
| 123 | + ], |
| 124 | + "metadata": { |
| 125 | + "kernelspec": { |
| 126 | + "display_name": "Python 3 (ipykernel)", |
| 127 | + "language": "python", |
| 128 | + "name": "python3" |
| 129 | + }, |
| 130 | + "language_info": { |
| 131 | + "codemirror_mode": { |
| 132 | + "name": "ipython", |
| 133 | + "version": 3 |
| 134 | + }, |
| 135 | + "file_extension": ".py", |
| 136 | + "mimetype": "text/x-python", |
| 137 | + "name": "python", |
| 138 | + "nbconvert_exporter": "python", |
| 139 | + "pygments_lexer": "ipython3", |
| 140 | + "version": "3.9.5" |
| 141 | + } |
| 142 | + }, |
| 143 | + "nbformat": 4, |
| 144 | + "nbformat_minor": 5 |
| 145 | +} |
0 commit comments