Actually added the documentation to the repository. D'oh!
This commit is contained in:
parent
12a2eb71c8
commit
38a4610f0e
|
@ -8,7 +8,7 @@ Download from http://example.com/FIXME.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
**WARNING**: does not even nearly work yet, and may nver do so. The value of this archive is probably mainly as something to mine for algorithms and ideas, especially for those doing natural language interpreteation and generation.
|
**WARNING**: does not even nearly work yet, and may never do so. The value of this archive is probably mainly as something to mine for algorithms and ideas, especially for those doing natural language interpreteation and generation.
|
||||||
|
|
||||||
**WARNING**: nothing in this is stable. Nothing should be treated as an API. Feel free to steal ideas and code, but don't depend on `wwui` as a library.
|
**WARNING**: nothing in this is stable. Nothing should be treated as an API. Feel free to steal ideas and code, but don't depend on `wwui` as a library.
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<td class="with-number">7</td><td class="with-number">1</td><td class="with-number">3</td>
|
<td class="with-number">7</td><td class="with-number">1</td><td class="with-number">3</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="wwui/propositions.clj.html">wwui.propositions</a></td><td class="with-bar"><div class="covered"
|
<td><a href="wwui/parser.clj.html">wwui.parser</a></td><td class="with-bar"><div class="covered"
|
||||||
style="width:58.17307692307692%;
|
style="width:58.17307692307692%;
|
||||||
float:left;"> 484 </div><div class="not-covered"
|
float:left;"> 484 </div><div class="not-covered"
|
||||||
style="width:41.82692307692308%;
|
style="width:41.82692307692308%;
|
||||||
|
|
692
docs/cloverage/wwui/parser.clj.html
Normal file
692
docs/cloverage/wwui/parser.clj.html
Normal file
|
@ -0,0 +1,692 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> wwui/parser.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns wwui.parser
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 (:require [clojure.math.combinatorics :as combi]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 [clojure.pprint :refer [pprint]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 [clojure.string :as s]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 [opennlp.nlp :as nlp]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 [opennlp.treebank :as tb]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 [taoensso.timbre :as log :refer [debug error info spy]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 [wildwood.knowledge-accessor :refer [Accessor]]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
009
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
010 ;; Position tags used by OpenNLP for English are documented here:
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
011 ;; https://dpdearing.com/posts/2011/12/opennlp-part-of-speech-pos-tags-penn-english-treebank/
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
012
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
013 (def get-sentences (nlp/make-sentence-detector "models/en-sent.bin"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
014 (def tokenize (nlp/make-tokenizer "models/en-token.bin"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
015 (def pos-tag (nlp/make-pos-tagger "models/en-pos-maxent.bin"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
016 (def name-find (nlp/make-name-finder "models/namefind/en-ner-person.bin"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
017 ;; (def chunker (make-treebank-chunker "models/en-chunker.bin"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
018
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
019 (def grammar
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
020 "The objective of this grammar is to allow us to take a sequence of tagged symbols, and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
021 produce a higher-level tagging of parts of speech, and ultimately propositions, from them.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
022
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
023 *NOTE THAT* tags in this grammar are always keywords, to distinguish them from OpenNLP
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
024 tags, which tag individual tokens and are represented as strings."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="22 out of 22 forms covered">
|
||||||
|
025 {:contextual-reference [["PRP"]] ;; the documentation says PRP is 'peronal pronoun',
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
026 ;; but it seems to be all pronouns.
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="9 out of 9 forms covered">
|
||||||
|
027 :noun [["NN"]["NNS"]["NNP"]["NNPS"]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
028 :full-name [["NNP"]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
029 ["NNP" :full-name]] ;; an unpunctuated sequence of proper nouns
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
030 ;; probably represents a full name
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
031 :noun-phrase [[:contextual-reference]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
032 [:noun]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
033 [:full-name]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
034 ["DT" :noun]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
035 [:adjectives :noun]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
036 ["DT" :adjectives :noun]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
037 :noun-phrases [[:noun-phrase]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
038 [:noun-phrase "CC" :noun-phrases]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
039 [:noun-phrase "," :noun-phrases]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
040 :adjective [["JJ"]["JJR"]["JJS"]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
041 :adjectives [[:adjective]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
042 [:adjective :adjectives]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
043 [:adjective "," :adjectives]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
044 [:adjective "CC" :adjectives]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="13 out of 13 forms covered">
|
||||||
|
045 :verb [["VB"]["VBD"]["VBG"]["VBN"]["VBP"]["VBZ"]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
046 :adverb [["RB"]["RBR"]["RBS"]] ;; beware here that negation and qualification show up only as adverbs
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
047 :adverbs [[:adverb]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
048 [:adverb "," :adverbs]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
049 [:adverb "CC" :adverbs]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
050 :verb-phrase [[:verb]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
051 [:adverbs :verb]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
052 [:verb :adverbs :verb]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
053 [:verb :adverbs]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
054 [:verb :adverbs :verb "TO"]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
055 :locator [["IN" :noun-phrases]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
056 :locators [[:locator]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
057 [:locator :locators]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
058 [:locator "," :locators]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
059 :location [[:locators]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
060 :subject [[:noun-phrases]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
061 :object [[:noun-phrases]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
062 :proposition [[:subject :verb-phrase :object]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
|
063 [:location "," :subject :verb-phrase :object]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
064 [:subject "," :location "," :verb-phrase :object]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
065 [:subject :verb-phrase :object :location]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
066 :propositions [[:proposition]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
067 [:proposition "CC" :propositions]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
068 [:proposition "," "CC" :propositions]]})
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
069
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
070 (declare reparse rdp-seek)
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
071
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
072 (defn rdp-seek
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
073 "Seek a phrase which satisfies this `goal` (expected to be a keyword) in
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
074 this `tagged-sentence` using this `grammar`.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
075
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
076 Return a cons comprising
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
077 1. the first matching phrase for the goal, tagged with the goal, or `nil` if
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
078 no match;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
079 2. the tail of the sentence when the parts comprising the phrase are removed."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
080 [tagged-sentence grammar goal]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
081 (if (keyword? goal)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
082 (when (not (empty? tagged-sentence))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="8 out of 8 forms covered">
|
||||||
|
083 (when-let [result (first
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
084 (sort
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="8 out of 8 forms covered">
|
||||||
|
085 #(< (count %1) (count %2))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
086 (remove
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
087 empty?
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
088 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
089 #(reparse tagged-sentence grammar %)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
090 (goal grammar)))))]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="13 out of 13 forms covered">
|
||||||
|
091 (cons (cons (first result) (list goal)) (rest result))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 16 forms covered">
|
||||||
|
092 (throw (Exception. (str "Non-keyword passed to rdp-seek: `" goal "` (type " (or (type goal) "nil") ")")))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
093
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="19 out of 19 forms covered">
|
||||||
|
094 (defmacro tag
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
095 "The tag, on a `tagged-token`, is just the second element. Written as a macro
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
096 for readability."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
097 [tagged-token]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
098 `(nth ~tagged-token 1))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
099
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="44 out of 44 forms covered">
|
||||||
|
100 (defmacro coll-or-nil?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
101 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
102 "For fuck's sake, `nil` isn't a collection? What planet are these people on?"
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
103 `(or (nil? ~o) (coll? ~o)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
104
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
105 (defn rdp-extend
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
106 "Seek a phrase which satisfies this `goal` (expected to be a collection of tags) in
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
107 this `tagged-sentence` using this `grammar`.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
108
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
109 Return a cons comprising
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
110 1. the first matching phrase for the goal, or `nil` if no match;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
111 2. the tail of the sentence when the parts comprising the phrase are removed."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
112 [tagged-sentence grammar goal]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
113 (cond
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="10 out of 10 forms covered">
|
||||||
|
114 (not (coll-or-nil? goal))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 16 forms covered">
|
||||||
|
115 (throw (Exception. (str "Non-collection passed to rdp-extend: `" goal "` (type " (or (type goal) "nil") ")")))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
116 (empty? goal)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
117 (cons (list) tagged-sentence)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
118 (not (empty? tagged-sentence))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
119 (let [[tt & st] tagged-sentence
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
120 [target & gt] goal]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
121 (cond
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
122 (keyword? target)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="11 out of 11 forms covered">
|
||||||
|
123 (when-let [[h & t](reparse tagged-sentence grammar target)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="11 out of 11 forms covered">
|
||||||
|
124 (when-let [[dh & dt] (reparse t grammar gt)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
125 (cons (cons h dh) dt)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
|
126 (= target (tag tt))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="11 out of 11 forms covered">
|
||||||
|
127 (when-let [[dh & dt] (reparse st grammar gt)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="7 out of 7 forms covered">
|
||||||
|
128 (cons (cons tt dh) dt))))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
129
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
130 (defn reparse
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
131 "Reparse this `tagged-sentence` using this grammar to seek this `goal`.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
132 Parse greedily, seeking the most extended goal.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
133
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
134 Return a sequence comprising
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
135 1. the first matching phrase for the goal, tagged with the goal, or `nil`
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
136 if no match;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
137 2. the tail of the sentence when the parts comprising the phrase are removed.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
138
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
139 This function is called `reparse` because:
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
140 1. it is designed to parse sentences which have already been parsed by
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
141 OpenNLP: it will not work on raw sentences;
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
142 2. it is a recursive descent parser."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
143 [tagged-sentence grammar goal]
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="13 out of 16 forms covered">
|
||||||
|
144 (log/debug "=> Choosing strategy for "
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 19 forms covered">
|
||||||
|
145 goal " in " (with-out-str (pprint tagged-sentence)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="3 out of 4 forms covered">
|
||||||
|
146 (let [r (cond
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="8 out of 8 forms covered">
|
||||||
|
147 (keyword? goal) (rdp-seek tagged-sentence grammar goal)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="13 out of 13 forms covered">
|
||||||
|
148 (coll-or-nil? goal) (rdp-extend tagged-sentence grammar goal))]
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="13 out of 18 forms covered">
|
||||||
|
149 (log/debug "<= " goal " in "
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 20 forms covered">
|
||||||
|
150 (s/trim (with-out-str (pprint tagged-sentence)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 20 forms covered">
|
||||||
|
151 " returned " (s/trim (with-out-str (pprint r))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
152 r))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
153
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
154 (defn identify
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
155 [parse-tree knowledge-accessor]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
156 ;; TODO: we don't yet have a working knowledge accessor. When we do,
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
157 ;; construct a query from the contents of this parse-tree, and pass it
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
158 ;; to the knowledge accessor in the hope of finding a true name.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
159 parse-tree)
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
160
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
161 (defn normalise
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
162 [parse-tree ka]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
163 (if
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 23 forms covered">
|
||||||
|
164 (and (coll? parse-tree) (= (count parse-tree) 2)(keyword? (nth parse-tree 1)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
165 (case (nth parse-tree 1)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
166 :proposition (list
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
167 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
168 merge
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
169 {}
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
170 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
171 ;; TODO: use combinatorics to extract all propositions from
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
172 ;; a proposition having multiple locations, multiple subject,
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
173 ;; objects and/or verbs
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 13 forms covered">
|
||||||
|
174 #(assoc {} (nth % 1) (identify (first %) ka))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 10 forms covered">
|
||||||
|
175 (map #(normalise % ka) (first parse-tree)))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
176 (:location :subject :object)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
177 (cons
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
178 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
179 concat
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
180 (remove
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
181 empty?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 30 forms covered">
|
||||||
|
182 (map #(normalise % ka) (first parse-tree))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 18 forms covered">
|
||||||
|
183 (list (nth parse-tree 1)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
184 (:propositions :locators :noun-phrases :verbs)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 8 forms covered">
|
||||||
|
185 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
186 concat
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 8 forms covered">
|
||||||
|
187 (remove
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
188 empty?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 40 forms covered">
|
||||||
|
189 (map #(normalise % ka) (first parse-tree))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
190 ;; else
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
191 parse-tree)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
192 parse-tree))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
193
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
194 (defn propositions
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
195 "Given a `tagged-sentence`, return a list of propositions detected in that
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
196 sentence; if `knowledge-accessor` is passed, try to resolve names and noun
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
197 phrases to entities known to that knowledge accessor.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
198
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
199 TODO: Note that if `:subject`, `:object` or `:locator` resolves to multiple
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
200 objects, then that is essentially one proposition for each unique
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
201 combination. This is not yet implemented!"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
202 ([tagged-sentence]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
203 (propositions tagged-sentence nil))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
204 ([tagged-sentence ;; ^wildwood.knowledge-accessor.Accessor
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
205 knowledge-accessor]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
206 ;; TODO: doesn't work yet.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
207 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
208 concat
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
209 (remove
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
210 empty?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
211 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
212 #(normalise % knowledge-accessor)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
213 (first (first (reparse tagged-sentence grammar :propositions))))))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
214
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
215 (defn propositions-from-file
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
216 [file-path]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
217 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
218 concat
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
219 (remove
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
220 empty?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
221 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 7 forms covered">
|
||||||
|
222 #(propositions (pos-tag (tokenize %)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
223 (get-sentences (slurp file-path))))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
224
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
225 ;; (reparse (pos-tag (tokenize "True love is the daughter of temperance, and temperance is utterly opposed to the madness of bodily pleasure.")) grammar :propositions)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
226 ;; (reparse [["temperance" "NN"] ["is" "VBZ"] ["utterly" "RB"] ["opposed" "VBN"] ["to" "TO"] ["the" "DT"] ["madness" "NN"] ["of" "IN"] ["bodily" "JJ"] ["pleasure" "NN"]] grammar :subject)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
227 ;; (reparse [["is" "VBZ"] ["utterly" "RB"] ["opposed" "VBN"] ["to" "TO"] ["the" "DT"] ["madness" "NN"] ["of" "IN"] ["bodily" "JJ"] ["pleasure" "NN"]] grammar :verb-phrase)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
228 ;; (reparse [["is" "VBZ"] ["utterly" "RB"] ["opposed" "VBN"] ["to" "TO"] ["the" "DT"] ["madness" "NN"] ["of" "IN"] ["bodily" "JJ"] ["pleasure" "NN"]] grammar :verb-phrase)
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,3 +1,3 @@
|
||||||
<!DOCTYPE html PUBLIC ""
|
<!DOCTYPE html PUBLIC ""
|
||||||
"">
|
"">
|
||||||
<html><head><meta charset="UTF-8" /><title>Wwui 0.1.0-SNAPSHOT</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.propositions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>propositions</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></h1><h5 class="license">Released under the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GNU General Public License,version 2.0 or (at your option) any later version</a></h5><div class="doc"><p>Experimental work towards a conversational interface to Wildwood.</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[wwui "0.1.0-SNAPSHOT"]</pre><h2>Topics</h2><ul class="topics"><li><a href="intro.html">Introduction to wwui</a></li></ul><h2>Namespaces</h2><div class="namespace"><h3><a href="wwui.core.html">wwui.core</a></h3><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="wwui.core.html#var--main">-main</a> </li></ul></div></div><div class="namespace"><h3><a href="wwui.propositions.html">wwui.propositions</a></h3><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="wwui.propositions.html#var-coll-or-nil.3F">coll-or-nil?</a> </li><li> <a href="wwui.propositions.html#var-get-sentences">get-sentences</a> </li><li> <a href="wwui.propositions.html#var-grammar">grammar</a> </li><li> <a href="wwui.propositions.html#var-identify">identify</a> </li><li> <a href="wwui.propositions.html#var-name-find">name-find</a> </li><li> <a href="wwui.propositions.html#var-normalise">normalise</a> </li><li> <a href="wwui.propositions.html#var-pos-tag">pos-tag</a> </li><li> <a href="wwui.propositions.html#var-propositions">propositions</a> </li><li> <a href="wwui.propositions.html#var-propositions-from-file">propositions-from-file</a> </li><li> <a href="wwui.propositions.html#var-rdp-extend">rdp-extend</a> </li><li> <a href="wwui.propositions.html#var-rdp-seek">rdp-seek</a> </li><li> <a href="wwui.propositions.html#var-reparse">reparse</a> </li><li> <a href="wwui.propositions.html#var-tag">tag</a> </li><li> <a href="wwui.propositions.html#var-tokenize">tokenize</a> </li></ul></div></div></div></body></html>
|
<html><head><meta charset="UTF-8" /><title>Wwui 0.1.0-SNAPSHOT</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li><li class="depth-1 "><a href="parsing.html"><div class="inner"><span>Parsing</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></h1><h5 class="license">Released under the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GNU General Public License,version 2.0 or (at your option) any later version</a></h5><div class="doc"><p>Experimental work towards a conversational interface to Wildwood.</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[wwui "0.1.0-SNAPSHOT"]</pre><h2>Topics</h2><ul class="topics"><li><a href="intro.html">Introduction to wwui</a></li><li><a href="parsing.html">Parsing</a></li></ul><h2>Namespaces</h2><div class="namespace"><h3><a href="wwui.core.html">wwui.core</a></h3><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="wwui.core.html#var--main">-main</a> </li></ul></div></div><div class="namespace"><h3><a href="wwui.parser.html">wwui.parser</a></h3><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="wwui.parser.html#var-coll-or-nil.3F">coll-or-nil?</a> </li><li> <a href="wwui.parser.html#var-get-sentences">get-sentences</a> </li><li> <a href="wwui.parser.html#var-grammar">grammar</a> </li><li> <a href="wwui.parser.html#var-identify">identify</a> </li><li> <a href="wwui.parser.html#var-name-find">name-find</a> </li><li> <a href="wwui.parser.html#var-normalise">normalise</a> </li><li> <a href="wwui.parser.html#var-pos-tag">pos-tag</a> </li><li> <a href="wwui.parser.html#var-propositions">propositions</a> </li><li> <a href="wwui.parser.html#var-propositions-from-file">propositions-from-file</a> </li><li> <a href="wwui.parser.html#var-rdp-extend">rdp-extend</a> </li><li> <a href="wwui.parser.html#var-rdp-seek">rdp-seek</a> </li><li> <a href="wwui.parser.html#var-reparse">reparse</a> </li><li> <a href="wwui.parser.html#var-tag">tag</a> </li><li> <a href="wwui.parser.html#var-tokenize">tokenize</a> </li></ul></div></div></div></body></html>
|
|
@ -1,4 +1,18 @@
|
||||||
<!DOCTYPE html PUBLIC ""
|
<!DOCTYPE html PUBLIC ""
|
||||||
"">
|
"">
|
||||||
<html><head><meta charset="UTF-8" /><title>Introduction to wwui</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.propositions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>propositions</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#introduction-to-wwui" name="introduction-to-wwui"></a>Introduction to wwui</h1>
|
<html><head><meta charset="UTF-8" /><title>Introduction to wwui</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li><li class="depth-1 "><a href="parsing.html"><div class="inner"><span>Parsing</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#introduction-to-wwui" name="introduction-to-wwui"></a>Introduction to wwui</h1>
|
||||||
<p>TODO: write <a href="http://jacobian.org/writing/what-to-write/">great documentation</a></p></div></div></div></body></html>
|
<p>The long term objective for WWUI is to provide a conversational, natural language interface to Wildwood: that is, that you should be able to question Wildwood agents in normal, everyday natural language - initially only English - and have it reply in the same way. It may possibly also display on a screen diagrams and documents which support its answer and reasoning, but the primary intention is that it should converse.</p>
|
||||||
|
<p>This boils down to two things: parsing, and idiomatic language generation. The intention here is not to have full general comrehension of a natural language. Questions which may sensibly be asked of an agent essentially query the truth value of a proposition, or the value of some fact, such as:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Is Brutus honourable?</li>
|
||||||
|
<li>Where did Caesar die?</li>
|
||||||
|
<li>Did Brutus kill Caesar?</li>
|
||||||
|
</ul>
|
||||||
|
<p>and it’s perfectly OK, if a question doesn’t conform to this general form, for the interface to respond with some text of the general form ‘I don’t understand’, or ‘I don’t know about…’</p>
|
||||||
|
<p>In the past, other conversational artificial intelligence systems, e.g. <a href="https://simon-brooke.github.io/wildwood/codox/History.html#mycin">Mycin</a>, <a href="https://simon-brooke.github.io/wildwood/codox/History.html#apes">APES</a> have allowed the user to query <strong>how</strong> a result was achieved. I’m hoping that whe working of Wildwood will be sufficiently transparent that this question is largely redundant; however, it’s entirely possible that I shall implement a response to both the primitive <strong>how</strong> question (‘How do you know that?’, where the proposition being asked about is inferred from the conversational context) and a more general (‘How do you know that <code>P</code>?’, where <code>P</code> is any proposition). Indeed, the former is a special case of the latter.</p>
|
||||||
|
<h2><a href="#major-components" name="major-components"></a>Major components</h2>
|
||||||
|
<h3><a href="#parser" name="parser"></a>Parser</h3>
|
||||||
|
<p>Initial work so far is on parsing propositions out of continuous English text. At present (1<sup>st</sup> May 2020), I’m finding 63 propositions in the 5,285 sentences of Jowett’s translation into English of Plato’s Republic, which is not a good strike rate. More discussion of the parser is found <a href="parsing.html">here</a>.</p>
|
||||||
|
<p>A critical point about the parser is that it must be able not only to parse user input, but also to parse documents in order to extract knowledge from them.</p>
|
||||||
|
<h3><a href="#generator" name="generator"></a>Generator</h3>
|
||||||
|
<p>The generator is in principle much simpler than the parser; it merely needs to be able to output, as idiomatic natural language, the trace of the moves in <a href="https://simon-brooke.github.io/wildwood/codox/Arden.html#legitimate-moves-in-an-explanation-game">the inference game</a>, and the proposition which is the conclusion of the inference. To make this flow naturally, several templates will need to be stored for each potential output form, in order that these can be varied to prevent unduly repetitive output; and there may be some heuristics which guide when to use particular templates.</p></div></div></div></body></html>
|
34
docs/codox/parsing.html
Normal file
34
docs/codox/parsing.html
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE html PUBLIC ""
|
||||||
|
"">
|
||||||
|
<html><head><meta charset="UTF-8" /><title>Parsing</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li><li class="depth-1 current"><a href="parsing.html"><div class="inner"><span>Parsing</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#parsing" name="parsing"></a>Parsing</h1>
|
||||||
|
<p>Generally, The <code>wwui</code> parser needs to be able to recognise, and to extract in a form usable by <code>wildwood</code>, two general forms of utterances:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Propositions, and</li>
|
||||||
|
<li>Questions;</li>
|
||||||
|
</ol>
|
||||||
|
<p>where questions can be further subdivided:</p>
|
||||||
|
<ol>
|
||||||
|
<li>is (proposition) true at present?</li>
|
||||||
|
<li>was (proposition) true in the past?</li>
|
||||||
|
<li>will (proposition) be true in the future?</li>
|
||||||
|
<li>is (proposition) true at this (time or time range specification)?</li>
|
||||||
|
<li>what is the value of (property) of (entity)?</li>
|
||||||
|
<li>how do you know that (proposition) has (truth-value)?</li>
|
||||||
|
<li>how do you know that (property) of (entity) has (value)?</li>
|
||||||
|
</ol>
|
||||||
|
<p>So the key things we need to know about and identify in natural language input are</p>
|
||||||
|
<ol>
|
||||||
|
<li>Propositions;</li>
|
||||||
|
<li>Entities;</li>
|
||||||
|
<li>Properties;</li>
|
||||||
|
<li>Values</li>
|
||||||
|
</ol>
|
||||||
|
<p>At the current stage of development of the current iteration, is is anticipated that the key construct that <code>wildwood</code> will reason with are <a href="https://simon-brooke.github.io/wildwood/codox/Bialowieza.html#propositions">located two position propositions</a>; that is to say propositions having</p>
|
||||||
|
<ol>
|
||||||
|
<li>A <strong>verb</strong>;</li>
|
||||||
|
<li>A <strong>subject</strong>, being an entity;</li>
|
||||||
|
<li>An <strong>object</strong>, being an entity;</li>
|
||||||
|
<li>Optionally, a <strong>spatial location</strong>;</li>
|
||||||
|
<li>Optionally, a <strong>temporal location</strong>.</li>
|
||||||
|
</ol>
|
||||||
|
<p>The principle behind <code>wildwood</code> - at least in its current iteration - is that for the inference game to work, there has to be, for every entity, a ‘true name’ or unique identifier consensually agreed by each agent for each entity. The parser, obviously, can only parse noun phrases, so to be able to resolve noun phrases to true names there must be an API for the parser to pass a noun phrase, possibly with some context, to a knowledge accessor and receive a true name back.</p></div></div></div></body></html>
|
|
@ -1,3 +1,3 @@
|
||||||
<!DOCTYPE html PUBLIC ""
|
<!DOCTYPE html PUBLIC ""
|
||||||
"">
|
"">
|
||||||
<html><head><meta charset="UTF-8" /><title>wwui.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch current"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.propositions.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>propositions</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="wwui.core.html#var--main"><div class="inner"><span>-main</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">wwui.core</h1><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="public anchor" id="var--main"><h3>-main</h3><div class="usage"><code>(-main & args)</code></div><div class="doc"><div class="markdown"><p>I don’t do a whole lot … yet.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/core.clj#L4">view source</a></div></div></div></body></html>
|
<html><head><meta charset="UTF-8" /><title>wwui.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li><li class="depth-1 "><a href="parsing.html"><div class="inner"><span>Parsing</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch current"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="wwui.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="wwui.core.html#var--main"><div class="inner"><span>-main</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">wwui.core</h1><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="public anchor" id="var--main"><h3>-main</h3><div class="usage"><code>(-main & args)</code></div><div class="doc"><div class="markdown"><p>I don’t do a whole lot … yet.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/core.clj#L4">view source</a></div></div></div></body></html>
|
9
docs/codox/wwui.parser.html
Normal file
9
docs/codox/wwui.parser.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<!DOCTYPE html PUBLIC ""
|
||||||
|
"">
|
||||||
|
<html><head><meta charset="UTF-8" /><title>wwui.parser documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Wwui</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to wwui</span></div></a></li><li class="depth-1 "><a href="parsing.html"><div class="inner"><span>Parsing</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>wwui</span></div></div></li><li class="depth-2 branch"><a href="wwui.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2 current"><a href="wwui.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="wwui.parser.html#var-coll-or-nil.3F"><div class="inner"><span>coll-or-nil?</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-get-sentences"><div class="inner"><span>get-sentences</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-grammar"><div class="inner"><span>grammar</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-identify"><div class="inner"><span>identify</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-name-find"><div class="inner"><span>name-find</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-normalise"><div class="inner"><span>normalise</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-pos-tag"><div class="inner"><span>pos-tag</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-propositions"><div class="inner"><span>propositions</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-propositions-from-file"><div class="inner"><span>propositions-from-file</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-rdp-extend"><div class="inner"><span>rdp-extend</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-rdp-seek"><div class="inner"><span>rdp-seek</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-reparse"><div class="inner"><span>reparse</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-tag"><div class="inner"><span>tag</span></div></a></li><li class="depth-1"><a href="wwui.parser.html#var-tokenize"><div class="inner"><span>tokenize</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">wwui.parser</h1><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="public anchor" id="var-coll-or-nil.3F"><h3>coll-or-nil?</h3><h4 class="type">macro</h4><div class="usage"><code>(coll-or-nil? o)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L100">view source</a></div></div><div class="public anchor" id="var-get-sentences"><h3>get-sentences</h3><div class="usage"></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L13">view source</a></div></div><div class="public anchor" id="var-grammar"><h3>grammar</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The objective of this grammar is to allow us to take a sequence of tagged symbols, and produce a higher-level tagging of parts of speech, and ultimately propositions, from them.</p>
|
||||||
|
<p><em>NOTE THAT</em> tags in this grammar are always keywords, to distinguish them from OpenNLP tags, which tag individual tokens and are represented as strings.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L19">view source</a></div></div><div class="public anchor" id="var-identify"><h3>identify</h3><div class="usage"><code>(identify parse-tree knowledge-accessor)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L154">view source</a></div></div><div class="public anchor" id="var-name-find"><h3>name-find</h3><div class="usage"></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L16">view source</a></div></div><div class="public anchor" id="var-normalise"><h3>normalise</h3><div class="usage"><code>(normalise parse-tree ka)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L161">view source</a></div></div><div class="public anchor" id="var-pos-tag"><h3>pos-tag</h3><div class="usage"></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L15">view source</a></div></div><div class="public anchor" id="var-propositions"><h3>propositions</h3><div class="usage"><code>(propositions tagged-sentence)</code><code>(propositions tagged-sentence knowledge-accessor)</code></div><div class="doc"><div class="markdown"><p>Given a <code>tagged-sentence</code>, return a list of propositions detected in that sentence; if <code>knowledge-accessor</code> is passed, try to resolve names and noun phrases to entities known to that knowledge accessor.</p>
|
||||||
|
<p>TODO: Note that if <code>:subject</code>, <code>:object</code> or <code>:locator</code> resolves to multiple objects, then that is essentially one proposition for each unique combination. This is not yet implemented!</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L194">view source</a></div></div><div class="public anchor" id="var-propositions-from-file"><h3>propositions-from-file</h3><div class="usage"><code>(propositions-from-file file-path)</code></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L215">view source</a></div></div><div class="public anchor" id="var-rdp-extend"><h3>rdp-extend</h3><div class="usage"><code>(rdp-extend tagged-sentence grammar goal)</code></div><div class="doc"><div class="markdown"><p>Seek a phrase which satisfies this <code>goal</code> (expected to be a collection of tags) in this <code>tagged-sentence</code> using this <code>grammar</code>.</p>
|
||||||
|
<p>Return a cons comprising 1. the first matching phrase for the goal, or <code>nil</code> if no match; 2. the tail of the sentence when the parts comprising the phrase are removed.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L105">view source</a></div></div><div class="public anchor" id="var-rdp-seek"><h3>rdp-seek</h3><div class="usage"><code>(rdp-seek tagged-sentence grammar goal)</code></div><div class="doc"><div class="markdown"><p>Seek a phrase which satisfies this <code>goal</code> (expected to be a keyword) in this <code>tagged-sentence</code> using this <code>grammar</code>.</p>
|
||||||
|
<p>Return a cons comprising 1. the first matching phrase for the goal, tagged with the goal, or <code>nil</code> if no match; 2. the tail of the sentence when the parts comprising the phrase are removed.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L72">view source</a></div></div><div class="public anchor" id="var-reparse"><h3>reparse</h3><div class="usage"><code>(reparse tagged-sentence grammar goal)</code></div><div class="doc"><div class="markdown"><p>Reparse this <code>tagged-sentence</code> using this grammar to seek this <code>goal</code>. Parse greedily, seeking the most extended goal.</p>
|
||||||
|
<p>Return a sequence comprising 1. the first matching phrase for the goal, tagged with the goal, or <code>nil</code> if no match; 2. the tail of the sentence when the parts comprising the phrase are removed.</p>
|
||||||
|
<p>This function is called <code>reparse</code> because: 1. it is designed to parse sentences which have already been parsed by OpenNLP: it will not work on raw sentences; 2. it is a recursive descent parser.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L130">view source</a></div></div><div class="public anchor" id="var-tag"><h3>tag</h3><h4 class="type">macro</h4><div class="usage"><code>(tag tagged-token)</code></div><div class="doc"><div class="markdown"><p>The tag, on a <code>tagged-token</code>, is just the second element. Written as a macro for readability.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L94">view source</a></div></div><div class="public anchor" id="var-tokenize"><h3>tokenize</h3><div class="usage"></div><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/wwui/blob/master/src/wwui/parser.clj#L14">view source</a></div></div></div></body></html>
|
|
@ -1,6 +1,6 @@
|
||||||
(ns wwui.propositions-test
|
(ns wwui.parser-test
|
||||||
(:require [clojure.test :refer :all]
|
(:require [clojure.test :refer :all]
|
||||||
[wwui.propositions :refer :all]
|
[wwui.parser :refer :all]
|
||||||
[taoensso.timbre :as log :refer [set-level!]]))
|
[taoensso.timbre :as log :refer [set-level!]]))
|
||||||
|
|
||||||
(log/set-level! :error)
|
(log/set-level! :error)
|
Loading…
Reference in a new issue