api-python icon indicating copy to clipboard operation
api-python copied to clipboard

[API v1.0.0 Feedback] Consider adding more information to `get_triples`

Open antaresc opened this issue 6 years ago • 1 comments

Currently, datacommons.get_triples returns a list of 3-tuples like so.

('geoId/sch069112212709', 'schoolDistrict', 'geoId/sch0691122')
('geoId/sch069112210678', 'schoolDistrict', 'geoId/sch0691122')
('geoId/sch069112209271', 'schoolDistrict', 'geoId/sch0691122')
('geoId/sch069112206289', 'schoolDistrict', 'geoId/sch0691122')

Perhaps we can consider returning more information about the subject and object node such as:

  • The name
  • Whether or not the node is a reference
  • The type

antaresc avatar Aug 14 '19 20:08 antaresc

Potentially we can return the following format from get_triples:

Imagine calling get_triples(['geoId/06']) returns two triples: ('geoId/06', 'name', 'California') and ('geoId/06', 'containedInPlace', 'country/USA'). 

A potential format could be the following dictionary

{
    "geoId/06": [
        {
            "subject_id": "geoId/06",
            "property": "name",
            "object_value": "California" # To denote a non-reference node
        },
        {
            "subject_id": "geoId/06",
            "property": "containedInPlace",
            "object_id": "country/USA" # To denote a reference node
        }
    ]
}

Another format could be

{
    "geoId/06": [
        ("geoId/06", "name", "California", None), # Index 2 and 3 are reserved for the object node. 2 exists if it is a non-reference node.
        ("geoId/06", "containedInPlace", None, "country/USA") # 3 exists if it is a reference node
    ]
}

antaresc avatar Aug 15 '19 00:08 antaresc