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

implement SchemaMappingImpl #199

Open
hartig opened this issue Jun 9, 2022 · 4 comments
Open

implement SchemaMappingImpl #199

hartig opened this issue Jun 9, 2022 · 4 comments
Assignees

Comments

@hartig
Copy link
Member

hartig commented Jun 9, 2022

@SHSenpai this one is for you. See the new class SchemaMappingImpl as added in commit 45695d6 This class needs to be implemented (there are several TODOs in the class), including a corresponding test class with some unit tests SchemaMappingImpl.

To this after addressing #198

@SHSenpai
Copy link
Collaborator

Is SchemaMappingImpl dependent on EntityMappingImpl? SchemaMapping.java mentions "(i.e., applying this entity mapping to the solution mapping does not have any effect)", is this a typo from copying over the definitions of EntityMapping's methods?

Also, what exactly is SchemaMapping? The brief description I see in SchemaMapping.java doesn't give me a clear view of what the methods in the class are supposed to do when fully implemented.

@hartig
Copy link
Member Author

hartig commented Sep 29, 2022

Is SchemaMappingImpl dependent on EntityMappingImpl?

No.

SchemaMapping.java mentions "(i.e., applying this entity mapping to the solution mapping does not have any effect)", is this a typo from copying over the definitions of EntityMapping's methods?

Yes, that was a typical copy-paste error. I have fixed it in commit 4ad03d7

Also, what exactly is SchemaMapping?

