File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11Converter 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
77a :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' )
Original file line number Diff line number Diff line change 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
9898Test a request using a service, e.g. with :meth:`rdflib.Graph.query`
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments