Skip to content

Commit

Permalink
added empty attributes to knowledge_graph.edges
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiwenho committed May 23, 2024
1 parent f11b901 commit ba84d0d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 55 deletions.
6 changes: 4 additions & 2 deletions medikanren2/neo/neo-server/neo-server-utils.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ A decreases B increases C = A decreases C
#t)
(else (loop (cdr hl))))))))))

(define (data-attributes props)
(list (get-publications props)))
(define (data-attributes props has-pub?)
(if has-pub?
(list (get-publications props))
(list)))

(define get-publications
(lambda props
Expand Down
86 changes: 33 additions & 53 deletions medikanren2/neo/neo-server/neo-server.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

(define DEFAULT_PORT 8384)

(define NEO_SERVER_VERSION "1.40")
(define NEO_SERVER_VERSION "1.41")

;; Maximum number of results to be returned from *each individual* KP,
;; or from mediKanren itself.
Expand Down Expand Up @@ -1320,61 +1320,41 @@
(predicate (get-assoc "predicate" props))
(aspect-qualifier (get-assoc "object_aspect_qualifier" props))
(direction-qualifier (get-assoc "object_direction_qualifier" props))
(qualifed-predicate (get-assoc "qualified_predicate" props)))
(qualifed-predicate (get-assoc "qualified_predicate" props))
(has-pub? (> (num-pubs props) 0)))
(add-node! object)
(add-node! subject)
(unless (hash-has-key? edges id-sym)
(if (= (num-pubs props) 0)
(if (and
#;(or (eq? which-mvp 'mvp2-chem) (eq? which-mvp 'mvp2-gene))
aspect-qualifier direction-qualifier qualifed-predicate)
(hash-set! edges id-sym
(hash 'object object
'predicate predicate
'subject subject
'sources (list (get-source props) UNSECRET-SOURCE)
'qualifiers (list
(hash 'qualifier_type_id "biolink:object_aspect_qualifier"
'qualifier_value aspect-qualifier)
(hash 'qualifier_type_id "biolink:object_direction_qualifier"
'qualifier_value direction-qualifier)
(hash 'qualifier_type_id "biolink:qualified_predicate"
'qualifier_value qualifed-predicate))))
(hash-set! edges id-sym
(hash 'object object
'predicate predicate
'subject subject
'sources (list (get-source props) UNSECRET-SOURCE))))
(if (and
#;(or (eq? which-mvp 'mvp2-chem) (eq? which-mvp 'mvp2-gene))
aspect-qualifier direction-qualifier qualifed-predicate)
(hash-set! edges id-sym
(hash 'attributes
(or
(and (get-assoc "json_attributes" props)
(string->jsexpr (get-assoc "json_attributes" props)))
(data-attributes props))
'object object
'predicate predicate
'subject subject
'sources (list (get-source props) UNSECRET-SOURCE)
'qualifiers (list
(hash 'qualifier_type_id "biolink:object_aspect_qualifier"
'qualifier_value aspect-qualifier)
(hash 'qualifier_type_id "biolink:object_direction_qualifier"
'qualifier_value direction-qualifier)
(hash 'qualifier_type_id "biolink:qualified_predicate"
'qualifier_value qualifed-predicate))))
(hash-set! edges id-sym
(hash 'attributes
(or
(and (get-assoc "json_attributes" props)
(string->jsexpr (get-assoc "json_attributes" props)))
(data-attributes props))
'object object
'predicate predicate
'subject subject
'sources (list (get-source props) UNSECRET-SOURCE))))))
(if (and
#;(or (eq? which-mvp 'mvp2-chem) (eq? which-mvp 'mvp2-gene))
aspect-qualifier direction-qualifier qualifed-predicate)
(hash-set! edges id-sym
(hash 'attributes
(or
(and (get-assoc "json_attributes" props)
(string->jsexpr (get-assoc "json_attributes" props)))
(data-attributes props has-pub?))
'object object
'predicate predicate
'subject subject
'sources (list (get-source props) UNSECRET-SOURCE)
'qualifiers (list
(hash 'qualifier_type_id "biolink:object_aspect_qualifier"
'qualifier_value aspect-qualifier)
(hash 'qualifier_type_id "biolink:object_direction_qualifier"
'qualifier_value direction-qualifier)
(hash 'qualifier_type_id "biolink:qualified_predicate"
'qualifier_value qualifed-predicate))))
(hash-set! edges id-sym
(hash 'attributes
(or
(and (get-assoc "json_attributes" props)
(string->jsexpr (get-assoc "json_attributes" props)))
(data-attributes props has-pub?))
'object object
'predicate predicate
'subject subject
'sources (list (get-source props) UNSECRET-SOURCE)))))
id))

(define (add-creative-edge! sub obj pred n aux-id)
Expand Down

0 comments on commit ba84d0d

Please sign in to comment.