From d6675c010a95fe90f5a77c5eee0e9675ed4b43a8 Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Mon, 11 Dec 2023 14:32:42 -0500 Subject: [PATCH 1/3] Finagling LC processing section. --- docs/0.1/index.md | 79 ++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 56 deletions(-) diff --git a/docs/0.1/index.md b/docs/0.1/index.md index 3428953..064dc90 100644 --- a/docs/0.1/index.md +++ b/docs/0.1/index.md @@ -891,77 +891,44 @@ Of these four possibilities, we describe _mutable reverse_, of which the Library ### 6.1 Consuming a _mutable reverse_ stream (e.g. Library of Congress) -_CAUTION: This section is under construction. This section may or may not be removed from the final draft, in lieu of, a section that is a general example._ - -{:.todo} - Library of Congress provides an activity stream for several authorities (e.g. names, genre/forms, subjects, etc.). Characteristics: * an entity will appear in the activity stream at most one time -* the date of the activity for an entity will be the date of the most recent change +* the `published` date of the activity for an entity will be the date of the most recent change of the object of the activity * the first page of the stream has the most recent activities * activities on a page are listed from newest to oldest -* the date of an activity is the time the ??? - -_What does the date of an activity represent?_ -{:.todo} Assumptions: -* the activity MUST includes a URL that dereferences to a first order graph that - * MUST include all triples where the entity is the subject ( ) - * MUST include all blanknodes, and related sub-graph, where the blanknode is the object and the entity is the subject ( <_:b1>) - * MAY include triples for entities that are external to the base datasource if the entity is not available in another activity stream - * The activity MAY include another URL that dereferences to a graph that - * MAY include additional triple for other entities that are external to the base datasource that serve as object of the entity's triple ( <_:b1>) - * triples where the entity is the subject ( ) - * if activity type == ADD, dereference the entity URI and add the following triples to the cache - * all triples where the entity is subject ( ) - * all triples, and related sub-graph, where the entity is subject and a blank node is object ( <_:b1>) - * if activity type == UPDATE, dereference the entity URI and add the following triples to the cache - * perform the steps for a REMOVE - * perform the steps for an ADD - * next activity if there is one OR first activity on the next page OR stop if no next page - * stop if date of the activity is later than saved last processed date - -Pseudocode: +Pseudocode (to consume updated resources since a specific date): ``` -go to activity stream -page = activity_stream.first -activity = page.activities.first -LOOP - switch(activity.type) - case REMOVE, UPDATE - remove all triples, and sub-graph, where == activity.object.id && .is_a? blank_node - remove all triples where == activity.object.id - case ADD, UPDATE - graph = dereference(activity.object.url.skos.nt) - add all triples, and sub-graph, where graph.triple.subject == activity.object.id && .is_a? blank_node - add all triples where graph.triple.subject == activity.object.id - end +func process_as(date_from, as_uri) + activity_stream_page = get as_uri + process_as_page(date_from, activity_stream_page) +end func + +func process_as_page(date_from, activity_stream_page) + for each activity in activity_stream_page + if activity.published >= date_from then + process activity by type + else + return + + if activity.last == true and activity.published >= date_from then + process_as(activity_stream.next, date_from) +end func + +# a week +date_from = today - 6 days +process_as(date_from, uri_of_first_activity_stream_page) - if activity == page.last_activity - page = page.next - activity == page.first_activity - else - activity == activity.next_activity - end - STOP if activity.date < last_process_date -end ``` ### 6.2 Consuming an _immutable forward_ stream (e.g. Getty) From d8b4c1ca9ea7c99e03cbd592005a083dddebe3bc Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Wed, 13 Dec 2023 10:21:14 -0500 Subject: [PATCH 2/3] Incorporating less overwrought psudeo code, with tweaks to variable definitions. --- docs/0.1/index.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/0.1/index.md b/docs/0.1/index.md index 064dc90..95bc3da 100644 --- a/docs/0.1/index.md +++ b/docs/0.1/index.md @@ -909,26 +909,25 @@ Recommendations: Pseudocode (to consume updated resources since a specific date): ``` +# uri_of_first_activity_stream_page = Input URI of first Activity Stream page +# date_from = Date of last activity processed in previous pocessing run. +# last_update = Date of last activity processed in current pocessing run. + func process_as(date_from, as_uri) activity_stream_page = get as_uri - process_as_page(date_from, activity_stream_page) -end func - -func process_as_page(date_from, activity_stream_page) for each activity in activity_stream_page if activity.published >= date_from then process activity by type + last_update = activity.published else return if activity.last == true and activity.published >= date_from then - process_as(activity_stream.next, date_from) + process_as(date_from, activity_stream.next) end func -# a week -date_from = today - 6 days process_as(date_from, uri_of_first_activity_stream_page) - +# for next run: date_from = last_update ``` ### 6.2 Consuming an _immutable forward_ stream (e.g. Getty) From 8a86f2d3e37f3584ba1f37fc847be32bc018479c Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Wed, 13 Dec 2023 10:23:49 -0500 Subject: [PATCH 3/3] Correcting bad typing followed by poor reading. --- docs/0.1/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/0.1/index.md b/docs/0.1/index.md index 95bc3da..41bf113 100644 --- a/docs/0.1/index.md +++ b/docs/0.1/index.md @@ -910,8 +910,8 @@ Recommendations: Pseudocode (to consume updated resources since a specific date): ``` # uri_of_first_activity_stream_page = Input URI of first Activity Stream page -# date_from = Date of last activity processed in previous pocessing run. -# last_update = Date of last activity processed in current pocessing run. +# date_from = Date of last activity processed in previous processing run. +# last_update = Date of last activity processed in current processing run. func process_as(date_from, as_uri) activity_stream_page = get as_uri