UNPKG

tpmkms

Version:

Reusable libraries for Entodicton, a natural language to json converter

1,469 lines 29.6 kB
{ "configs": [ "formulas are concepts", { "name": "formulas", "operators": [ "([formula])", "([solve] (equals/1) ([forVariable|for]) (variable))", "(([formula]) [formulaForVariable|] ([forVariable|]) (variable))", "([calculate] ([expression]))", "(([expression]) [equals] ([expression]))" ], "priorities": [ { "context": [ [ "mathematical_operator", 0 ], [ "number", 0 ] ], "choose": [ 0 ] } ], "semantics": [ { "match": "({context, api}) => context.evaluate && api.get(context)", "apply": "async ({context, api, e}) => {\n const { formula } = api.get(context)\n // console.log('greg24 -----------', JSON.stringify(formula, null, 2))\n context.evalue = await e(formula) \n }" } ], "bridges": [ { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:120", "id": "formulaForVariable", "isA": [ "preposition", "queryable" ], "convolution": true, "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }", "generatorp": "async ({context, g}) => `${await g(context.what)} ${await g(context.equality)} ${await g(context.variable)}`", "evaluator": "({context, api, objects}) => {\n const formulas = api.gets(context.variable).map((f) => { return { ...f.equality, paraphrase: true } })\n context.evalue = { marker: 'list', value: formulas }\n }" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:132", "id": "solve", "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }", "generatorp": "async ({context, gp}) => `${context.word} ${await gp(context.equality)} for ${await gp(context.variable)}`", "semantic": "({context}) => {\n context.response = solveFor(context.equality, context.variable)\n context.isResponse = true\n context.value = null\n if (!context.response) {\n // TODO some KM for talking to the user wrt brief+avatar\n context.verbatim = `Solving failed`\n }\n }" }, { "id": "forVariable", "isA": [ "preposition" ] }, { "id": "formula" }, { "id": "expression", "children": [ "mathematicalExpression", "number" ], "before": [ "verb" ] }, { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:159", "id": "calculate", "isA": [ "verb" ], "bridge": "{ ...next(operator), expression: after[0] }", "generatorp": "async ({context, g}) => `${context.word} ${await g(context.expression)}`", "localHierarchy": [ [ "unknown", "expression" ] ], "semantic": "async ({context, e}) => {\n context.evalue = await e(context.expression)\n context.isResponse = true\n }" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:171", "id": "equals", "bridge": "{ ...next(operator), left: before[0], right: after[0] }", "words": [ "=" ], "after": [ "mathematical_operator" ], "localHierarchy": [ [ "unknown", "expression" ] ], "generatorp": "async ({context, gp}) => `${await gp(context.left)} ${context.word} ${await gp(context.right)}`", "semantic": "({context, api}) => {\n // TODO make sure left is a single name\n // TODO calculate invertable formulas?\n api.add(context.left, context.right, context)\n }" } ] } ], "resultss": [ { "hierarchy": [ [ "a", "article", false ], [ "adjective", "adjective", false ], [ "all", "quantifier", false ], [ "article", "article", false ], [ "ascending", "hierarchyAble", false ], [ "ascending", "isEdee", false ], [ "ascending", "isEder", false ], [ "ascending", "object", false ], [ "ascending", "property", false ], [ "ascending", "queryable", false ], [ "ascending", "sort_ordering", false ], [ "ascending", "theAble", false ], [ "between", "preposition", false ], [ "canBeDoQuestion", "canBeDoQuestion", false ], [ "canBeQuestion", "canBeQuestion", false ], [ "comparable", "theAble", false ], [ "concept", "queryable", false ], [ "concept", "theAble", false ], [ "condition", "condition", false ], [ "countable", "hierarchyAble", false ], [ "descending", "hierarchyAble", false ], [ "descending", "isEdee", false ], [ "descending", "isEder", false ], [ "descending", "object", false ], [ "descending", "property", false ], [ "descending", "queryable", false ], [ "descending", "sort_ordering", false ], [ "descending", "theAble", false ], [ "distributable", "queryable", false ], [ "divideByExpression", "mathematicalExpression", false ], [ "divideByOperator", "mathematical_operator", false ], [ "doubleQuote", "queryable", false ], [ "each", "article", false ], [ "evaluate", "verb", false ], [ "every", "article", false ], [ "hasCountOfPieces", "countable", false ], [ "have", "canBeDoQuestion", false ], [ "have", "canBeQuestion", false ], [ "hierarchyAble", "queryable", false ], [ "highest", "condition", false ], [ "ifAble", "ifAble", false ], [ "integer", "number", false ], [ "is", "canBeQuestion", false ], [ "is", "verb", false ], [ "isEdee", "isEdee", false ], [ "isEder", "isEder", false ], [ "isQuery", "verb", false ], [ "it", "pronoun", false ], [ "it", "queryable", false ], [ "it", "thisitthat", false ], [ "it", "toAble", false ], [ "listable", "theAble", false ], [ "lowest", "condition", false ], [ "mathematical", "hierarchyAble", false ], [ "mathematical", "isEdee", false ], [ "mathematical", "isEder", false ], [ "mathematical", "object", false ], [ "mathematical", "operator_modifier", false ], [ "mathematical", "property", false ], [ "mathematical", "queryable", false ], [ "mathematical", "theAble", false ], [ "mathematicalExpression", "concept", false ], [ "mathematicalExpression", "number", false ], [ "mathematical_operator", "adjective", true ], [ "mathematical_operator", "concept", false ], [ "mathematical_operator", "hierarchyAble", false ], [ "mathematical_operator", "isEdee", false ], [ "mathematical_operator", "isEder", false ], [ "mathematical_operator", "object", false ], [ "mathematical_operator", "operator", false ], [ "mathematical_operator", "property", false ], [ "mathematical_operator", "queryable", false ], [ "mathematical_operator", "theAble", false ], [ "memorable", "theAble", false ], [ "minusExpression", "mathematicalExpression", false ], [ "minusOperator", "mathematical_operator", false ], [ "modifies", "verb", false ], [ "negatable", "queryable", false ], [ "noun", "theAble", false ], [ "number", "quantifier", false ], [ "number", "queryable", false ], [ "object", "listable", false ], [ "object", "queryable", false ], [ "object", "theAble", false ], [ "operator", "concept", false ], [ "operator", "hierarchyAble", false ], [ "operator", "isEdee", false ], [ "operator", "isEder", false ], [ "operator", "object", false ], [ "operator", "property", false ], [ "operator", "queryable", false ], [ "operator", "theAble", false ], [ "operator_modifier", "adjective", false ], [ "orAble", "ifAble", false ], [ "ordering", "concept", false ], [ "ordering", "hierarchyAble", false ], [ "ordering", "isEdee", false ], [ "ordering", "isEder", false ], [ "ordering", "object", false ], [ "ordering", "property", false ], [ "ordering", "queryable", false ], [ "ordering", "theAble", false ], [ "ordering_modifier", "adjective", false ], [ "plusExpression", "mathematicalExpression", false ], [ "plusOperator", "mathematical_operator", false ], [ "preposition", "preposition", false ], [ "pronoun", "pronoun", false ], [ "property", "queryable", false ], [ "property", "theAble", false ], [ "propertyOf", "preposition", false ], [ "punctuation", "punctuation", false ], [ "quantifier", "quantifier", false ], [ "queryable", "listable", false ], [ "questionMark", "punctuation", false ], [ "readonly", "queryable", false ], [ "reason", "queryable", false ], [ "reason", "theAble", false ], [ "remember", "verb", false ], [ "sort", "hierarchyAble", false ], [ "sort", "isEdee", false ], [ "sort", "isEder", false ], [ "sort", "object", false ], [ "sort", "ordering_modifier", false ], [ "sort", "property", false ], [ "sort", "queryable", false ], [ "sort", "theAble", false ], [ "sortOrdering", "adjective", false ], [ "sort_ordering", "adjective", true ], [ "sort_ordering", "concept", false ], [ "sort_ordering", "hierarchyAble", false ], [ "sort_ordering", "isEdee", false ], [ "sort_ordering", "isEder", false ], [ "sort_ordering", "object", false ], [ "sort_ordering", "ordering", false ], [ "sort_ordering", "property", false ], [ "sort_ordering", "queryable", false ], [ "sort_ordering", "theAble", false ], [ "stm_before", "adjective", false ], [ "that", "thisitthat", false ], [ "the", "article", false ], [ "theAble", "queryable", false ], [ "this", "pronoun", false ], [ "this", "queryable", false ], [ "this", "thisitthat", false ], [ "thisitthat", "queryable", false ], [ "timesExpression", "mathematicalExpression", false ], [ "timesOperator", "mathematical_operator", false ], [ "to", "preposition", false ], [ "toAble", "toAble", false ], [ "type", "property", false ], [ "type", "whatAble", false ], [ "unknown", "hierarchyAble", false ], [ "verb", "verb", false ], [ "what", "object", false ], [ "what", "queryable", false ], [ "whatAble", "queryable", false ], [ "whose", "object", false ], [ "x", "number", false ], [ "xfx", "queryable", false ], [ "y", "number", false ] ], "metadata": { "opChoices": [ { "op": [ "unknown", 0 ], "ops": [ [ "is", 0 ], [ "unknown", 0 ], [ "unknown", 0 ] ], "counter": 1 }, { "op": [ "unknown", 0 ], "ops": [ [ "is", 0 ], [ "unknown", 0 ] ], "counter": 2 }, { "op": [ "is", 0 ], "ops": [ [ "is", 0 ] ], "counter": 3 }, { "op": [ "is", 1 ], "ops": [ [ "is", 1 ] ], "counter": 4 } ] }, "trace": "undefined", "contexts": [ { "number": "many", "text": "formulas are concepts", "marker": "is", "word": "are", "range": { "start": 0, "end": 20 }, "one": { "number": "many", "value": "formulas", "unknown": true, "text": "formulas", "marker": "unknown", "word": "formulas", "range": { "start": 0, "end": 20 }, "dead": true, "types": [ "unknown" ], "level": 0 }, "two": { "value": "concepts", "unknown": true, "text": "concepts", "marker": "unknown", "word": "concepts", "range": { "start": 13, "end": 20 }, "dead": true, "types": [ "unknown" ], "level": 0, "concept": true }, "dead": true, "level": 2, "context_index": 1, "topLevel": true, "context_id": 2, "touchedBy": [ "formulas#call2" ] } ], "generated": [ "" ], "paraphrases": [ "formulas are concepts" ], "paraphrasesParenthesized": [], "generatedParenthesized": [], "responses": [ "" ], "associations": [ [ [ "is", 0 ], [ "unknown", 0 ] ] ], "summaries": [ { "summaries": [ { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 7 } }, { "marker": [ "is", 0 ], "range": { "start": 9, "end": 11 } }, { "marker": [ "unknown", 0 ], "range": { "start": 13, "end": 20 } } ], "counter": 1 }, { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 7 } }, { "marker": [ "is", 0 ], "range": { "start": 9, "end": 11 } }, { "marker": [ "unknown", 0 ], "range": { "start": 13, "end": 20 } } ], "counter": 2 }, { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 7 } }, { "marker": [ "is", 0 ], "range": { "start": 9, "end": 11 } }, { "marker": [ "unknown", 0 ], "range": { "start": 13, "end": 20 } } ], "counter": 3 }, { "operators": [ { "marker": [ "is", 1 ], "range": { "start": 0, "end": 20 } } ], "counter": 4 }, { "operators": [ { "marker": [ "is", 2 ], "range": { "start": 0, "end": 20 } } ], "counter": 5 } ], "length": 1 } ], "learned_contextual_priorities": [], "query": "formulas are concepts", "key": { "query": "formulas are concepts" } }, { "extraConfig": true, "name": "formulas", "operators": [ "([formula])", "([solve] (equals/1) ([forVariable|for]) (variable))", "(([formula]) [formulaForVariable|] ([forVariable|]) (variable))", "([calculate] ([expression]))", "(([expression]) [equals] ([expression]))" ], "priorities": [ { "context": [ [ "mathematical_operator", 0 ], [ "number", 0 ] ], "choose": [ 0 ] } ], "semantics": [ { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:109" } ], "bridges": [ { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:120", "id": "formulaForVariable", "isA": [ "preposition", "queryable" ], "convolution": true, "bridge": "{ number: before[0].number, ...next(operator), what: before[0], equality: after[0], variable: after[1] }" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:132", "id": "solve", "bridge": "{ ...next(operator), equality: after[0], variable: after[2] }" }, { "id": "forVariable", "isA": [ "preposition" ] }, { "id": "formula" }, { "id": "expression", "children": [ "mathematicalExpression", "number" ], "before": [ "verb" ] }, { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:159", "id": "calculate", "isA": [ "verb" ], "bridge": "{ ...next(operator), expression: after[0] }", "localHierarchy": [ [ "unknown", "expression" ] ] }, { "where": "/home/dev/code/theprogrammablemind/kms/common/formulas.js:171", "id": "equals", "bridge": "{ ...next(operator), left: before[0], right: after[0] }", "words": [ "=" ], "after": [ "mathematical_operator" ], "localHierarchy": [ [ "unknown", "expression" ] ] } ] } ], "fragments": [], "semantics": [], "associations": [ [ [ "is", 0 ], [ "unknown", 0 ] ] ], "summaries": [ { "summaries": [ { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 7 } }, { "marker": [ "is", 0 ], "range": { "start": 9, "end": 11 } }, { "marker": [ "unknown", 0 ], "range": { "start": 13, "end": 20 } } ], "counter": 1 }, { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 7 } }, { "marker": [ "is", 0 ], "range": { "start": 9, "end": 11 } }, { "marker": [ "unknown", 0 ], "range": { "start": 13, "end": 20 } } ], "counter": 2 }, { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 7 } }, { "marker": [ "is", 0 ], "range": { "start": 9, "end": 11 } }, { "marker": [ "unknown", 0 ], "range": { "start": 13, "end": 20 } } ], "counter": 3 }, { "operators": [ { "marker": [ "is", 1 ], "range": { "start": 0, "end": 20 } } ], "counter": 4 }, { "operators": [ { "marker": [ "is", 2 ], "range": { "start": 0, "end": 20 } } ], "counter": 5 } ], "length": 1 } ], "learned_contextual_priorities": [] }