Skip to content
/ nldl Public

Natural Language Processing for Clojure's common Datalog flavor

License

Notifications You must be signed in to change notification settings

den1k/nldl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Natural Language Processing for Clojure's common Datalog flavor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published