Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutag example has property chain to non-literal. What is the proper way to construct literal predicate chains from an ontology? #250

Open
timduval-unifylogic opened this issue Feb 26, 2024 · 2 comments
Labels
question Further information is requested

Comments

@timduval-unifylogic
Copy link

timduval-unifylogic commented Feb 26, 2024

❓ What is the proper way to construct literal predicate chains from an ontology?

I am attempting to create embeddings for an ontology.

I looked through the issues to see if this was answered and maybe I overlooked something but i'm a little confused as to how to construct the predicate chains properly using the mutag example as a reference.

Here is an exerpt from the provided rdflib example where the literal predicate chains are being defined. I noticed that inBond's range is not a literal and that introduced some confusion as to how to construct them correctly from an ontology.

# "samples/mutag/mutag.owl",
skip_predicates={"http://dl-learner.org/carcinogenesis#isMutagenic"}
literals=[
    [
        "http://dl-learner.org/carcinogenesis#hasBond", # domain: Compound , range: Bond
        "http://dl-learner.org/carcinogenesis#inBond",  # domain: Bond, range: Atom  <-- this is not a literal? I'm confused?
    ],
    [
        "http://dl-learner.org/carcinogenesis#hasAtom", # domain: Compound, range: Atom
        "http://dl-learner.org/carcinogenesis#charge",  # domain: Atom, range: xsd:double
    ],
],

Is there any documentation/guidance on how to construct these? Where do I begin the walk of the properties (building the chain) down to the eventual properties whose range is a xsd:primitive?

Does this mean that there could be more than two items in each literal predicate chain entry, as in:

literals=[
    [
        "http://example.com#prop1",    # domain: ClassA, range: ClassB
        "http://example.com#prop2",    # domain: ClassB, range: ClassC
        "http://example.com#prop3",    # domain: ClassC, range: xsd:string 
    ],
]

I have a rather large ontology and I want to make sure I am doing it correctly. Any help is greatly appreciated!!

@timduval-unifylogic timduval-unifylogic added the question Further information is requested label Feb 26, 2024
@GillesVandewiele
Copy link
Collaborator

GillesVandewiele commented Mar 2, 2024

Hi Tim,

The code to extract literals is defined here: https://github.com/IBCNServices/pyRDF2Vec/blob/940ef534cd44698dfb625a0f55a47b781a8dacae/pyrdf2vec/graphs/kg.py#L330

In a nutshell, if you provide a list of entities [e_1, ..., e_n] and a list of predicate walks (e.g. 1 predicate walk could be [pred1, pred2])

Then we look for all walks of form e_i -> pred1 -> * -> pred2 -> literal for every entity in your provided list, where * is a wildcard that can by anything. In case multiple such walks can be found, a list of literals will be returned and you'll have to aggregate it (mean/max/...). You'll be returned a list of n lists (n being the amount of entities) with variable lengths.

Hope that clears it up, if not, feel free to ask!

@timduval-unifylogic
Copy link
Author

timduval-unifylogic commented Mar 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants