Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/osw/utils/regex_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@
".drawio.png",
],
),
RegExPatternExtended(
description="File uuid in template",
pattern=r"{{\s*(Template:Editor\/(DrawIO|SvgEdit|Kekule|Spreadsheet))[\s\S]*?\|\s*uuid\s*=\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[\s\S]*?}}",
group_keys=["Full template name", "Editor", "UUID"],
example_str="""{{Template:Editor/DrawIO
| file_name = Semantic triple schematic
| page_name = Item:OSW8bccb1f0123f47d1831a1348ecbe63cc
| uuid = c4171917-ea09-4d98-823a-6af8282a6d50
| full_width = 0
| width = 300px
}}""",
expected_groups=[
"Template:Editor/DrawIO",
"DrawIO",
"c4171917-ea09-4d98-823a-6af8282a6d50",
],
),
RegExPatternExtended(
description="UUID from full page title",
pattern=r"([A-Za-z]+):([A-Z]+)([0-9a-fA-F]{32})((?:\.[\w-]+)*)",
Expand Down
26 changes: 26 additions & 0 deletions src/osw/wtsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from osw.model.static import OswBaseModel
from osw.utils.regex_pattern import REGEX_PATTERN_LIB
from osw.utils.util import parallelize
from osw.utils.wiki import get_osw_id

# Constants
SLOTS = {
Expand Down Expand Up @@ -1555,6 +1556,31 @@ def find_file_page_refs_in_slots(self, slots: List[str] = None) -> List[str]:
"Full page name",
)
file_page_refs.extend(full_page_names)
# find all files in editor templates
pattern = REGEX_PATTERN_LIB["File uuid in template"]
res = pattern.finditer(str(content))
# interate over all matches
for match in res:
ft = None
# check if the match has the groups "Editor" and "UUID" and UUID is a valid OSW ID
try:
if "Editor" in match.groups and "UUID" in match.groups:
# construct a file page title
osw_id = get_osw_id(match.groups["UUID"])
if match.groups["Editor"] == "DrawIO":
ft = "File:" + osw_id + ".drawio.svg"
elif match.groups["Editor"] == "SvgEdit":
ft = "File:" + osw_id + ".svg"
elif match.groups["Editor"] == "Kekule":
ft = "File:" + osw_id + ".kekule.json"
elif match.groups["Editor"] == "Spreadsheet":
ft = "File:" + osw_id + ".luckysheet.json"
elif match.groups["Editor"] == "Wellplate":
ft = "File:" + osw_id + ".wellplate.svg"
if ft is not None:
file_page_refs.append(ft)
except ValueError:
print("Warning: Error while parsing uuid in editor template")
return list(set(file_page_refs))

def purge(self):
Expand Down
82 changes: 82 additions & 0 deletions tests/test_osl.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,85 @@ def test_apply_overwrite_policy():
check["assert"](original_item, altered_item, new_item)

# todo: # where do we really need to interact with an OSL instance?


def test_wtpage_get_files():
# create a offline page with test content in slot main
# real-world example from Item:OSW8bccb1f0123f47d1831a1348ecbe63cc (About this platform)
page = OfflineWtPage()
page.set_slot_content(
"main",
"""

====File pages====
The following image gallery displays the relevant elements of a WikiFile page, which are specific to file pages.
{{Template:Viewer/Media
| image_size = 300
| mode = default
| textdata = File:OSW486215598a1f4993b063804775d70716.png{{!}}Example WikiFile page with preview of the file;
File:OSWb4f81db0862d4430b45e6fcbda9fc1ff.PNG{{!}}Infobox of a WikiFile page;
File:OSWb6115f4d5b414a3f8b3dffd420c82c2e.PNG{{!}}Footer of a WikiFile page;
}}

===Semantic triples===
The semantic triple is the basic building block of semantic technology. It links two nodes ("Subject" and "Object") by a "Property" (sometimes called "Predicate"), which expresses the relation between the two, giving meaning to the link.
{{Template:Editor/DrawIO
| file_name = Semantic triple schematic
| page_name = Item:OSW8bccb1f0123f47d1831a1348ecbe63cc
| uuid = c4171917-ea09-4d98-823a-6af8282a6d50
| full_width = 0
| width = 300px
}}{{Template:Viewer/Media
| image_size = 600
| mode = default
| textdata = File:OSW51ad8f9d660641f9880006c40f41cb56.png{{!}}An example for a network of semantic links, describing a publication, one of the authors and his affiliate;
}}

===Ontologies===
Ontologies aren't just vocabularies that define terms linke a dictionary would do. Ontologies structure knowledge by defining concepts and the relations among them. Often, they involve a hierarchy, which springs from a very generic object, aiming to describe almost everything, like "Thing" in {{Template:Viewer/Link|page=|url=https://schema.org/docs/full.html|label=Schema.org}} or "Entity" within this [[:Category:Entity#Subcategories|platform]]. Use the > Symbol to expand different hierarchy levels and to explore the structure.

There are many ontologies in use and even more in development. Most scientific domains have their own, often multiples. Here are some prominent examples:

*{{Template:Viewer/Link|page=|url=https://emmo-repo.github.io/|label=The Elementary Multiperspective Material Ontology (EMMO)}}
* {{Template:Viewer/Link|page=|url=https://big-map.github.io/BattINFO/index.html|label=Battery Interface Ontology (BattINFO)}}

==Object Orientation==
Object Orientation (OO) is a theoretical concept in computer science. It uses the abstract concept of objects to describe and model real-world objects.

===Basic building blocks===
*Object


{{Template:Editor/DrawIO
| file_name = Basic building blocks of Object Orientation diagramm
| page_name = Item:OSW8bccb1f0123f47d1831a1348ecbe63cc
| uuid = 0bea84d5-4c07-4374-a4b4-5dc84d9ba302
| full_width = 0
| width = 200px
}}

===Linked Data===
Object oriented linked data (OO-LD) in Open Semantic Lab is our way to leverage the functionality of linked data while employing concepts of object orientation to avoid the redundant definition of (semantic) properties of objects and mapping of semantic properties to ontologies.

The following figure sketches how Open Semantic Lab is used to modell objects in the real-world. On the left we see a hierarchy of abstract concepts, starting from the most generic at the top and ending up at the most specific at the bottom. At each level either new properties are introduced or the range of property values is reduced to a certain set to account for the specifics of a category. A category or class is used to define and bundle all properties or attributes that items or instances of a certain class have in common. {{Template:Editor/DrawIO
| file_name = Object oriented linked data in OSL diagramm
| page_name = Item:OSW8bccb1f0123f47d1831a1348ecbe63cc
| uuid = 58baa09e-c00b-42cc-b077-9fe4d58ccf82
| width = 600px
}}

==Glossary of frequently used terms==
""",
)

file_list = page.find_file_page_refs_in_slots()
print(file_list)
assert len(file_list) == 7
# assert if the file list contains the expected files
assert "File:OSW486215598a1f4993b063804775d70716.png" in file_list
assert "File:OSWb4f81db0862d4430b45e6fcbda9fc1ff.PNG" in file_list
assert "File:OSWb6115f4d5b414a3f8b3dffd420c82c2e.PNG" in file_list
assert "File:OSWc4171917ea094d98823a6af8282a6d50.drawio.svg" in file_list
assert "File:OSW51ad8f9d660641f9880006c40f41cb56.png" in file_list
assert "File:OSW0bea84d54c074374a4b45dc84d9ba302.drawio.svg" in file_list
assert "File:OSW58baa09ec00b42ccb0779fe4d58ccf82.drawio.svg" in file_list
Loading