GIG Python Library

Installation

Prerequisites

The Python package is only a wrapper to the GIG Server which is originally built using Golang. You require a running GIG server to interface with the Python library. Check https://github.com/LDFLK/GIG for more information on how to initiate a GIG server locally. Also having some data populated using the crawlers might come in handy when testing the functions we are explaining below.

Initialization

Once you have the GIG server up and running use the following code snippet to import and initiate the server connection. Change the server URL accordingly.

from gig-python import Server as GIG_Server
from gig-python import Entity

server = GIG_Server("http://localhost:9000/")

API Functions

Next will see how we can use the functionality of our Python package. The library provides a rich set of functions to interface with the GIG server easily.

entity = server.get("Sri Lanka")
entities = server.search("sri lanka", attributes_list=["title"])
results = server.normalize_name("sri lanka")
results = server.normalize_location("colombo")
entities = server.get_links("Person A")
entities = server.get_relations("Sri Lanka")
entity = Entity()
entity.title = "LDF Test Entity"
result = server.add(entity)
entity = Entity()
entity.title = "LDF Batch"
result = server.add_all([entity])
entity = Entity()
entity.title = "LDF Test Entity"
entity.source_date = "2021-01-02T15:04:05-07:00"
entity.source = "python-lib"
result = server.terminate(entity)

References

  1. https://github.com/LDFLK/gig-python
  2. https://pypi.org/project/gig-python/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store