<commit_before>from IPython import embed
import rdflib
from pyontutils.core import OntId, OntCuries
from pyontutils.core import simpleOnt, oc, oc_, odp, oop, olit, oec, olist
from pyontutils.core import POCombinator, _POCombinator, ObjectCombinator, propertyChainAxiom, Combinator, Restriction2, EquivalentClass
from pyontutils.core import restriction, restrictions
from pyontutils.core import NIFTTL, NIFRID, ilxtr, BFO
from pyontutils.core import definition, hasRole, hasParticipant, hasPart, hasInput, hasOutput, makeNamespaces, participatesIn, partOf, intersectionOf
from pyontutils.core import owl, rdf, rdfs

import rdflib
from pyontutils.core import propertyChainAxiom as pca
class mGraph(rdflib.Graph):
    def __init__(self, *args, filename='/tmp/test.ttl', **kwargs):
        super().__init__(*args, **kwargs)
        self.filename = filename
    def write(self):
        with open(self.filename, 'wb') as f:
            f.write(self.serialize(format='nifttl'))
collector = mGraph(filename='property-chains.ttl')
def _propertyChainAxiom(*args):
    class Derp(Combinator):
        def __init__(self):
            pass
        def __call__(self, *argsi):
            [collector.add(_) for _ in pca(*args)(*argsi)]
            yield ilxtr.a, ilxtr.b, ilxtr.c
    return Derp()

restN = Restriction2(None, owl.onProperty, owl.someValuesFrom)
restG = POCombinator(rdf.type, owl.Restriction).full_combinator
axiom = POCombinator(rdf.type, owl.Axiom)
blankc = POCombinator
equivalentClassC = POCombinator(owl.equivalentClass, ObjectCombinator).full_combinator
oECN = EquivalentClass(None)
owlClass = oc_
owlClassC = oc_.full_combinator
subClassOf = POCombinator(rdfs.subClassOf, ObjectCombinator).full_combinator
oop_ = POCombinator(rdf.type, owl.ObjectProperty)

def _t(subject, label, *rests, def_=None, synonyms=tuple(), comment=None,
       equivalentClass=oec):
    members = tuple()
    _rests = tuple()
    for rest in rests:
        if isinstance(rest, tuple):
            if len(rest) == 2:
                _rests += rest,
            else:
                raise ValueError(f'length of {rest} is not 2!')
        elif isinstance(rest, Combinator):
            members += rest,
        else:
            members += rest,

    rests = _rests
    if not members:
        members = ilxtr.technique,

    yield from oc(subject)
    yield from equivalentClass.serialize(subject, *members, *restrictions(*rests))
    yield from olit(subject, rdfs.label, label)
    if def_:
        yield from olit(subject, definition, def_)

    if synonyms:
        if not isinstance(synonyms, tuple):
            # this is why python sucks and racket is awesome if this was racket
            # the error would show up on the line where the problem was :/
            raise TypeError(f'Type of {synonyms!r} should not be {type(synonyms)}!')
        yield from olit(subject, NIFRID.synonyms, *synonyms)

    if comment:
        yield olit(subject, rdfs.comment, comment)

prot = rdflib.Namespace(ilxtr[''] + 'protocol/')
tech = rdflib.Namespace(ilxtr[''] + 'technique/')
asp = rdflib.Namespace(ilxtr[''] + 'aspect/')

obo, RO, *_ = makeNamespaces('obo', 'RO')
filename = 'methods-core'
prefixes = ('BFO', 'ilxtr', 'NIFRID', 'RO', 'IAO', 'definition', 'hasParticipant')
OntCuries['HBP_MEM'] = 'http://www.hbp.FIXME.org/hbp_measurement_methods/'
imports = NIFTTL['nif_backend.ttl'],
#imports = obo['bfo.owl'], obo['ro.owl']
#imports = tuple()
comment = 'The core components for modelling techniques and methods.'
branch = 'methods'
_repo = True
debug = True

