theprogrammablemind_4wp 7.4.3-beta.9 → 7.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +70 -28
- package/package.json +1 -1
- package/src/config.js +45 -13
- package/src/generators.js +4 -2
- package/src/helpers.js +32 -1
- package/src/semantics.js +4 -2
    
        package/client.js
    CHANGED
    
    | @@ -692,10 +692,23 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug | |
| 692 692 | 
             
                  const failed_responses = !matching(result.responses, expected.responses)
         | 
| 693 693 | 
             
                  const failed_contexts = !matching(result.contexts, expected.contexts)
         | 
| 694 694 | 
             
                  const failed_objects = !matching(actual_objects, expected_objects)
         | 
| 695 | 
            +
             | 
| 696 | 
            +
                  const pickEm = (objects) => {
         | 
| 697 | 
            +
                    const picked = {}
         | 
| 698 | 
            +
                    for (let prop of (testConfig.check || [])) {
         | 
| 699 | 
            +
                      picked[prop] = objects[prop]
         | 
| 700 | 
            +
                    }
         | 
| 701 | 
            +
                    return picked
         | 
| 702 | 
            +
                  }
         | 
| 703 | 
            +
                  const expected_checked = sortJson(pickEm(expected.objects.namespaced[0]), { depth: 25 })
         | 
| 704 | 
            +
                  const actual_checked = sortJson(pickEm(objects), { depth: 25 })
         | 
| 705 | 
            +
                  const failed_checked = !matching(actual_objects, expected_objects)
         | 
| 706 | 
            +
             | 
| 707 | 
            +
                  const failed_checks = !matching(actual_objects, expected_objects)
         | 
| 695 708 | 
             
                  const actual_config = sortJson(convertToStable(getConfigForTest(config, testConfig)), { depth: 25 })
         | 
| 696 709 | 
             
                  const expected_config = sortJson(convertToStable(expected.config), { depth: 25 })
         | 
| 697 710 | 
             
                  const failed_config = !matching(actual_config, expected_config)
         | 
| 698 | 
            -
                  let failed = failed_paraphrases || failed_responses || failed_contexts || failed_objects || failed_config
         | 
| 711 | 
            +
                  let failed = failed_paraphrases || failed_responses || failed_contexts || failed_objects || failed_config || failed_checked
         | 
| 699 712 | 
             
                  if (!failed) {
         | 
| 700 713 | 
             
                    if (config.afterTest) {
         | 
| 701 714 | 
             
                      failed = config.afterTest({ query: test, expected, actual: result, config })
         | 
| @@ -703,8 +716,8 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug | |
| 703 716 | 
             
                        return {
         | 
| 704 717 | 
             
                          utterance: test,
         | 
| 705 718 | 
             
                          errorFromAfterTest: failed,
         | 
| 706 | 
            -
                          expected: { responses: expected.responses, paraphrases: expected.paraphrases, results: expected.contexts, objects: expected_objects, config: expected.config },
         | 
| 707 | 
            -
                          actual: { responses: result.responses, paraphrases: result.paraphrases, results: result.contexts, objects: actual_objects, config: actual_config }
         | 
| 719 | 
            +
                          expected: { responses: expected.responses, paraphrases: expected.paraphrases, results: expected.contexts, checked: expected_checked, objects: expected_objects, config: expected.config },
         | 
| 720 | 
            +
                          actual: { responses: result.responses, paraphrases: result.paraphrases, results: result.contexts, checked: actual_checked, objects: actual_objects, config: actual_config }
         | 
| 708 721 | 
             
                        }
         | 
| 709 722 | 
             
                      }
         | 
| 710 723 | 
             
                    }
         | 
