idloc


Nameidloc JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryGet JSON-LD for a Library of Congress name or subject authority.
upload_time2024-02-14 16:24:31
maintainer
docs_urlNone
authorEd Summers
requires_python>=3.8,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # idloc 

[![Build Status](https://github.com/edsu/idloc/actions/workflows/test.yml/badge.svg)](https://github.com/edsu/idloc/actions/workflows/test.yml)


*idloc* is a command line utility and small function library for getting JSON-LD from the Library of Congress Linked Data service at https://id.loc.gov.

Ideally *idloc* would not be needed at all because you could just use [curl](https://curl.se/) or whatever HTTP library you want to fetch the JSON-LD directly. But at the moment the JSON-LD that is returned, while valid, isn't exactly usable and needs to be [framed](https://www.w3.org/TR/json-ld11-framing/). *idloc* uses [pyld] internally to do the framing that makes the JSON usable by someone who just wants to use the data as JSON without the cognitive overhead of using RDF processing tools.

## Install

This will install *idloc* and its dependencies:

```bash
pip install idloc
```

## CLI

Once installed you should also have a *idloc* command line utility available. There are four commands get, lucky, search, concept-schemes.

### Get

Get will fetch the id.loc.gov entity by URI and print out the framed JSON-LD:

```bash
$ idloc get https://id.loc.gov/authorities/subjects/sh2002000569
```

To see the output of this command see [this file](examples/sh2002000569.json) since it's really too long to include inline here in the docs.

Compare that to the JSON that is being made available at https://id.loc.gov/authorities/subjects/sh85021262.json and you will probably see why *framing* the JSON-LD is currently needed if you want to work with the data as JSON.

### Lucky

If you want to roll the dice and see the JSON-LD for first entity that matches a given string:

```
$ idloc lucky "Semantic Web"
```

If you want to limit to particular concept schemes like `subject-headings` you can:

```
$idloc lucky --concept-scheme subject-headings "Semantic Web"
```

### Search

You can search for entities:

```
$ idloc search "Semantic Web" --limit 5

International Semantic Web Conference (6th : 2007 : Pusan, Korea) Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings
<http://id.loc.gov/resources/works/15024802>

International Semantic Web Conference (6th : 2007 : Pusan, Korea) The Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings Berlin ; New York : Springer, 2007.
<http://id.loc.gov/resources/instances/15024802>

IFIP WG 12.5 Working Conference on Industrial Applications of Semantic Web (1st : 2005 : Jyväskylä, Finland) Industrial applications of semantic Web : proceedings of the 1st IFIP WG12.5 Working Conference on Industrial Applications of Semantic Web, August 25-27, 2005, Jyväskylä, Finland New York : Springer, c2005.
<http://id.loc.gov/resources/instances/14054943>

International Semantic Web Conference (1st : 2002 : Sardinia, Italy) semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings
<http://id.loc.gov/resources/works/12761651>

International Semantic Web Conference (1st : 2002 : Sardinia, Italy) The semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings Berlin ; New York : Springer, c2002.
<http://id.loc.gov/resources/instances/12761651>
```

Notice how the top 5 were taken up with bibframe instances? Similar to `get` you can limit a search to one or more concept schemes. For example if we want to search for "Semantic Web" only in the `subject-headings` and `name-authority` concept schemes:

```
$ idloc search --concept-scheme subject-headings --concept-scheme name-authority "Semantic Web" 
```

### Concept Schemes

You may be wondering what concept schemes are available. To see a list of them:

```
$ idloc concept-schemes
```

## Use as a Library

The idloc Python library can be used in your Python programs.


### Get

You can get the JSON-LD for a given id.loc.gov URI:

```
import idloc

concept = idloc.get('http://id.loc.gov/authorities/subjects/sh2002000569')
```

### Search

You can search for entities:

```python
for result in idloc.search('Semantic Web'):
    print(result['name'], result['uri']
```

Similarly you can limit to particular concept schemes:

```python
for result in idloc.search('Semantic Web', concept_schemes=['subject-headings', 'name-authority']):
    print(result['name'], result['uri'])
```

By default you get the first 20 results, but you can use the `limit` parameter to get more. If you set `limit` to `0` it will page through all the results.

### Concept Schemes

A mapping of concept scheme names and their corresponding URIs is available in:

```python
idloc.CONCEPT_SCHEMES
```

There are 130 of them! There is also a function `idloc.concept_schemes()` which will scrape the search interface at https://id.loc.gov/search to determine what the latest group of concept schemes is.

[pyld]: https://github.com/digitalbazaar/pyld

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "idloc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ed Summers",
    "author_email": "ehs@pobox.com",
    "download_url": "https://files.pythonhosted.org/packages/c3/d4/c5bdfee2aea42239e3dcc228ebcac79ebffc3e85787f8b087fbfe55ef74a/idloc-0.1.0.tar.gz",
    "platform": null,
    "description": "# idloc \n\n[![Build Status](https://github.com/edsu/idloc/actions/workflows/test.yml/badge.svg)](https://github.com/edsu/idloc/actions/workflows/test.yml)\n\n\n*idloc* is a command line utility and small function library for getting JSON-LD from the Library of Congress Linked Data service at https://id.loc.gov.\n\nIdeally *idloc* would not be needed at all because you could just use [curl](https://curl.se/) or whatever HTTP library you want to fetch the JSON-LD directly. But at the moment the JSON-LD that is returned, while valid, isn't exactly usable and needs to be [framed](https://www.w3.org/TR/json-ld11-framing/). *idloc* uses [pyld] internally to do the framing that makes the JSON usable by someone who just wants to use the data as JSON without the cognitive overhead of using RDF processing tools.\n\n## Install\n\nThis will install *idloc* and its dependencies:\n\n```bash\npip install idloc\n```\n\n## CLI\n\nOnce installed you should also have a *idloc* command line utility available. There are four commands get, lucky, search, concept-schemes.\n\n### Get\n\nGet will fetch the id.loc.gov entity by URI and print out the framed JSON-LD:\n\n```bash\n$ idloc get https://id.loc.gov/authorities/subjects/sh2002000569\n```\n\nTo see the output of this command see [this file](examples/sh2002000569.json) since it's really too long to include inline here in the docs.\n\nCompare that to the JSON that is being made available at https://id.loc.gov/authorities/subjects/sh85021262.json and you will probably see why *framing* the JSON-LD is currently needed if you want to work with the data as JSON.\n\n### Lucky\n\nIf you want to roll the dice and see the JSON-LD for first entity that matches a given string:\n\n```\n$ idloc lucky \"Semantic Web\"\n```\n\nIf you want to limit to particular concept schemes like `subject-headings` you can:\n\n```\n$idloc lucky --concept-scheme subject-headings \"Semantic Web\"\n```\n\n### Search\n\nYou can search for entities:\n\n```\n$ idloc search \"Semantic Web\" --limit 5\n\nInternational Semantic Web Conference (6th : 2007 : Pusan, Korea) Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings\n<http://id.loc.gov/resources/works/15024802>\n\nInternational Semantic Web Conference (6th : 2007 : Pusan, Korea) The Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings Berlin ; New York : Springer, 2007.\n<http://id.loc.gov/resources/instances/15024802>\n\nIFIP WG 12.5 Working Conference on Industrial Applications of Semantic Web (1st : 2005 : Jyv\u00e4skyl\u00e4, Finland) Industrial applications of semantic Web : proceedings of the 1st IFIP WG12.5 Working Conference on Industrial Applications of Semantic Web, August 25-27, 2005, Jyv\u00e4skyl\u00e4, Finland New York : Springer, c2005.\n<http://id.loc.gov/resources/instances/14054943>\n\nInternational Semantic Web Conference (1st : 2002 : Sardinia, Italy) semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings\n<http://id.loc.gov/resources/works/12761651>\n\nInternational Semantic Web Conference (1st : 2002 : Sardinia, Italy) The semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings Berlin ; New York : Springer, c2002.\n<http://id.loc.gov/resources/instances/12761651>\n```\n\nNotice how the top 5 were taken up with bibframe instances? Similar to `get` you can limit a search to one or more concept schemes. For example if we want to search for \"Semantic Web\" only in the `subject-headings` and `name-authority` concept schemes:\n\n```\n$ idloc search --concept-scheme subject-headings --concept-scheme name-authority \"Semantic Web\" \n```\n\n### Concept Schemes\n\nYou may be wondering what concept schemes are available. To see a list of them:\n\n```\n$ idloc concept-schemes\n```\n\n## Use as a Library\n\nThe idloc Python library can be used in your Python programs.\n\n\n### Get\n\nYou can get the JSON-LD for a given id.loc.gov URI:\n\n```\nimport idloc\n\nconcept = idloc.get('http://id.loc.gov/authorities/subjects/sh2002000569')\n```\n\n### Search\n\nYou can search for entities:\n\n```python\nfor result in idloc.search('Semantic Web'):\n    print(result['name'], result['uri']\n```\n\nSimilarly you can limit to particular concept schemes:\n\n```python\nfor result in idloc.search('Semantic Web', concept_schemes=['subject-headings', 'name-authority']):\n    print(result['name'], result['uri'])\n```\n\nBy default you get the first 20 results, but you can use the `limit` parameter to get more. If you set `limit` to `0` it will page through all the results.\n\n### Concept Schemes\n\nA mapping of concept scheme names and their corresponding URIs is available in:\n\n```python\nidloc.CONCEPT_SCHEMES\n```\n\nThere are 130 of them! There is also a function `idloc.concept_schemes()` which will scrape the search interface at https://id.loc.gov/search to determine what the latest group of concept schemes is.\n\n[pyld]: https://github.com/digitalbazaar/pyld\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Get JSON-LD for a Library of Congress name or subject authority.",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f694891408f09712c90901203cb3fa4671cd634247a001c73a155f544e141764",
                "md5": "8806c1213b8f1b844280793f46cd42ff",
                "sha256": "d5b5ba41c27c9d2f9c5704b117ab7f92d29d9fd1dc8f583976fa22aef1238b68"
            },
            "downloads": -1,
            "filename": "idloc-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8806c1213b8f1b844280793f46cd42ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 8373,
            "upload_time": "2024-02-14T16:24:26",
            "upload_time_iso_8601": "2024-02-14T16:24:26.975606Z",
            "url": "https://files.pythonhosted.org/packages/f6/94/891408f09712c90901203cb3fa4671cd634247a001c73a155f544e141764/idloc-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3d4c5bdfee2aea42239e3dcc228ebcac79ebffc3e85787f8b087fbfe55ef74a",
                "md5": "ae4e6e2ea5f20aaefb45c03d6626f574",
                "sha256": "5a95258f5505c140a74932060d2165a388891257529bbad657cbbbf84c258b42"
            },
            "downloads": -1,
            "filename": "idloc-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ae4e6e2ea5f20aaefb45c03d6626f574",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 7591,
            "upload_time": "2024-02-14T16:24:31",
            "upload_time_iso_8601": "2024-02-14T16:24:31.986680Z",
            "url": "https://files.pythonhosted.org/packages/c3/d4/c5bdfee2aea42239e3dcc228ebcac79ebffc3e85787f8b087fbfe55ef74a/idloc-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-14 16:24:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "idloc"
}
        
Elapsed time: 0.20411s