As you may remember, RDF vocabularies / ontologies introduce classes and properties which can be used in RDF triples that represent statements about instances of the classes. For instance, the FOAF vocabulary contains the class of persons for which it introduces the URI http://xmlns.com/foaf/0.1/Person (or, foaf:Person for short if we assume that the prefix name foaf is declared for the URI prefix http://xmlns.com/foaf/0.1/). Now, we can use that URI in a triple to state that something identified by the URI http://example.org/Bob is a person:

 (http://example.org/Bob, rdf:type, foaf:Person)

The properties that RDF vocabulary define can be used in the predicate position of triples. For instance:

 (http://example.org/Bob, foaf:name, "Robert")
 (http://example.org/Bob, foaf:knows, http://example.org/Ali)

Now, entity mappings are about the URIs for the things that we can describe using such vocabularies (e.g., http://example.org/Bob and http://example.org/Ali in the example). Schema mappings are about the properties and the classes defined in the vocabularies. For instance, a schema mapping may define that the class denoted by the URI foaf:Person is equivalent to the class denoted by the URI http://example.org/HumanBeing or that the class with URI foaf:Person is a subclass of the class with URI foaf:Agent. Juliette's thesis draft covers several such types of relationships between classes and also between properties. A schema mapping may contain all of them (except for the owl:sameAs relationships, which are for entity mappings).

Unfortunately, the VocabularyMapping class that we currently have in HeFQUIN mixes both (i.e., it represents both a schema mapping and an entity mapping). I would like these two things to be separated. That's why the new interfaces EntityMapping and SchemaMapping. So, in that sense, the functions of the SchemaMapping should do what the corresponding functions of the VocabularyMapping are currently doing except for the parts that are based on owl:sameAs relationships between URIs of entities.

Does this help? Let me know if you have further questions.

@SHSenpai
Copy link
Collaborator

Yeah, this helps quite a bit.

I have some further questions, first off: The implementation's TODO wants me to define 'TermMapping' and implement classes. After looking at the page you linked to, I still don't know what 'Term' means in this context.

What relationships between classes exist, which the SchemaMappingImpl should be aware of (if any)? I see "equivalent to" and "subclass of" as two examples, are there more?
Furthermore, assuming that foaf:Person is a subclass of foaf:Agent, how do I apply this to a solution mapping? Same for the inverse.
Given (http://example.org/Bob, rdf:type, foaf:Person) as a triple pattern, what sort of result can I expect applyToTriplePattern to produce given the knowledge that foaf:Person is a subclass of foaf:Agent? They're not equivalent, so (http://example.org/Bob, rdf:type, foaf:Agent) as a result by itself doesn't seem like a fully-obvious output, but at the same time I also don't see any alternative outputs.

I see that the TODO states that Node should be the key value in g2lMap - just like in EntityMappingImpl. Can Node be anything? A literal? A URI? Furthermore regarding the g2lMap, should an l2gMap in the same vein as EntityMappingImpl also be created? If so, is applyInverseToSolutionMapping the 'mirror image' as it is in EntityMappingImpl, or something else? If not, I assume the applyInverseToSolutionMapping would work as a 'any of these locals are renamed to this global', but I'm not sure because this isn't a Node-to-Node mapping as it was in EntityMappingImpl.

From what I can see on the FOAF webpage, I have a hint that these foaf-classes are pre-defined and finite. Is this correct? As in, the classes listed on the FOAF webpage are all FOAF classes which exist and they have set properties which can be specified - and also seems like not all properties have to be specified.
What is the difference between domain and range in the context of FOAF? My current hunch is that 'range' are properties which establish a relationship between one class to another class, whereas 'domain' are properties that do not involve other classes.

@hartig
Copy link
Member Author

hartig commented Sep 30, 2022

I have some further questions, first off: The implementation's TODO wants me to define 'TermMapping' and implement classes. After looking at the page you linked to, I still don't know what 'Term' means in this context.

By "terms" I mean the URIs that identify classes and properties as introduced by the vocabularies. For instance, foaf:Person is a term, and so is foaf:knows. In the Jena API, such terms are objects of the Java class Node.

Now, regarding TermMapping, please note that I have not thought through in detail how SchemaMappingImpl can be implemented. However, broadly the idea was to capture the different types of relationships that can exist between terms in the global and in the local vocabulary by different Java classes that implement TermMapping (i.e., one such Java class per type of relationship). An object of such a Java class would represent the instance of the corresponding type of relationships for a particular term of the global vocabulary.

For example, the "equivalent to" relationships that can exists between classes would be captured as one such Java class that implements TermMapping. Let's call this Java class EquivalentClassMapping. Then, continuing my earlier example about the class with URI foaf:Person being equivalent to the class with URI http://example.org/HumanBeing, you would need to create an EquivalentClassMapping object that represents this particular instance of the "equivalent to" relationship. Further, assuming foaf:Person is in the global vocabulary, this EquivalentClassMapping object needs to be put into the g2lMap under the key for foaf:Person (i.e., the Jena Node object for the URI foaf:Person).

What function declarations the TermMapping interface needs to contain in order to be able to use TermMapping objects for the rewriting of triple patterns (function applyToTriplePattern of SchemaMappingImpl) and for the rewriting of solution mappings (function applyToSolutionMapping) is something that I have not yet thought about. Maybe you have a proposal?

What relationships between classes exist, which the SchemaMappingImpl should be aware of (if any)? I see "equivalent to" and "subclass of" as two examples, are there more?

This is in Juliette's thesis report. I will email you a recent draft that she just sent yesterday. In that one, the relevant section for your question here is Section 4.2.2.

Furthermore, assuming that foaf:Person is a subclass of foaf:Agent, how do I apply this to a solution mapping?

Short answer, that still needs to be defined.

Longer answer: Remember that both your and Juliette's thesis work considers only the cases in which solution mappings need to be translated from the local vocabulary of a federation member to the global vocabulary. That would be applying the inverse of a schema mapping to such solution mappings (which your next question was about---answer below). In other words, for both your theses, you are not considering cases in which solution mappings that contain terms of the global vocabulary need to be translated by applying our global-to-local schema mappings to them. That's why this part is still undefined. Creating this definition is perhaps not too difficult because it would be similar to how the schema mappings are applied to triple patterns. However, I suggest to ignore this part for the moment and, instead, first focus on implementing the functions of SchemaMappingImpl for which we have definitions (i.e., the functions applyToTriplePattern and applyInverseToSolutionMapping).

Same for the inverse. [...]

See Section 4.4 in the latest draft of Juliette's thesis report that I will email you.

Remember, however, that Juliette's notion of "vocabulary mapping" mixes the concept of a schema mapping with the concept of an entity mapping. Hence, for the schema mapping, you can ignore the parts of Juliette's description that are about owl:sameAs.

Given (http://example.org/Bob, rdf:type, foaf:Person) as a triple pattern, what sort of result can I expect applyToTriplePattern to produce given the knowledge that foaf:Person is a subclass of foaf:Agent? They're not equivalent, so (http://example.org/Bob, rdf:type, foaf:Agent) as a result by itself doesn't seem like a fully-obvious output, but at the same time I also don't see any alternative outputs.

The rewriting of triple patterns is defined in Section 4.3 of Juliette's latest draft (also here, ignore the parts that are about owl:sameAs).

For your given example, assuming that foaf:Person is in the global vocabulary and foaf:Agent in the local one, there is no way to correctly rewrite your given triple pattern and, thus, by the definition, the triple pattern would remain as is.

An alternative example would be a triple pattern (?x, rdf:type, foaf:Agent) with foaf:Agent in the global vocabulary and foaf:Person in the local one. In this case, the triple pattern would be rewritten to (?x, rdf:type, foaf:Person). Informally, you can think of this rewriting as follows: the given triple pattern wants to retrieve all agents and, by the schema mapping, we know that persons are agents; therefore, we can retrieve all persons from the federation member that uses the local vocabulary with foaf:Person and return all these persons as solutions for the given triple pattern.

I see that the TODO states that Node should be the key value in g2lMap - just like in EntityMappingImpl. Can Node be anything? A literal? A URI?

In general, yes. The Jena class Node represents literals, URIs, etc. However, in the particular case, you would create such Node objects only for the URIs that identify terms in the vocabularies, as I explained above.

Furthermore regarding the g2lMap, should an l2gMap in the same vein as EntityMappingImpl also be created?

I think yes.

If so, is applyInverseToSolutionMapping the 'mirror image' as it is in EntityMappingImpl, or something else? If not, I assume the applyInverseToSolutionMapping would work as a 'any of these locals are renamed to this global', but I'm not sure because this isn't a Node-to-Node mapping as it was in EntityMappingImpl.

applyInverseToSolutionMapping is not exactly a "mirror image" in this case. As I mention above, the desired effect of applyInverseToSolutionMapping is defined in Section 4.4 of Juliette's latest draft.

From what I can see on the FOAF webpage, I have a hint that these foaf-classes are pre-defined and finite. Is this correct? As in, the classes listed on the FOAF webpage are all FOAF classes which exist and they have set properties which can be specified - and also seems like not all properties have to be specified.

Yes. However, please do not get hung up too much on the FOAF vocabulary. That was just an example.

What is the difference between domain and range in the context of FOAF? [...]

domain and range are general concepts for RDF vocabularies. In other words, there is nothing specific about them in the context of FOAF. As a reminder what these concepts mean, you can take a look again at Section 4 of the RDF primer document I pointed you to much earlier: https://www.w3.org/TR/rdf11-primer/#section-vocabulary

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

No branches or pull requests

2 participants