tpmkms
Version:
Reusable libraries for Entodicton, a natural language to json converter
69 lines (65 loc) • 2.01 kB
JavaScript
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
const { defaultContextCheck } = require('./helpers')
const gdefaults = require("./gdefaults")
const tests = require('./errors.test.json')
const config = {
name: 'errors',
operators: [
{ pattern: "([drop] ([dropable]))", scope: "testing" },
],
bridges: [
{
id: "drop",
bridge: "{ ...next(operator), arg: after[0] }",
scope: "testing"
},
{ id: "dropable", scope: "testing" },
],
semantics: [
{
match: ({context}) => context.interpretation_error,
apply: async ({context, g, gp, verbatim, contexts}) => {
const argument = contexts.find( (argument) => argument.argument_id == context.interpretation_error.argument_id )
verbatim(`Did not know how to understand "${await gp(argument)}" when applying "${await g(context)}"`)
}
},
{
match: ({context}) => context.context?.interpretation_error,
apply: async ({context, g, gp, verbatim, contexts}) => {
context = context.context
const argument = contexts.find( (argument) => argument.argument_id == context.interpretation_error.argument_id )
verbatim(`Did not know how to understand "${await gp(argument)}" when applying "${await g(context)}"`)
}
},
],
};
knowledgeModule({
config,
includes: [gdefaults],
module,
description: 'handling of surfaceable errors',
test: {
name: './errors.test.json',
contents: tests,
checks: {
context: [defaultContextCheck()],
}
/*
checks: {
context: [
...defaultContextCheck(),
{
property: 'quantity',
check: ['marker', 'value'],
},
{
property: 'pieces',
check: [
'marker', 'text',
{ property: 'count', check: ['marker', 'value'] },
]
}]
},
*/
},
})