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

Add a reference to the articles being annotated with an entity in the rdf graph #760

Closed
cyberandy opened this issue Jan 29, 2018 · 1 comment
Closed

Comments

@cyberandy
Copy link
Member

@cyberandy cyberandy commented Jan 29, 2018

Please describe the issue here:

In order to keep track of all annotated articles - we can add the following property to entities and this will be the property to be used:

@ziodave ziodave added this to the 3.18 milestone Feb 8, 2018
@ziodave ziodave self-assigned this Feb 8, 2018
@ziodave

This comment has been minimized.

Copy link
Member

@ziodave ziodave commented Feb 8, 2018

Introduction

There is a lot of legacy code: we can hook to some actions provided by the wl_core_* functions to add/remove the relationships from the linked dataset.

We need to start publishing the following information for non-entities referencing entities:

  • schema:headline
  • schema:url
  • rdfs:type
  • dcterms:references

Note that the dcterms:isReferencedBy property is no more necessary because we use the dcterms:references property.

When do want to update the dcterms:references?

  • When a relationship is created
  • When a relationship is deleted
  • When a referencing non-entity is deleted
  • When a referenced entity is deleted

State of the Art

Relationships

The relationships are created in the wl_linked_data_save_post_and_related_entities function (src/includes/class-wordlift-linked-data-service.php): first the relationships are deleted calling the wl_core_delete_relation_instances function (src/modules/core/wordlift_core_post_entity_relations.php) and then they're recreated using the wl_core_add_relation_instance function (src/modules/core/wordlift_core_post_entity_relations.php).

wl_core_delete_relation_instances and wl_core_add_relation_instance functions call respectively the following action hooks: wl_relation_deleted and wl_relation_added.

We can hook to the above to make the calls to the Linked Dataset.

Non-entity in Linked Dataset

The main class is Wordlift_Linked_Data_Service and it has two relevant functions: push (to create/update data) and remove.

The push function (src/includes/class-wordlift-linked-data-service.php) pushes data to the Linked Dataset. It currently filters entities so that non-entites or Article entities are not pushed to the Linked Dataset (if ( ! $this->entity_service->is_entity( $post_id ) ) ).

A possible way is to remove the above if and hook to the wl_insert_tuples_properties filter to reduce the properties to schema:url, schema:headline, rdfs:type and dcterms:references (this one needs to be added) when the post is not an entity (! $this->entity_service->is_entity( $post_id )).

A new property storage of Wordlift_Post_References_Storage must be added (similar to Wordlift_Post_Related_Storage, maybe can be a superclass).

In order to support deleting also the schema:headline and dcterms:references triples we need to hook to wl_schema_predicates in order to add those to the triples to delete.

Linked Dataset

In order to send the DELETE/INSERT queries to the Linked Dataset we can use the Wordlift_Sparql_Service->execute( $stmt ) function.

Queries

Queries can be generated using the Wordlift_Query_Builder class e.g. the DELETE query:

Wordlift_Query_Builder::new_instance()->delete()
	->statement( <the-uri-of-the-subject-id>, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, ?o )
	->build()

E.g. the SELECT query:

Wordlift_Query_Builder::new_instance()
	->insert()
	->statement( '<the-subject-id>', Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, '<the-object-id-uri>' )
	->build();

Initial Synchronization

When WL is updated we need to make the initial synchronization which can be something like:

  1. delete all the DCTERMS_REFERENCES_URI triples,
  2. for each row --filtered by non-entities-- in the wl_relation_instances table we call the Wordlift_Linked_Data_Service->push() function which will be created as described in Article data above to create schema:url, schema:headline and rdfs:type for the referencing entity (delete / create triples).

Rebuild Service

The Rebuild Service synchronizes the whole WP data to the Linked Dataset, therefore this must be also reviewed in order to ensure the Article data and the schema:references triples are added to the Linked Dataset.

ziodave added a commit that referenced this issue Feb 12, 2018
ziodave added a commit that referenced this issue Feb 12, 2018
ziodave added a commit that referenced this issue Feb 12, 2018
Stoyan0v added a commit that referenced this issue Feb 13, 2018
Update the tuples and predicates for non-entities
WIP
ziodave added a commit that referenced this issue Feb 14, 2018
Stoyan0v added a commit that referenced this issue Feb 14, 2018
Stoyan0v added a commit that referenced this issue Feb 14, 2018
Stoyan0v added a commit that referenced this issue Feb 15, 2018
Stoyan0v added a commit that referenced this issue Feb 15, 2018
Stoyan0v added a commit that referenced this issue Feb 15, 2018
Stoyan0v added a commit that referenced this issue Feb 15, 2018
… since we need article for all DB versions
Stoyan0v added a commit that referenced this issue Feb 16, 2018
… test for entity type service
Stoyan0v added a commit that referenced this issue Feb 16, 2018
See #760:
* Add references rebuild service
* Group rebuild services in separate folder
Stoyan0v added a commit that referenced this issue Feb 16, 2018
ziodave added a commit that referenced this issue Feb 19, 2018
ziodave added a commit that referenced this issue Feb 19, 2018
Stoyan0v added a commit that referenced this issue Feb 19, 2018
Stoyan0v added a commit that referenced this issue Feb 20, 2018
Stoyan0v added a commit that referenced this issue Feb 20, 2018
…ain rebuild service
Stoyan0v added a commit that referenced this issue Feb 20, 2018
Stoyan0v added a commit that referenced this issue Feb 20, 2018
…ssues with get_post_meta
Stoyan0v added a commit that referenced this issue Feb 20, 2018
Stoyan0v added a commit that referenced this issue Feb 21, 2018
Stoyan0v added a commit that referenced this issue Feb 21, 2018
ziodave added a commit that referenced this issue Feb 21, 2018
Stoyan0v added a commit that referenced this issue Feb 21, 2018
Stoyan0v added a commit that referenced this issue Feb 27, 2018
ziodave added a commit that referenced this issue Feb 27, 2018
@ziodave ziodave closed this Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.