UNPKG

tpmkms

Version:

Reusable libraries for Entodicton, a natural language to json converter

2,697 lines (2,696 loc) 519 kB
{ "configs": [ "amount is a concept", "measurement modifies unit", "dimension and measurement unit are concepts", "unit means measurement unit", { "apply": "({apis}) => {\n apis('properties').addHierarchyWatcher({\n match: ({parentId, isA}) => isA(parentId, 'unit') && parentId.startsWith('unit_'),\n apply: ({config, childId, parent, parentId}) => {\n config.updateBridge(childId, ({ bridge }) => {\n if (!bridge.init) {\n bridge.init = {}\n }\n // bridge.init['dimension'] = parent.object.marker\n bridge.init['dimension'] = parent.object.value\n })\n }\n })\n }" }, "metric modifies system", "imperial modifies system", "measurement modifies system", "the metric system is a measurement system", "the imperial system is a measurement system", "imperial modifies unit", "metric modifies unit", "imperial unit is a unit", "metric unit is a unit", { "name": "dimension", "operators": [ "([quantity])", "([unit])", "((amount/* || number/* || mathematicalExpression/*) [amountOfCoordinate|] ([unit]))", "(([amount]) [unit])", "((@<=quantity || context.possession == true) [convertToUnits|in] (unit))", "([forQuantity|for] (@<= quantity && !context.unit.dimension == null))", "([useUnits|use] (unit))", "([preferredUnits] (quantity))", { "pattern": "([length])", "scope": "testing" } ], "priorities": [ { "context": [ [ "amountOfCoordinate", 0 ], [ "convertToUnits", 0 ] ], "choose": [ 0 ] } ], "hierarchy": [ { "child": "convertToUnits", "parent": "testingValue", "scope": "testing" } ], "generators": [ { "match": "({context}) => context.marker == 'noconversion'", "apply": "async ({context, gp}) => `there is no conversion between ${await gp(context.from)} and ${await gp(context.to)}`" } ], "bridges": [ { "id": "forQuantity", "isA": [ "preposition" ], "bridge": "{ ...operator, quantity: after[0], operator: operator, interpolate: [ { property: 'operator' }, { property: 'quantity' } ] }", "check": [ "marker", "text", "verbatim", "value", "evalue", "isResponse", { "properties": "modifiers" }, { "properties": "postModifiers" }, "quantity" ] }, { "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:199", "id": "preferredUnits", "isA": [ "verb" ], "bridge": "{ ...next(operator), quantity: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'quantity' }] }", "semantic": "async ({context, e, api, toArray, resolveResponse}) => {\n const preferredUnits = await api.getPreferredUnits(context.quantity)\n if (!preferredUnits) {\n return\n }\n const from = context.quantity;\n const value = await e({ marker: 'convertToUnits', from, to: preferredUnits })\n resolveResponse(context, value.evalue)\n }" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:214", "id": "useUnits", "isA": [ "verb" ], "bridge": "{ ...next(operator), units: after[0], operator: operator, interpolate: [{ property: 'operator' }, { property: 'units' }] }", "semantic": "({context, api}) => {\n api.setPreferredUnits(context.units)\n }" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:223", "id": "dimension" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:227", "id": "quantity", "isA": [ "noun" ], "check": [ "marker", "text", "verbatim", "value", "evalue", "isResponse", { "properties": "modifiers" }, { "properties": "postModifiers" }, "amount", "unit" ], "generatorp": "[object Object]", "generatorr": "[object Object]" }, { "id": "length", "isA": [ "dimension" ], "bridge": "{ ...next(operator) }", "scope": "testing" }, { "id": "amountOfCoordinate", "convolution": true, "before": [ "preposition" ], "bridge": "{ marker: next(operator('quantity')), dead: true, unit: after[0], amount: before[0] }" }, { "where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:257", "id": "convertToUnits", "bridge": "{ ...next(operator), from: before[0], to: after[0] }", "isA": [ "expression", "queryable" ], "localHierarchy": [ [ "unknown", "dimension" ] ], "after": [ [ "possession", 0 ], [ "possession", 1 ] ], "generatorp": "async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`", "evaluator": "async ({context, api, toArray, resolveEvaluate}) => {\n const from = context.from;\n const tos = toArray(context.to);\n resolveEvaluate(context, await api.convertToUnits(context, from, tos))\n }" }, { "id": "unit", "isA": [ "mathematicalExpression" ] } ] }, { "operators": [ "([useMeasurementSystem|use] (measurement_system))" ], "bridges": [ { "id": "useMeasurementSystem", "isA": [ "verb" ], "bridge": "{ ...next(operator), system: after[0], interpolate: [ { context: operator }, { property: 'system' } ] }", "semantic": "({context, api}) => {\n api.setMeasurementSystem(context.system.value)\n }", "check": [ "marker", "text", "verbatim", "value", "evalue", "isResponse", { "properties": "modifiers" }, { "properties": "postModifiers" }, "system" ] } ] } ], "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 ], [ "ascending", "thisAble", false ], [ "between", "preposition", false ], [ "calculate", "verb", false ], [ "canBeDoQuestion", "canBeDoQuestion", false ], [ "canBeQuestion", "canBeQuestion", false ], [ "comparable", "theAble", false ], [ "concept", "queryable", false ], [ "concept", "theAble", false ], [ "condition", "concept", false ], [ "condition", "hierarchyAble", false ], [ "condition", "isEdee", false ], [ "condition", "isEder", false ], [ "condition", "object", false ], [ "condition", "property", false ], [ "condition", "queryable", false ], [ "condition", "theAble", false ], [ "condition", "thisAble", false ], [ "countable", "hierarchyAble", false ], [ "deletable", "deletable", false ], [ "delete", "verb", 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 ], [ "descending", "thisAble", false ], [ "distributable", "queryable", false ], [ "divideByExpression", "mathematicalExpression", false ], [ "divideByOperator", "mathematical_operator", false ], [ "doubleQuote", "queryable", false ], [ "each", "article", false ], [ "every", "article", false ], [ "expression", "expression", false ], [ "forVariable", "preposition", false ], [ "formula", "concept", false ], [ "formula", "hierarchyAble", false ], [ "formula", "isEdee", false ], [ "formula", "isEder", false ], [ "formula", "object", false ], [ "formula", "property", false ], [ "formula", "queryable", false ], [ "formula", "theAble", false ], [ "formula", "thisAble", false ], [ "formulaForVariable", "preposition", false ], [ "formulaForVariable", "queryable", false ], [ "hasCountOfPieces", "countable", false ], [ "have", "canBeDoQuestion", false ], [ "have", "canBeQuestion", false ], [ "hierarchyAble", "queryable", false ], [ "highest", "hierarchyAble", false ], [ "highest", "isEdee", false ], [ "highest", "isEder", false ], [ "highest", "object", false ], [ "highest", "property", false ], [ "highest", "queryable", false ], [ "highest", "superlative", false ], [ "highest", "theAble", false ], [ "highest", "thisAble", 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", "hierarchyAble", false ], [ "lowest", "isEdee", false ], [ "lowest", "isEder", false ], [ "lowest", "object", false ], [ "lowest", "property", false ], [ "lowest", "queryable", false ], [ "lowest", "superlative", false ], [ "lowest", "theAble", false ], [ "lowest", "thisAble", 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", "expression", 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 ], [ "maximum", "hierarchyAble", false ], [ "maximum", "isEdee", false ], [ "maximum", "isEder", false ], [ "maximum", "object", false ], [ "maximum", "property", false ], [ "maximum", "queryable", false ], [ "maximum", "superlative", false ], [ "maximum", "theAble", false ], [ "maximum", "thisAble", false ], [ "memorable", "deletable", false ], [ "memorable", "theAble", false ], [ "minimum", "hierarchyAble", false ], [ "minimum", "isEdee", false ], [ "minimum", "isEder", false ], [ "minimum", "object", false ], [ "minimum", "property", false ], [ "minimum", "queryable", false ], [ "minimum", "superlative", false ], [ "minimum", "theAble", false ], [ "minimum", "thisAble", false ], [ "minusExpression", "mathematicalExpression", false ], [ "minusOperator", "mathematical_operator", false ], [ "modifies", "verb", false ], [ "negatable", "queryable", false ], [ "noun", "theAble", false ], [ "noun", "thisAble", false ], [ "number", "expression", 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 ], [ "recall", "verb", 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 ], [ "stm_current", "adjective", false ], [ "stm_previous", "adjective", false ], [ "superlative", "condition", false ], [ "superlative", "hierarchyAble", false ], [ "superlative", "isEdee", false ], [ "superlative", "isEder", false ], [ "superlative", "object", false ], [ "superlative", "property", false ], [ "superlative", "queryable", false ], [ "superlative", "theAble", false ], [ "superlative", "thisAble", false ], [ "that", "thisitthat", false ], [ "the", "article", false ], [ "theAble", "queryable", false ], [ "this", "pronoun", false ], [ "this", "queryable", false ], [ "this", "thisitthat", false ], [ "thisAble", "thisAble", 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": [ [ "a", 0 ], [ "is", 0 ], [ "unknown", 0 ] ], "counter": 1 }, { "op": [ "a", 0 ], "ops": [ [ "a", 0 ], [ "is", 0 ] ], "counter": 2 }, { "op": [ "is", 0 ], "ops": [ [ "is", 0 ] ], "counter": 3 }, { "op": [ "is", 1 ], "ops": [ [ "is", 1 ] ], "counter": 4 } ] }, "trace": "undefined", "contexts": [ { "number": "one", "text": "amount is a concept", "marker": "is", "word": "is", "range": { "start": 0, "end": 18 }, "one": { "number": "one", "value": "amount", "unknown": true, "text": "amount", "marker": "unknown", "word": "amount", "range": { "start": 0, "end": 5 }, "dead": true, "types": [ "unknown" ], "level": 0 }, "two": { "marker": "concept", "value": "concept", "default": true, "text": "a concept", "dead": true, "word": "concept", "range": { "start": 10, "end": 18 }, "types": [ "concept" ], "pullFromContext": false, "instance": true, "concept": true, "number": "one", "wantsValue": true, "determiner": { "marker": "a", "default": true, "word": "a", "text": "a", "range": { "start": 10, "end": 10 }, "level": 0 }, "modifiers": [ "determiner" ], "level": 0 }, "dead": true, "level": 2, "context_index": 1, "topLevel": true, "context_id": 2, "touchedBy": [ "dimension#call2" ] } ], "generated": [ "" ], "paraphrases": [ "amount is a concept" ], "paraphrasesParenthesized": [], "generatedParenthesized": [], "responses": [ "" ], "associations": [ [ [ "a", 0 ], [ "concept", 0 ], [ "is", 0 ], [ "unknown", 0 ] ], [ [ "concept", 0 ], [ "is", 0 ], [ "unknown", 0 ] ] ], "summaries": [ { "summaries": [ { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 5 } }, { "marker": [ "is", 0 ], "range": { "start": 7, "end": 8 } }, { "marker": [ "a", 0 ], "range": { "start": 10, "end": 10 } }, { "marker": [ "concept", 0 ], "range": { "start": 12, "end": 18 } } ], "counter": 1 }, { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 5 } }, { "marker": [ "is", 0 ], "range": { "start": 7, "end": 8 } }, { "marker": [ "a", 0 ], "range": { "start": 10, "end": 10 } }, { "marker": [ "concept", 0 ], "range": { "start": 12, "end": 18 } } ], "counter": 2 }, { "operators": [ { "marker": [ "unknown", 0 ], "range": { "start": 0, "end": 5 } }, { "marker": [ "is", 0 ], "range": { "start": 7, "end": 8 } }, { "marker": [ "concept", 0 ], "range": { "start": 10, "end": 18 } } ], "counter": 3 }, { "operators": [ { "marker": [ "is", 1 ], "range": { "start": 0, "end": 18 } } ], "counter": 4 }, { "operators": [ { "marker": [ "is", 2 ], "range": { "start": 0, "end": 18 } } ], "counter": 5 } ], "length": 1 } ], "learned_contextual_priorities": [], "rtf_associations": [], "query": "amount is a concept", "key": { "query": "amount is a concept" } }, { "hierarchy": [ [ "a", "article", false ], [ "adjective", "adjective", false ], [ "all", "quantifier", false ], [ "amount", "concept", false ], [ "amount", "hierarchyAble", false ], [ "amount", "isEdee", false ], [ "amount", "isEder", false ], [ "amount", "object", false ], [ "amount", "property", false ], [ "amount", "queryable", false ], [ "amount", "theAble", false ], [ "amount", "thisAble", 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 ], [ "ascending", "thisAble", false ], [ "between", "preposition", false ], [ "calculate", "verb", false ], [ "canBeDoQuestion", "canBeDoQuestion", false ], [ "canBeQuestion", "canBeQuestion", false ], [ "comparable", "theAble", false ], [ "concept", "queryable", false ], [ "concept", "theAble", false ], [ "condition", "concept", false ], [ "condition", "hierarchyAble", false ], [ "condition", "isEdee", false ], [ "condition", "isEder", false ], [ "condition", "object", false ], [ "condition", "property", false ], [ "condition", "queryable", false ], [ "condition", "theAble", false ], [ "condition", "thisAble", false ], [ "countable", "hierarchyAble", false ], [ "deletable", "deletable", false ], [ "delete", "verb", 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 ], [ "descending", "thisAble", false ], [ "distributable", "queryable", false ], [ "divideByExpression", "mathematicalExpression", false ], [ "divideByOperator", "mathematical_operator", false ], [ "doubleQuote", "queryable", false ], [ "each", "article", false ], [ "every", "article", false ], [ "expression", "expression", false ], [ "forVariable", "preposition", false ], [ "formula", "concept", false ], [ "formula", "hierarchyAble", false ], [ "formula", "isEdee", false ], [ "formula", "isEder", false ], [ "formula", "object", false ], [ "formula", "property", false ], [ "formula", "queryable", false ], [ "formula", "theAble", false ], [ "formula", "thisAble", false ], [ "formulaForVariable", "preposition", false ], [ "formulaForVariable", "queryable", false ], [ "hasCountOfPieces", "countable", false ], [ "have", "canBeDoQuestion", false ], [ "have", "canBeQuestion", false ], [ "hierarchyAble", "queryable", false ], [ "highest", "hierarchyAble", false ], [ "highest", "isEdee", false ], [ "highest", "isEder", false ], [ "highest", "object", false ], [ "highest", "property", false ], [ "highest", "queryable", false ], [ "highest", "superlative", false ], [ "highest", "theAble", false ], [ "highest", "thisAble", 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", "hierarchyAble", false ], [ "lowest", "isEdee", false ], [ "lowest", "isEder", false ], [ "lowest", "object", false ], [ "lowest", "property", false ], [ "lowest", "queryable", false ], [ "lowest", "superlative", false ], [ "lowest", "theAble", false ], [ "lowest", "thisAble", 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", "expression", 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 ], [ "maximum", "hierarchyAble", false ], [ "maximum", "isEdee", false ], [ "maximum", "isEder", false ], [ "maximum", "object", false ], [ "maximum", "property", false ], [ "maximum", "queryable", false ], [ "maximum", "superlative", false ], [ "maximum", "theAble", false ], [ "maximum", "thisAble", false ], [ "memorable", "deletable", false ], [ "memorable", "theAble", false ], [ "minimum", "hierarchyAble", false ], [ "minimum", "isEdee", false ], [ "minimum", "isEder", false ], [ "minimum", "object", false ], [ "minimum", "property", false ], [ "minimum", "queryable", false ], [ "minimum", "superlative", false ], [ "minimum", "theAble", false ], [ "minimum", "thisAble", false ], [ "minusExpression", "mathematicalExpression", false ], [ "minusOperator", "mathematical_operator", false ], [ "modifies", "verb", false ], [ "negatable", "queryable", false ], [ "noun", "theAble", false ], [ "noun", "thisAble", false ], [ "number", "expression", 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 ], [ "recall", "verb", false