| @@ -720,8 +733,8 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug | |
| 720 733 | 
             
                  if (failed) {
         | 
| 721 734 | 
             
                    return {
         | 
| 722 735 | 
             
                      utterance: test,
         | 
| 723 | 
            -
                      expected: { responses: expected.responses, paraphrases: expected.paraphrases, results: expected.contexts, objects: expected_objects, config: expected.config },
         | 
| 724 | 
            -
                      actual: { responses: result.responses, paraphrases: result.paraphrases, results: result.contexts, objects: actual_objects, config: actual_config }
         | 
| 736 | 
            +
                      expected: { responses: expected.responses, paraphrases: expected.paraphrases, results: expected.contexts, checked: expected_checked, objects: expected_objects, config: expected.config },
         | 
| 737 | 
            +
                      actual: { responses: result.responses, paraphrases: result.paraphrases, results: result.contexts, checked: actual_checked, objects: actual_objects, config: actual_config }
         | 
| 725 738 | 
             
                    }
         | 
| 726 739 | 
             
                  }
         | 
| 727 740 | 
             
                } catch(error) {
         | 
| @@ -1254,7 +1267,7 @@ const knowledgeModule = async ({ | |
| 1254 1267 | 
             
                parser.add_argument('-q', '--query', { help: 'Run the specified query' })
         | 
| 1255 1268 | 
             
                parser.add_argument('-ip ', '--server', { help: 'Server to run against' })
         | 
| 1256 1269 | 
             
                parser.add_argument('-qp ', '--queryParams', { help: 'Query params for the server call' })
         | 
| 1257 | 
            -
                parser.add_argument('- | 
| 1270 | 
            +
                parser.add_argument('-td', '--testDelete', { help: 'Delete the specified query from the tests file.' })
         | 
| 1258 1271 | 
             
                parser.add_argument('-c', '--clean', { help: 'Remove data from the test files. a === association' })
         | 
| 1259 1272 | 
             
                parser.add_argument('-od', '--objectDiff', { action: 'store_true', help: 'When showing the objects use a colour diff' })
         | 
| 1260 1273 | 
             
                parser.add_argument('-daa', '--dontAddAssociations', { action: 'store_true', help: 'Do not add associations from the tests.' })
         | 
| @@ -1293,11 +1306,11 @@ const knowledgeModule = async ({ | |
| 1293 1306 | 
             
                  return
         | 
| 1294 1307 | 
             
                }
         | 
| 1295 1308 |  | 
| 1296 | 
            -
                if (args. | 
| 1309 | 
            +
                if (args.testDelete) {
         | 
| 1297 1310 | 
             
                  let tests = JSON.parse(runtime.fs.readFileSync(testConfig.name))
         | 
| 1298 | 
            -
                  tests = tests.filter( (test) => test.query !== args. | 
| 1311 | 
            +
                  tests = tests.filter( (test) => test.query !== args.testDelete );
         | 
| 1299 1312 | 
             
                  writeTestFile(testConfig.name, tests)
         | 
| 1300 | 
            -
                  console.log(`Remove the test for "${args. | 
| 1313 | 
            +
                  console.log(`Remove the test for "${args.testDelete}"`)
         | 
| 1301 1314 | 
             
                  return
         | 
| 1302 1315 | 
             
                }
         | 
| 1303 1316 |  | 
| @@ -1462,34 +1475,63 @@ const knowledgeModule = async ({ | |
| 1462 1475 | 
             
                        let newError = false
         | 
| 1463 1476 | 
             
                        if (results.length > 0) {
         | 
| 1464 1477 | 
             
                          let headerShown = false
         | 
| 1465 | 
            -
             | 
| 1478 | 
            +
             | 
| 1479 | 
            +
                          let hasError = false
         | 
| 1466 1480 | 
             
                          for (const result of results) {
         | 
| 1467 | 
            -
                            console.log('Utterance: ', result.utterance)
         | 
| 1468 1481 | 
             
                            if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
         | 
| 1469 | 
            -
                               | 
| 1470 | 
            -
                                console.log('  Failure')
         | 
| 1471 | 
            -
                              }
         | 
| 1472 | 
            -
                              console.log('    expected paraphrases', result.expected.paraphrases)
         | 
| 1473 | 
            -
                              console.log('    actual paraphrases  ', result.actual.paraphrases)
         | 
| 1474 | 
            -
                              newError = true
         | 
| 1475 | 
            -
                              headerShown = true
         | 
| 1482 | 
            +
                              hasError = true
         | 
| 1476 1483 | 
             
                            }
         | 
| 1477 1484 | 
             
                            if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
         | 
| 1478 | 
            -
                               | 
| 1479 | 
            -
             | 
| 1485 | 
            +
                              hasError = true
         | 
| 1486 | 
            +
                            }
         | 
| 1487 | 
            +
                            if (JSON.stringify(result.expected.checked) !== JSON.stringify(result.actual.checked)) {
         | 
| 1488 | 
            +
                              hasError = true
         | 
| 1489 | 
            +
                            }
         | 
| 1490 | 
            +
                          }
         | 
| 1491 | 
            +
             | 
| 1492 | 
            +
                          if (hasError) {
         | 
| 1493 | 
            +
                            console.log('**************************** ERRORS ************************')
         | 
| 1494 | 
            +
                            for (const result of results) {
         | 
| 1495 | 
            +
                              console.log('Utterance: ', result.utterance)
         | 
| 1496 | 
            +
                              if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
         | 
| 1497 | 
            +
                                if (!headerShown) {
         | 
| 1498 | 
            +
                                  console.log('  Failure')
         | 
| 1499 | 
            +
                                }
         | 
| 1500 | 
            +
                                console.log('    expected paraphrases', result.expected.paraphrases)
         | 
| 1501 | 
            +
                                console.log('    actual paraphrases  ', result.actual.paraphrases)
         | 
| 1502 | 
            +
                                newError = true
         | 
| 1503 | 
            +
                                headerShown = true
         | 
| 1504 | 
            +
                              }
         | 
| 1505 | 
            +
                              if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
         | 
| 1506 | 
            +
                                if (!headerShown) {
         | 
| 1507 | 
            +
                                  console.log('  Failure')
         | 
| 1508 | 
            +
                                }
         | 
| 1509 | 
            +
                                console.log('    expected responses  ', result.expected.responses)
         | 
| 1510 | 
            +
                                console.log('    actual responses    ', result.actual.responses)
         | 
| 1511 | 
            +
                                newError = true
         | 
| 1512 | 
            +
                                headerShown = true
         | 
| 1513 | 
            +
                              }
         | 
| 1514 | 
            +
                              if (JSON.stringify(result.expected.checked) !== JSON.stringify(result.actual.checked)) {
         | 
| 1515 | 
            +
                                if (!headerShown) {
         | 
| 1516 | 
            +
                                  console.log('  Failure')
         | 
| 1517 | 
            +
                                }
         | 
| 1518 | 
            +
                                console.log('    expected checked', result.expected.checked)
         | 
| 1519 | 
            +
                                console.log('    actual checked  ', result.actual.checked)
         | 
| 1520 | 
            +
                                newError = true
         | 
| 1521 | 
            +
                                headerShown = true
         | 
| 1480 1522 | 
             
                              }
         | 
| 1481 | 
            -
                              console.log('    expected responses  ', result.expected.responses)
         | 
| 1482 | 
            -
                              console.log('    actual responses    ', result.actual.responses)
         | 
| 1483 | 
            -
                              newError = true
         | 
| 1484 | 
            -
                              headerShown = true
         | 
| 1485 1523 | 
             
                            }
         | 
| 1486 1524 | 
             
                          }
         | 
| 1487 1525 | 
             
                          if (!headerShown) {
         | 
| 1488 | 
            -
                             | 
| 1526 | 
            +
                            if (!(testConfig.check && testConfig.check.length > 0)) {
         | 
| 1527 | 
            +
                              console.log('There are failures due to things other than paraphrases, responses and checked properties being different. They are not shown because you ran -tv or -tva which only shows difference in paraphrase and results. Usually what I do is -s and do a diff to make sure there are no other problems. If the paraphrases or results were different they would have shown here.')
         | 
| 1528 | 
            +
                            }
         | 
| 1529 | 
            +
                          }
         | 
| 1530 | 
            +
                          if (!(testConfig.check && testConfig.check.length > 0)) {
         | 
| 1531 | 
            +
                            console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
         | 
| 1532 | 
            +
                            // console.log(JSON.stringify(contexts))
         | 
| 1533 | 
            +
                            console.log('**************************** ERRORS ************************')
         | 
| 1489 1534 | 
             
                          }
         | 
| 1490 | 
            -
                          console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
         | 
| 1491 | 
            -
                          // console.log(JSON.stringify(contexts))
         | 
| 1492 | 
            -
                          console.log('**************************** ERRORS ************************')
         | 
| 1493 1535 | 
             
                        }
         | 
| 1494 1536 | 
             
                        // const contexts = { failures: results }
         | 
| 1495 1537 | 
             
                        l(n - 1, hasError || newError)
         | 
    
        package/package.json
    CHANGED
    
    
    
        package/src/config.js
    CHANGED
    
    | @@ -412,11 +412,11 @@ class Config { | |
| 412 412 | 
             
              }
         | 
| 413 413 |  | 
| 414 414 | 
             
              getSemantics (logs = []) {
         | 
| 415 | 
            -
                return new Semantics(this.config.semantics || [], logs)
         | 
| 415 | 
            +
                return new Semantics(this.config.semantics || [], logs, { km: this.name })
         | 
| 416 416 | 
             
              }
         | 
| 417 417 |  | 
| 418 418 | 
             
              getGenerators (logs = []) {
         | 
| 419 | 
            -
                return new Generators(this.config.generators || [], logs)
         | 
| 419 | 
            +
                return new Generators(this.config.generators || [], logs, { km: this.name })
         | 
| 420 420 | 
             
              }
         | 
| 421 421 |  | 
| 422 422 | 
             
              warningNotEvaluated (log, value) {
         | 
| @@ -979,6 +979,35 @@ class Config { | |
| 979 979 | 
             
                  throw 'Excepted the config argument to be a hash not a Config object'
         | 
| 980 980 | 
             
                }
         | 
| 981 981 |  | 
| 982 | 
            +
                if (config) {
         | 
| 983 | 
            +
                  const valid = [ 
         | 
| 984 | 
            +
                    'hierarchy', 
         | 
| 985 | 
            +
                    'objects', 
         | 
| 986 | 
            +
                    'bridges', 
         | 
| 987 | 
            +
                    'operators', 
         | 
| 988 | 
            +
                    'words', 
         | 
| 989 | 
            +
                    'priorities', 
         | 
| 990 | 
            +
                    'associations', 
         | 
| 991 | 
            +
                    'name', 
         | 
| 992 | 
            +
                    'version', 
         | 
| 993 | 
            +
                    'generators', 
         | 
| 994 | 
            +
                    'semantics', 
         | 
| 995 | 
            +
                    'floaters', 
         | 
| 996 | 
            +
                    'debug',
         | 
| 997 | 
            +
             | 
| 998 | 
            +
                    // TODO Fix these from the test app
         | 
| 999 | 
            +
                    'implicit',
         | 
| 1000 | 
            +
                    'expected_generated',
         | 
| 1001 | 
            +
                    'expected_results',
         | 
| 1002 | 
            +
                    'skipSemantics',
         | 
| 1003 | 
            +
                    'description',
         | 
| 1004 | 
            +
                    'contexts',
         | 
| 1005 | 
            +
                    'utterances',
         | 
| 1006 | 
            +
                    'flatten',
         | 
| 1007 | 
            +
                  ]
         | 
| 1008 | 
            +
                  helpers.validProps(valid, config, 'config')
         | 
| 1009 | 
            +
                }
         | 
| 1010 | 
            +
             | 
| 982 1011 | 
             
                this.allowDelta = false
         | 
| 983 1012 | 
             
                this.resetDelta()
         | 
| 984 1013 |  | 
| @@ -1030,7 +1059,8 @@ class Config { | |
| 1030 1059 | 
             
                normalizeConfig(config)
         | 
| 1031 1060 |  | 
| 1032 1061 | 
             
                // set the default server so stuff just works
         | 
| 1033 | 
            -
                this.server(' | 
| 1062 | 
            +
                // this.server('https://184.67.27.82:3000', '6804954f-e56d-471f-bbb8-08e3c54d9321')
         | 
| 1063 | 
            +
                this.server('https://thinktelligence.com:3000', '6804954f-e56d-471f-bbb8-08e3c54d9321')
         | 
| 1034 1064 |  | 
| 1035 1065 | 
             
                this.defaultConfig()
         | 
| 1036 1066 | 
             
                this.initializerFn = ({ currentConfig }) => {
         | 
| @@ -1063,15 +1093,9 @@ class Config { | |
| 1063 1093 | 
             
                    // this.config.words = {}
         | 
| 1064 1094 | 
             
                  }
         | 
| 1065 1095 | 
             
                  for (let bridge of (this.config.bridges || [])) {
         | 
| 1066 | 
            -
                    const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', ' | 
| 1067 | 
            -
                                    'level', 'optional', 'selector', 'semantic',  'words' ]
         | 
| 1068 | 
            -
                     | 
| 1069 | 
            -
                      if (!valid.includes(prop)) {
         | 
| 1070 | 
            -
                        if (!prop.endsWith("Bridge")) {
         | 
| 1071 | 
            -
                          throw `Unknown property "${prop}" in the bridge. Valid properties are ${valid}. The bridge is ${JSON.stringify(bridge)}`
         | 
| 1072 | 
            -
                        }
         | 
| 1073 | 
            -
                      }
         | 
| 1074 | 
            -
                    }
         | 
| 1096 | 
            +
                    const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'inverted', 'isA',
         | 
| 1097 | 
            +
                                    'level', 'optional', 'selector', 'semantic',  'words', /Bridge$/, 'localHierarchy' ]
         | 
| 1098 | 
            +
                    helpers.validProps(valid, bridge, 'bridge')
         | 
| 1075 1099 | 
             
                    /*
         | 
| 1076 1100 | 
             
                    if (bridge.generator) {
         | 
| 1077 1101 | 
             
                      this.config.generators.push({ 
         | 
| @@ -1087,6 +1111,9 @@ class Config { | |
| 1087 1111 | 
             
                    }
         | 
| 1088 1112 | 
             
                    if (bridge.before) {
         | 
| 1089 1113 | 
             
                      for (let after of bridge.before) {
         | 
| 1114 | 
            +
                        if (typeof after == 'string') {
         | 
| 1115 | 
            +
                          after = [after, 0]
         | 
| 1116 | 
            +
                        }
         | 
| 1090 1117 | 
             
                        this.addPriorities([after, [bridge.id, bridge.level]])
         | 
| 1091 1118 | 
             
                      }
         | 
| 1092 1119 | 
             
                    }
         | 
| @@ -1238,6 +1265,10 @@ class Config { | |
| 1238 1265 | 
             
              }
         | 
| 1239 1266 |  | 
| 1240 1267 | 
             
              set api (value) {
         | 
| 1268 | 
            +
                if (!value.initialize) {
         | 
| 1269 | 
            +
                  throw `Expected the API to have an initialize function for ${this.name}.`
         | 
| 1270 | 
            +
                }
         | 
| 1271 | 
            +
             | 
| 1241 1272 | 
             
                if (this._api && this._api.multiApi) {
         | 
| 1242 1273 | 
             
                  this._api.add(this, this._api, value)
         | 
| 1243 1274 | 
             
                } else {
         | 
| @@ -1755,7 +1786,8 @@ class Config { | |
| 1755 1786 | 
             
                  config.wasInitialized = false
         | 
| 1756 1787 | 
             
                  // TODO change name of config: to baseConfig:
         | 
| 1757 1788 | 
             
                  const kmFn = (name) => this.getConfig(name)
         | 
| 1758 | 
            -
                  const  | 
| 1789 | 
            +
                  const hierarchy = new Digraph((config.config || {}).hierarchy || [])
         | 
| 1790 | 
            +
                  const args = { isModule, addWord: aw, km: kmFn, hierarchy, config, baseConfig: this, currentConfig: config, uuid: config._uuid, objects: namespacedObjects, namespace, api: config.api }
         | 
| 1759 1791 | 
             
                  config.initializerFn(args)
         | 
| 1760 1792 | 
             
                  if (config.initAfterApi) {
         | 
| 1761 1793 | 
             
                    initAfterApis.push({ config, args })
         | 
    
        package/src/generators.js
    CHANGED
    
    | @@ -124,12 +124,14 @@ class Generator { | |
| 124 124 | 
             
            }
         | 
| 125 125 |  | 
| 126 126 | 
             
            class Generators {
         | 
| 127 | 
            -
              constructor (generators, logs = []) {
         | 
| 127 | 
            +
              constructor (generators, logs = [], options = {}) {
         | 
| 128 | 
            +
                let index = -1
         | 
| 128 129 | 
             
                generators = (generators || []).map((generator) => {
         | 
| 129 130 | 
             
                  if (generator instanceof Generator) {
         | 
| 130 131 | 
             
                    return generator
         | 
| 131 132 | 
             
                  } else {
         | 
| 132 | 
            -
                     | 
| 133 | 
            +
                    index += 1
         | 
| 134 | 
            +
                    return new Generator({ km: options.km, index, ...normalizeGenerator(generator) })
         | 
| 133 135 | 
             
                  }
         | 
| 134 136 | 
             
                })
         | 
| 135 137 | 
             
                this.defaults = []
         | 
    
        package/src/helpers.js
    CHANGED
    
    | @@ -217,4 +217,35 @@ const sortJson = (json) => { | |
| 217 217 | 
             
              return json
         | 
| 218 218 | 
             
            }
         | 
| 219 219 |  | 
| 220 | 
            -
             | 
| 220 | 
            +
            const validProps = (valids, object, type) => {
         | 
| 221 | 
            +
              for (let prop of Object.keys(object)) {
         | 
| 222 | 
            +
                let okay = false
         | 
| 223 | 
            +
                for (valid of valids) {
         | 
| 224 | 
            +
                  if (prop.match(valid)) {
         | 
| 225 | 
            +
                    okay = true
         | 
| 226 | 
            +
                    break
         | 
| 227 | 
            +
                  }
         | 
| 228 | 
            +
                }
         | 
| 229 | 
            +
                if (!okay) {
         | 
| 230 | 
            +
                  throw `Unknown property "${prop}" in the ${type}. Valid properties are ${valid}. The ${type} is ${JSON.stringify(object)}`
         | 
| 231 | 
            +
                }
         | 
| 232 | 
            +
              }
         | 
| 233 | 
            +
            }
         | 
| 234 | 
            +
             | 
| 235 | 
            +
            module.exports = { 
         | 
| 236 | 
            +
              validProps, 
         | 
| 237 | 
            +
              args, 
         | 
| 238 | 
            +
              safeEquals, 
         | 
| 239 | 
            +
              appendNoDups, 
         | 
| 240 | 
            +
              hashIndexesGet, 
         | 
| 241 | 
            +
              hashIndexesSet, 
         | 
| 242 | 
            +
              translationMapping, 
         | 
| 243 | 
            +
              normalizeGenerator, 
         | 
| 244 | 
            +
              normalizeSemantic, 
         | 
| 245 | 
            +
              isArray, 
         | 
| 246 | 
            +
              isObject, 
         | 
| 247 | 
            +
              isCompound, 
         | 
| 248 | 
            +
              InitCalls, 
         | 
| 249 | 
            +
              hashCode, 
         | 
| 250 | 
            +
              sortJson 
         | 
| 251 | 
            +
            }
         | 
    
        package/src/semantics.js
    CHANGED
    
    | @@ -115,12 +115,14 @@ class Semantic { | |
| 115 115 | 
             
            }
         | 
| 116 116 |  | 
| 117 117 | 
             
            class Semantics {
         | 
| 118 | 
            -
              constructor (semantics, logs = []) {
         | 
| 118 | 
            +
              constructor (semantics, logs = [], options = {}) {
         | 
| 119 | 
            +
                let index = -1
         | 
| 119 120 | 
             
                semantics = semantics.map((semantic) => {
         | 
| 120 121 | 
             
                  if (semantic instanceof Semantic) {
         | 
| 121 122 | 
             
                    return semantic
         | 
| 122 123 | 
             
                  } else {
         | 
| 123 | 
            -
                     | 
| 124 | 
            +
                    index += 1
         | 
| 125 | 
            +
                    return new Semantic({ km: options.km, index, ...normalizeSemantic(semantic) })
         | 
| 124 126 | 
             
                  }
         | 
| 125 127 | 
             
                })
         | 
| 126 128 |  |