uncefact / spec-jsonld

Exposing the UN/CEFACT vocabulary as web semantics
https://service.unece.org/trade/uncefact/vocabulary/uncefact/
13 stars 5 forks source link

Unreferenced Classes, How should they be defined? #141

Open ChrisJMacdonald opened 2 years ago

ChrisJMacdonald commented 2 years ago

Unreferenced Classes

Issue

Many Classes are defined that cannot be implemented as they are not referenced by any properties. How is one to use these classes and implement them? Classes such as Context, ExchangedDocument, LineTradeSettlement, etc.

Context

In conversations on Slack, I had asked about creating a payload and offered an example of:

{
  "@context": "https://dmvc7xzscpizo.cloudfront.net/unece-context.jsonld",
  "Context": {
    "specifiedTransactionId": "1234"
  },
  "HeaderTradeAgreement": {
    "sellerReference": "foo",
    "buyerReference": "bar"
  }
}

This is incorrect, as the Classes themselves cannot be used as a property. Instead, it should be a property that rangeIncludes the class.

Extra

Quick script to pull out all the classes which aren't referenced:

import json
with open('unece.jsonld') as file:
    file_contents = file.read()
parsed = json.loads(file_contents)
classes_list = []
for class_object in parsed['@graph']:
    if class_object['@type'] == 'rdfs:Class':
        classes_list.append(class_object['@id'])
for class_object in parsed['@graph']:
    try:
        if class_object['schema:rangeIncludes']['@id'] in classes_list:
            classes_list.remove(class_object['schema:rangeIncludes']['@id'])
    except:
        pass
print(classes_list)

Which returns :

'unece:AcknowledgementDocument', 'unece:AppliedTax', 'unece:AttachedTransportEquipment', 'unece:BreakdownStatement', 'unece:CancellationStatus', 'unece:ContactPerson', 'unece:Context', 'unece:Declaration', 'unece:DocumentStatus', 'unece:EmployerIdentity', 'unece:ExchangedDocument', 'unece:FinancingRequestDocument', 'unece:FinancingSummaryDocument', 'unece:HeaderTradeAgreement', 'unece:HeaderTradeDelivery', 'unece:InstalmentPayment', 'unece:LineTradeSettlement', 'unece:OperationalParameter', 'unece:PaymentTradeSettlement', 'unece:PersonIdentity', 'unece:ProprietaryIdentity', 'unece:RegulatedGoods', 'unece:ReturnableAssetInstructions', 'unece:SubordinateLineTradeAgreement', 'unece:SubordinateLineTradeDelivery', 'unece:SubordinateLocation', 'unece:TaxRegistration', 'unece:TelecommunicationCommunication', 'unece:TradeSettlementHeaderMonetarySummation', 'unece:TradeSettlementLineMonetarySummation', 'unece:TradeSettlementPayment', 'unece:TransportServiceLocation', 'unece:ValidationStatus'