Skip to content

Commit

Permalink
modified the ranking algorithm for mvp1 and mvp2 queries with 3 extra…
Browse files Browse the repository at this point in the history
… factors: class-hierarchy, hop-count, and predicate-type
  • Loading branch information
kaiwenho committed Jul 18, 2024
1 parent e97d004 commit 2ed6a13
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 142 deletions.
6 changes: 2 additions & 4 deletions medikanren2/neo/neo-low-level/query-low-level-multi-db.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@

(define (query:X->Y->Known-auto-grow
category*.X predicate*.X->Y category*.Y predicate*.Y->K curie*.K score* result_amount result-filter)
(define half-result (exact-round (/ result_amount 2.0)))
(define (helper YK XY curie-rep-hash score*)
(let* ((Y=>YK=>1 (result*->dict car YK curie-rep-hash))
(Y=>XY=>1 (result*->dict caddr XY curie-rep-hash))
Expand All @@ -429,7 +428,7 @@
XY*))))))
(result (result-filter result)))
(cond
[(> (length result) half-result)
[(> (length result) result_amount)
(printf "return ~a answers\n" (length result))
result]
[(andmap not score*)
Expand All @@ -453,7 +452,6 @@

(define (query:Known->Y->X-auto-grow
curie*.K predicate*.K->Y category*.Y predicate*.Y->X category*.X score* result_amount result-filter)
(define half-result (exact-round (/ result_amount 2.0)))
(define (helper KY YX curie-rep-hash score*)
(let* ((Y=>KY=>1 (result*->dict caddr KY curie-rep-hash))
(Y=>YX=>1 (result*->dict car YX curie-rep-hash))
Expand All @@ -472,7 +470,7 @@
YX*))))))
(result (result-filter result)))
(cond
[(> (length result) half-result)
[(> (length result) result_amount)
(printf "return ~a answers\n" (length result))
result]
[(andmap not score*)
Expand Down
4 changes: 2 additions & 2 deletions medikanren2/neo/neo-server/neo-server-utils.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ A decreases B increases C = A decreases C
(let ((score (string->number (get-assoc "mediKanren-score" props)))
(source (get-source-helper props)))
(cond
((equal? source "infores:semmeddb") (* 0.7 score))
((equal? source "infores:text-mining-provider-targeted") (* 2 score))
((equal? source "infores:semmeddb") (* 0.1 score))
((equal? source "infores:text-mining-provider-targeted") (* 10 score))
(else score))))

(define (get-score-from-result result)
Expand Down
Loading

0 comments on commit 2ed6a13

Please sign in to comment.