triples = (
    # object properties
    oop(ilxtr.hasOperationDefinition),
    oop(ilxtr.hasDefiningProtocol, ilxtr.hasOperationDefinition),

    oop(ilxtr.hasExecutor, hasParticipant),
    olit(ilxtr.hasExecutor, rdfs.label, 'has executor'),
    olit(ilxtr.hasExecutor, NIFRID.synonym, 'has executing agent'),
    olit(ilxtr.hasExecutor, definition,
         'The relationship between a technique and a thing that executes it.'),
    olit(ilxtr.hasExecutor, rdfs.comment,
         ('For example, a scientific protocol hasExecutor some graduateStudent.'
          'A case like some parallelProcess hasExecutor personA, personB suggests'
          'that the technique is a composite technique and should be broken down.'<commit_msg>methods core fixed olit issue, was using yield instead of yield from<commit_after>from IPython import embed
import rdflib
from pyontutils.core import OntId, OntCuries
from pyontutils.core import simpleOnt, oc, oc_, odp, oop, olit, oec, olist
from pyontutils.core import POCombinator, _POCombinator, ObjectCombinator, propertyChainAxiom, Combinator, Restriction2, EquivalentClass
from pyontutils.core import restriction, restrictions
from pyontutils.core import NIFTTL, NIFRID, ilxtr, BFO
from pyontutils.core import definition, hasRole, hasParticipant, hasPart, hasInput, hasOutput, makeNamespaces, participatesIn, partOf, intersectionOf
from pyontutils.core import owl, rdf, rdfs

import rdflib
from pyontutils.core import propertyChainAxiom as pca
class mGraph(rdflib.Graph):
    def __init__(self, *args, filename='/tmp/test.ttl', **kwargs):
        super().__init__(*args, **kwargs)
        self.filename = filename
    def write(self):
        with open(self.filename, 'wb') as f:
            f.write(self.serialize(format='nifttl'))
collector = mGraph(filename='property-chains.ttl')
def _propertyChainAxiom(*args):
    class Derp(Combinator):
        def __init__(self):
            pass
        def __call__(self, *argsi):
            [collector.add(_) for _ in pca(*args)(*argsi)]
            yield ilxtr.a, ilxtr.b, ilxtr.c
    return Derp()

restN = Restriction2(None, owl.onProperty, owl.someValuesFrom)
restG = POCombinator(rdf.type, owl.Restriction).full_combinator
axiom = POCombinator(rdf.type, owl.Axiom)
blankc = POCombinator
equivalentClassC = POCombinator(owl.equivalentClass, ObjectCombinator).full_combinator
oECN = EquivalentClass(None)
owlClass = oc_
owlClassC = oc_.full_combinator
subClassOf = POCombinator(rdfs.subClassOf, ObjectCombinator).full_combinator
oop_ = POCombinator(rdf.type, owl.ObjectProperty)

def _t(subject, label, *rests, def_=None, synonyms=tuple(), comment=None,
       equivalentClass=oec):
    members = tuple()
    _rests = tuple()
    for rest in rests:
        if isinstance(rest, tuple):
            if len(rest) == 2:
                _rests += rest,
            else:
                raise ValueError(f'length of {rest} is not 2!')
        elif isinstance(rest, Combinator):
            members += rest,
        else:
            members += rest,

    rests = _rests
    if not members:
        members = ilxtr.technique,

    yield from oc(subject)
    yield from equivalentClass.serialize(subject, *members, *restrictions(*rests))
    yield from olit(subject, rdfs.label, label)
    if def_:
        yield from olit(subject, definition, def_)

    if synonyms:
        if not isinstance(synonyms, tuple):
            # this is why python sucks and racket is awesome if this was racket
            # the error would show up on the line where the problem was :/
            raise TypeError(f'Type of {synonyms!r} should not be {type(synonyms)}!')
        yield from olit(subject, NIFRID.synonyms, *synonyms)

    if comment:
        yield from olit(subject, rdfs.comment, comment)

prot = rdflib.Namespace(ilxtr[''] + 'protocol/')
tech = rdflib.Namespace(ilxtr[''] + 'technique/')
asp = rdflib.Namespace(ilxtr[''] + 'aspect/')

obo, RO, *_ = makeNamespaces('obo', 'RO')
filename = 'methods-core'
prefixes = ('BFO', 'ilxtr', 'NIFRID', 'RO', 'IAO', 'definition', 'hasParticipant')
OntCuries['HBP_MEM'] = 'http://www.hbp.FIXME.org/hbp_measurement_methods/'
imports = NIFTTL['nif_backend.ttl'],
#imports = obo['bfo.owl'], obo['ro.owl']
#imports = tuple()
comment = 'The core components for modelling techniques and methods.'
branch = 'methods'
_repo = True
debug = True

triples = (
    # object properties
    oop(ilxtr.hasOperationDefinition),
    oop(ilxtr.hasDefiningProtocol, ilxtr.hasOperationDefinition),

    oop(ilxtr.hasExecutor, hasParticipant),
    olit(ilxtr.hasExecutor, rdfs.label, 'has executor'),
    olit(ilxtr.hasExecutor, NIFRID.synonym, 'has executing agent'),
    olit(ilxtr.hasExecutor, definition,
         'The relationship between a technique and a thing that executes it.'),
    olit(ilxtr.hasExecutor, rdfs.comment,
         ('For example, a scientific protocol hasExecutor some graduateStudent.'
          'A case like some parallelProcess hasExecutor personA, personB suggests'
          'that the technique is a composite technique and should be broken down.'
{'fraction_non_alphanumeric': 0.10965421211417962, 'fraction_numerical': 0.0009282896263634254, 'mean_word_length': 3.759249033683048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5365233', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2734, 'n_words': 739}