Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Python client for searching, publishing and modifying nanopublications.

License

NotificationsYou must be signed in to change notification settings

Nanopublication/nanopub-py

Repository files navigation

nanopubTests and update docsPublish to PyPICoverage StatusPyPI versionCII Best Practicesfair-software.euDOI

nanopub

Thenanopub library provides a high-level, user-friendly python interface for searching, publishing and retracting nanopublications.

Nanopublications are a formalized and machine-readable way of communicating the smallest possible units of publishable information. Seethe documentation for more information.

Documentation

Checkout theuser documentation 📖

Setup

Install using pip:

pip install nanopub

To publish to the nanopub server you need to setup your profile. This allows the nanopub server to identify you. Run the following command in the terminal:

np setup

This will ask you a few questions, then it will use that information to add and store RSA keys to sign your nanopublications with, (optionally) publish a nanopublication with your name and ORCID iD to declare that you are using these RSA keys, and store your ORCID iD to automatically add as author to the provenance of any nanopublication you will publish using this library.

Quick Start

Publishing nanopublications

fromrdflibimportGraphfromnanopubimportNanopub,NanopubConf,load_profile# 1. Create the confignp_conf=NanopubConf(use_test_server=True,profile=load_profile(),# Loads the user profile that was created with `np setup`add_prov_generated_time=True,attribute_publication_to_profile=True,)# 2. Construct a desired assertion (a graph of RDF triples) using rdflibmy_assertion=Graph()my_assertion.add((rdflib.URIRef('www.example.org/timbernerslee'),rdflib.RDF.type,rdflib.FOAF.Person))# 2. Make a Nanopub object with this assertionnp=Nanopub(conf=np_conf,assertion=my_assertion)# 3. Publish the Nanopub objectnp.publish()print(np)

Searching for nanopublications

fromnanopubimportNanopubClient# Search for all nanopublications containing the text 'fair'client=NanopubClient()results=client.find_nanopubs_with_text('fair')print(results)

Fetching nanopublications and inspecting them

# Fetch the nanopublication at the specified URIpublication=client.fetch('http://purl.org/np/RApJG4fwj0szOMBMiYGmYvd5MCtRle6VbwkMJUb1SxxDM')# Print the RDF contents of the nanopublicationprint(publication)# Iterate through all triples in the assertion graphfors,p,oinpublication.assertion:print(s,p,o)

Development

See thedevelopment page on the documentation website.


[8]ページ先頭

©2009-2025 Movatter.jp