tpmkms
Version:
Reusable libraries for Entodicton, a natural language to json converter
133 lines (128 loc) • 3.98 kB
JavaScript
const { knowledgeModule, where, stableId, debug } = require('./runtime').theprogrammablemind
const gdefaults = require('./gdefaults.js')
const pos = require('./pos.js')
const { defaultContextCheck } = require('./helpers')
const tests = require('./articles.test.json')
const config = {
name: 'articles',
operators: [
"([thisitthat|])",
"([it])",
"([everything])",
"([queryable])",
"(<each> ([distributable]))",
"(<every> ([distributable]))",
"(<the|> ([theAble]))",
"(<a|a,an> ([theAble|]))",
"(<this> ([thisAble])?)",
"(<that> ([thisAble])?)",
],
associations: {
positive: [
{ context: [['article', 0], ['unknown', 0]], choose: 1 },
{ context: [['article', 0], ['unknown', 1]], choose: 1 },
{ context: [['article', 0], ['theAble', 2]], choose: 1 },
]
},
bridges: [
{
id: 'everything',
},
{
id: 'each',
isA: ['article'],
bridge: '{ ...after[0], focusableForPhrase: true, pullFromContext: true, concept: true, wantsValue: true, distributer: operator, modifiers: append(["distributer"], after[0].modifiers)}'
},
{
id: 'every',
isA: ['article'],
bridge: '{ ...after[0], focusableForPhrase: true, pullFromContext: true, concept: true, wantsValue: true, distributer: operator, modifiers: append(["distributer"], after[0].modifiers)}'
},
{
id: 'distributable',
isA: ['queryable'],
},
{
id: 'the',
isA: ['article'],
localHierarchy: [['unknown', 'theAble']],
level: 0,
bridge: '{ ...after[0], focusableForPhrase: true, pullFromContext: true, concept: true, wantsValue: true, determiner: "the", modifiers: append(["determiner"], after[0].modifiers)}'
},
{
id: "a",
isA: ['article'],
localHierarchy: [['unknown', 'theAble']],
level: 0,
// bridge: "{ ...after[0], pullFromContext: false, instance: true, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
bridge: "{ ...after[0], pullFromContext: false, instance: true, concept: true, number: 'one', wantsValue: true, determiner: operator, modifiers: append(['determiner'], after[0].modifiers) }"
},
{ id: "queryable" },
{
id: "theAble",
children: ['noun'],
},
{
id: "thisitthat",
isA: ['queryable'],
before: ['verb'],
},
{
id: "it",
level: 0,
isA: ['thisitthat'],
bridge: "{ ...next(operator), pullFromContext: true, unknown: true, determined: true }"
},
{
id: "this",
level: 0,
isA: ['thisitthat'],
optional: {
1: "{ ...operator, interpolate: [{property: 'this'}] }",
},
bridge: "{ interpolate: [{property: 'this'}, {property: 'object'}], ...next(after[0]), unknown: true, this: operator, object: after[0], pullFromContext: true }"
},
{
id: "that",
level: 0,
isA: ['thisitthat'],
optional: {
1: "{ ...operator, interpolate: [{property: 'that'}] }",
},
bridge: "{ interpolate: [{property: 'that'}, {property: 'object'}], ...next(after[0]), unknown: true, that: operator, object: after[0], pullFromContext: true }"
},
{
id: "thisAble",
children: ['noun'],
},
],
words: {
"literals": {
"the": [{"id": "the", "initial": "{ modifiers: [] }" }],
}
},
hierarchy: [
['it', 'pronoun'],
['this', 'pronoun'],
// ['questionMark', 'isEd'],
// ['a', 'article'],
// ['the', 'article'],
['it', 'queryable'],
// ['it', 'toAble'],
['this', 'queryable'],
],
};
knowledgeModule( {
config,
includes: [pos, gdefaults],
module,
description: 'articles',
newWay: true,
test: {
name: './articles.test.json',
contents: tests,
checks: {
context: [defaultContextCheck({ extra: ['distributer'] })]
}
},
})