Skip to content

Commit e2528d1

Browse files
committed
Update docs
1 parent 957ca5f commit e2528d1

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
Converter with Preprocessing
22
============================
33

4-
When simple expansion and contraction aren't enough, and you want to
5-
inject global or context-specific rewrite rules, you can wrap a :class:`curies.Converter`
6-
and preprocessing rules encoded in an instance of :class:`curies.PreprocessingRules` inside
4+
When simple expansion and contraction aren't enough, and you want to inject global or
5+
context-specific rewrite rules, you can wrap a :class:`curies.Converter` and
6+
preprocessing rules encoded in an instance of :class:`curies.PreprocessingRules` inside
77
a :class:`curies.PreprocessingConverter`.
88

9+
For example, you always want to fix legacy references to the ``OBO_REL`` namespace:
10+
11+
.. code-block:: python
12+
13+
import curies
14+
from curies import PreprocessingRules, PreprocessingConverter
15+
from curies.wrapped import Rewrites
16+
17+
rules = PreprocessingRules(
18+
rewrites=Rewrites(
19+
full={"OBO_REL:is_a": "rdfs:subClassOf"}
20+
)
21+
)
22+
23+
converter = curies.get_obo_converter()
24+
converter = PreprocessingConverter.from_converter(
25+
converter, rules=rules
26+
)
27+
28+
>>> converter.parse_curie("OBO_REL:is_a")
29+
ReferenceTuple('rdfs', 'subClassOf')

src/curies/mapping_service/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@
8787
8888
import requests
8989
90-
sparql = '''
90+
sparql = """
9191
SELECT ?s ?o WHERE {
9292
VALUES ?s { <http://purl.obolibrary.org/obo/CHEBI_2> }
9393
?s owl:sameAs ?o
9494
}
95-
'''
95+
"""
9696
res = requests.get("http://localhost:8764/sparql", params={"query": sparql})
9797
9898
Test a request using a service, e.g. with :meth:`rdflib.Graph.query`

src/curies/wrapped.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def __init__(
191191
192192
:param args: Positional arguments passed to :func:`Converter.__init__`
193193
:param rules: A set of rules
194-
:param reference_cls: The reference class to use. Defaults to :class:`curies.Reference`.
194+
:param reference_cls: The reference class to use. Defaults to
195+
:class:`curies.Reference`.
195196
:param kwargs: Keyword arguments passed to :func:`Converter.__init__`
196197
"""
197198
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)