Skip to content
Natural Language Processing for Clojure's common Datalog flavor
Clojure
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dev/examples Init commit Jan 10, 2020
src/nldl WIP: gen schema and entities from text Jan 15, 2020
.gitignore Init commit Jan 10, 2020
LICENSE Init commit Jan 10, 2020
README.md update README Jan 14, 2020
deps.edn Init commit Jan 10, 2020

README.md

NLDL

Natural Language for Clojure's Datalog flavor as present in Datomic, Datascript, Datahike etc.

Inspired by nl-datalog and its demo

Usage

(ns examples.basic
  (:require [nldl.core :as nldl]
            [datascript.core :as d]))

(nldl/nl->dl
"find movie
 where movie title is avatar
 movie rating is 8")

;; => [:find ?movie :where [?movie :title "avatar"] [?movie :rating 8]]


(def db
  (-> (d/empty-db)
      (d/db-with
       [{:db/id 1 :title "titanic" :rating 3}
        {:db/id 2 :title "avatar" :rating 8}
        {:db/id 8 :title "avatar 2" :rating 5}
        {:db/id 3 :title "holy motors" :rating 8}
        {:db/id 4 :title "greener grass" :rating 9}])))

(d/q
 (nldl/nl->dl
  "find movie
  where movie title is avatar
  movie rating is 8")
 db)

;; => #{[2]}


(d/q
 (nldl/nl->dl
  "find movie
  where movie title is avatar
  movie rating is 8"
  {:find (fn [var] [:find (list 'pull var '[*])])})
 db)

;; =>  ([{:db/id 2, :rating 8, :title "avatar"}])

Status: Alpha

Experimental! I'm toying with this for easier entry of datalog queries on mobile (for my project Zeal) where Clojure Datalog's beloved parentheses, brackets, question marks and colons are always at least two taps away.

Thanks to its simple text processing NLDL also allows for accessibility enhancements through speech-to-text queries.

License

Copyright © 2020 FIXME

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

You can’t perform that action at this time.