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

JSON-LD: use shortened props and lowerCamelCase #331

Open
VladimirAlexiev opened this issue Dec 26, 2023 · 4 comments
Open

JSON-LD: use shortened props and lowerCamelCase #331

VladimirAlexiev opened this issue Dec 26, 2023 · 4 comments

Comments

@VladimirAlexiev
Copy link

VladimirAlexiev commented Dec 26, 2023

@Sveino

As clarified during a previous session, the concerns in https://github.com/VladimirAlexiev/soml/blob/master/owl2soml/CIM-shorten.md are not a problem:

  • For any two props C1.P and C2.P, the classes C1 and C2 are disjoint
  • The type and meaning of C1.P and C2.P are the same
  • Therefore, we can use the short name P in JSON to make instance data as pleasant as possible for developers.
    In particular, this enables JS "property paths", eg, bay.voltageLevel.name where bay is an object of type Bay

By using JSON-LD 1.1 (#330) "local contexts" it is possible to have short prop names in the payload.

  • We can also omit the cim: prefix: either by using @vocab, or by declaring the @id of every class
  • I've converted even object props to lowerCamelCase (most ontologies use the convention that all props should follow this naming):
    {
      "@id": "urn:uuid:9d58e5bb-834c-4faa-928c-7da0bb1497d9",
      "@type": "ACLineSegment",
      "mRID": "9d58e5bb-834c-4faa-928c-7da0bb1497d9",
      "description": "400V Telemarkstien 2 ACLineSegment 1",
      "name": "04 TELEMA2 ACLS1",
      "aggregate": false,
      "normallyInService": true,
      "length": "50.0",
      "bch": "0.0",
      "gch": "0.0",
      "r": "0.015999999945951",
      "x": "0.003769911221053",
      "assetDatasheet": "urn:uuid:d25f35ca-69fb-4c06-905b-67ec532e5f14" ,
      "equipmentContainer": "urn:uuid:64e21d95-8b55-b941-a923-b74087410a66" ,
      "baseVoltage": "urn:uuid:9598e4a0-67e5-4ad7-879c-c85a1f63159c"
    },
    {
      "@id": "urn:uuid:3d51330c-7528-4efb-8edc-e61dcc145ac4",
      "@type": "Bay",
      "mRID": "3d51330c-7528-4efb-8edc-e61dcc145ac4",
      "description": "Nedenes 400V Low Voltage Cable 1 Bay",
      "name": "NEDENES  04LC1",
      "voltageLevel": "urn:uuid:681a21b6-5a55-11eb-a658-74e5f963e191"
    },
    {
      "@id": "urn:uuid:681a21b6-5a55-11eb-a658-74e5f963e191",
      "@type": "VoltageLevel",
      "mRID": "681a21b6-5a55-11eb-a658-74e5f963e191",
      "description": "Secondary Substation LV",
      "name": "NEDENES 04",
      "baseVoltage": "urn:uuid:9598e4a0-67e5-4ad7-879c-c85a1f63159c",
      "substation": "urn:uuid:681a2179-5a55-11eb-a658-74e5f963e191"
    }
@VladimirAlexiev
Copy link
Author

The gist https://gist.github.com/VladimirAlexiev/d691a9c66c348877d6c90420b52dec40 file DIGIN10-30-LV1_EQ-shortProps.jsonld shows how this can be done:

  "@context": {
    "@vocab":  "http://ucaiug.org/ns/CIM#",
    "cim":     "http://ucaiug.org/ns/CIM#",
    "rdf":     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "eu":      "http://iec.ch/TC57/CIM100-European#",
    "dct":     "http://purl.org/dc/terms/",
    "dcat":    "http://www.w3.org/ns/dcat#",
    "prov":    "http://www.w3.org/ns/prov#",
    "xsd":     "http://www.w3.org/2001/XMLSchema#",
    "dcat:isVersionOf":      {"@type": "@id"},
    "dct:conformsTo":        {"@type": "@id"},
    "dct:issued":            {"@type": "xsd:dateTime"},
    "dct:references":        {"@type": "@id"},
    "dct:spatial":           {"@type": "@id"},
    "dct:temporal":          {"@type": "@id"},
    "prov:generatedAtTime":  {"@type": "xsd:dateTime"},
    "mRID":                  {"@id": "IdentifiedObject.mRID"},
    "Bay":                   {"@context": {"description":        {"@id": "IdentifiedObject.description"},
                                           "name":               {"@id": "IdentifiedObject.name"},
                                           "voltageLevel":       {"@id": "Bay.VoltageLevel","@type":  "@id"}}},
    "ConductingEquipment":   {"@context": {"baseVoltage":        {"@id": "ConductingEquipment.BaseVoltage","@type": "@id"}}},
    "Equipment":             {"@context": {"equipmentContainer": {"@id": "Equipment.EquipmentContainer","@type": "@id"}}},
    "PowerSystemResource":   {"@context": {"assetDatasheet":     {"@id": "PowerSystemResource.AssetDatasheet", "@type": "@id"}}},
    "VoltageLevel":          {"@context": {"description":        {"@id": "IdentifiedObject.description"},
                                           "name":               {"@id": "IdentifiedObject.name"},
                                           "substation":         {"@id": "VoltageLevel.Substation", "@type": "@id"},
                                           "baseVoltage":        {"@id": "VoltageLevel.BaseVoltage", "@type": "@id"}}},
    "Conductor":             {"@context": {"length":             {"@id": "Conductor.length", "@type": "xsd:float"}}},
    "ACLineSegment":         {"@context": {"description":        {"@id": "IdentifiedObject.description"},
                                           "name":               {"@id": "IdentifiedObject.name"},
                                           "aggregate":          {"@id": "Equipment.aggregate", "@type":"xsd:boolean"},
                                           "normallyInService":  {"@id": "Equipment.normallyInService", "@type":"xsd:boolean"},
                                           "length":             {"@id": "Conductor.length", "@type":"xsd:float"},
                                           "assetDatasheet":     {"@id": "PowerSystemResource.AssetDatasheet", "@type":"@id"},
                                           "equipmentContainer": {"@id": "Equipment.EquipmentContainer", "@type":"@id"},
                                           "baseVoltage":        {"@id": "ConductingEquipment.BaseVoltage", "@type":"@id"},
                                           "bch":                {"@id": "ACLineSegment.bch", "@type": "xsd:float"},
                                           "gch":                {"@id": "ACLineSegment.gch", "@type": "xsd:float"},
                                           "r":                  {"@id": "ACLineSegment.r", "@type": "xsd:float"},
                                           "x":                  {"@id": "ACLineSegment.x", "@type": "xsd:float"}}}
  }

@Sveino
Copy link
Contributor

Sveino commented Jan 12, 2024

@VladimirAlexiev You wrote "Therefore, we can use the short name P in JSON to make instance data as pleasant as possible for developers." - find two developer with the same preference is like finding to identical snowflakes...
This is the right time to have this discussion. I am in general a fan of getting it shorten. However, there are some semantic challenges.

@VladimirAlexiev
Copy link
Author

VladimirAlexiev commented Jan 23, 2024

@Sveino

  • Come on, you do not seriously claim that developers like to write and read longer names when shorter names are just as unambiguous?
    Even chatGPT prefers the shorter names (and gets confused which exact prefix to use),
  • What challenges?

@kapitkapit
Copy link

https://app.adjust.com/34cqh6a_tvv1g60?deeplink=mobilelegends://appinvites/mlr/whatsapp_2000000

The provided URL is an invite link for the mobile game "Mobile Legends" that can be shared via WhatsApp. This link allows users to invite friends to play the game and join the app.

Citations:
[1] https://app.adjust.com/34cqh6a_tvv1g60?deeplink=mobilelegends%3A%2F%2Fappinvites%2Fmlr%2Fwhatsapp_2000000
[2] Adding Employees Through the Invite Link - The Connecteam Help Center https://help.connecteam.com/en/articles/6445424-adding-employees-through-the-invite-link
[3] Create invite links - App Distribution - Firebase - Google https://firebase.google.com/docs/app-distribution/create-invite-links
[4] User referrals | Adjust Help Center https://help.adjust.com/en/article/user-referrals
[5] Set up user referrals - Adjust Help Center https://help.adjust.com/en/article/set-up-user-referrals
[6] How to correctly use and track App-invites? - Stack Overflow https://stackoverflow.com/questions/37703852/how-to-correctly-use-and-track-app-invites

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

3 participants