Use a more consistent representation for jsonld
activitystreams/ontology.scm
| 291 | 291 | (or | |
| 292 | 292 | (equal? property other) | |
| 293 | 293 | (equal? (as-property-uri property) other) | |
| 294 | + | (and (as-property? other) | |
| 295 | + | (equal? (as-property-uri property) (as-property-uri other))) | |
| 294 | 296 | (let loop ((superproperties (as-property-subproperty-of property))) | |
| 295 | 297 | (match superproperties | |
| 296 | 298 | (() #f) | |
… | |||
| 320 | 322 | (match kv | |
| 321 | 323 | ((k . v) | |
| 322 | 324 | (subproperty? k key)))) | |
| 323 | - | (let ((candidates (filter is-candidate document))) | |
| 325 | + | (let ((candidates (filter is-candidate | |
| 326 | + | (if (as-document? document) | |
| 327 | + | (as-document-properties document) | |
| 328 | + | document)))) | |
| 324 | 329 | (map cdr candidates))) | |
| 325 | 330 | ||
| 326 | 331 | (define (json->as-document ontology document) | |
… | |||
| 368 | 373 | ((json-array? document) | |
| 369 | 374 | ;; XXX: this filter is not correct if one of the values is the litteral | |
| 370 | 375 | ;; "false" | |
| 371 | - | (list->array 1 | |
| 372 | - | (filter | |
| 373 | - | (lambda (a) a) | |
| 374 | - | (map (lambda (doc) (json->as-document ontology doc)) | |
| 375 | - | (array->list document))))) | |
| 376 | - | ((json-has-key? document "@type") | |
| 377 | - | (let* ((types (assoc-ref document "@type")) | |
| 376 | + | (filter | |
| 377 | + | (lambda (a) a) | |
| 378 | + | (map (lambda (doc) (json->as-document ontology doc)) | |
| 379 | + | (array->list document)))) | |
| 380 | + | ((list? document) | |
| 381 | + | (let* ((types (or (assoc-ref document "@type") #())) | |
| 378 | 382 | (types (if (string? types) (list types) (array->list types))) | |
| 379 | 383 | (types (filter (lambda (a) a) (map uri->datatype types)))) | |
| 380 | - | (if (null? types) | |
| 381 | - | #f | |
| 382 | - | (make-as-document | |
| 383 | - | types | |
| 384 | - | (filter | |
| 385 | - | (lambda (a) a) | |
| 386 | - | (map | |
| 387 | - | (match-lambda | |
| 388 | - | ((key . value) | |
| 389 | - | (let ((property (uri->property key)) | |
| 390 | - | (value (json->as-document ontology value))) | |
| 391 | - | (if (and property (not (equal? key "@type")) value) | |
| 392 | - | (cons (uri->property key) value) | |
| 393 | - | #f)))) | |
| 394 | - | document)))))) | |
| 395 | - | (else | |
| 396 | - | (map | |
| 397 | - | (match-lambda | |
| 398 | - | ((key . value) | |
| 399 | - | (cons key (json->as-document ontology value)))) | |
| 400 | - | document)))) | |
| 384 | + | (make-as-document | |
| 385 | + | types | |
| 386 | + | (filter | |
| 387 | + | (lambda (a) a) | |
| 388 | + | (map | |
| 389 | + | (match-lambda | |
| 390 | + | ((key . value) | |
| 391 | + | (let ((property (uri->property key)) | |
| 392 | + | (value (json->as-document ontology value))) | |
| 393 | + | (if (and property (not (equal? key "@type")) value) | |
| 394 | + | (cons (uri->property key) value) | |
| 395 | + | #f)))) | |
| 396 | + | document))))))) | |
| 401 | 397 | ||
| 402 | 398 | (define (uri->as-document ontology uri) | |
| 403 | 399 | (json->as-document ontology (expand uri))) | |
… | |||
| 468 | 464 | (if (string? key) key (as-property-label key))) | |
| 469 | 465 | (as-document->graphviz value #:label child-label) | |
| 470 | 466 | (loop children (+ suffix 1)))))))) | |
| 471 | - | ((list? doc) | |
| 472 | - | (format #t " ~a [label=\"\"];~%" label) | |
| 473 | - | (let loop ((children doc) (suffix 0)) | |
| 474 | - | (match children | |
| 475 | - | (() (format #t "~%")) | |
| 476 | - | (((key . value) children ...) | |
| 477 | - | (let ((child-label (string-append label (number->string suffix)))) | |
| 478 | - | (format #t " ~a -> ~a [label=\"~a\"];~%" | |
| 479 | - | label child-label | |
| 480 | - | (if (string? key) key (as-property-label key))) | |
| 481 | - | (as-document->graphviz value #:label child-label) | |
| 482 | - | (loop children (+ suffix 1))))))) | |
| 483 | 467 | ((string? doc) | |
| 484 | 468 | (format #t " ~a [label=\"~a\"];~%" label doc)) | |
| 485 | - | ((array? doc) | |
| 486 | - | (let loop ((children (array->list doc)) (suffix 0)) | |
| 469 | + | ((list? doc) | |
| 470 | + | (let loop ((children doc) (suffix 0)) | |
| 487 | 471 | (match children | |
| 488 | 472 | (() (format #t "~%")) | |
| 489 | 473 | ((value children ...) | |