wwui.parser

TODO: write docs

coll-or-nil?

macro

(coll-or-nil? o)

TODO: write docs

get-sentences

TODO: write docs

grammar

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.

NOTE THAT tags in this grammar are always keywords, to distinguish them from OpenNLP tags, which tag individual tokens and are represented as strings.

identify

(identify parse-tree knowledge-accessor)

TODO: write docs

name-find

TODO: write docs

normalise

(normalise parse-tree ka)

TODO: write docs

pos-tag

TODO: write docs

propositions

(propositions tagged-sentence)(propositions tagged-sentence knowledge-accessor)

Given a tagged-sentence, return a list of propositions detected in that sentence; if knowledge-accessor is passed, try to resolve names and noun phrases to entities known to that knowledge accessor.

TODO: Note that if :subject, :object or :locator resolves to multiple objects, then that is essentially one proposition for each unique combination. This is not yet implemented!

propositions-from-file

(propositions-from-file file-path)

TODO: write docs

rdp-extend

(rdp-extend tagged-sentence grammar goal)

Seek a phrase which satisfies this goal (expected to be a collection of tags) in this tagged-sentence using this grammar.

Return a cons comprising 1. the first matching phrase for the goal, or nil if no match; 2. the tail of the sentence when the parts comprising the phrase are removed.

rdp-seek

(rdp-seek tagged-sentence grammar goal)

Seek a phrase which satisfies this goal (expected to be a keyword) in this tagged-sentence using this grammar.

Return a cons comprising 1. the first matching phrase for the goal, tagged with the goal, or nil if no match; 2. the tail of the sentence when the parts comprising the phrase are removed.

reparse

(reparse tagged-sentence grammar goal)

Reparse this tagged-sentence using this grammar to seek this goal. Parse greedily, seeking the most extended goal.

Return a sequence comprising 1. the first matching phrase for the goal, tagged with the goal, or nil if no match; 2. the tail of the sentence when the parts comprising the phrase are removed.

This function is called reparse 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.

tag

macro

(tag tagged-token)

The tag, on a tagged-token, is just the second element. Written as a macro for readability.

tokenize

TODO: write docs