Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/den1k/nldl
Natural Language Processing for Clojure's common Datalog flavor
https://github.com/den1k/nldl
Last synced: 2 months ago
JSON representation
Natural Language Processing for Clojure's common Datalog flavor
- Host: GitHub
- URL: https://github.com/den1k/nldl
- Owner: den1k
- License: epl-1.0
- Created: 2020-01-10T20:10:10.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T16:55:32.000Z (about 5 years ago)
- Last Synced: 2023-10-20T19:17:14.636Z (over 1 year ago)
- Language: Clojure
- Size: 9.77 KB
- Stars: 40
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NLDL
**N**atural **L**anguage for Clojure's **D**ata**l**og flavor
as present in Datomic, Datascript, Datahike etc.Inspired by [nl-datalog](https://github.com/harc/nl-datalog) and its [demo](http://alexwarth.com/projects/nl-datalog/)
## Usage
```clojure
(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](https://github.com/den1k/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.