{"_id":"@agarimo/pattern","name":"@agarimo/pattern","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@agarimo/pattern","version":"1.0.0","description":"Build several strings from a pattern using cartesian product","main":"src/index.js","scripts":{"test":"eslint --fix . && jest --silent --coverage --maxWorkers=4 ."},"repository":{"type":"git","url":"git+https://github.com/agarimojs/pattern.git"},"author":{"name":"Jesus Seijas","email":"jseijas@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/agarimojs/pattern/issues"},"homepage":"https://github.com/agarimojs/pattern#readme","devDependencies":{"eslint":"^8.12.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-import":"^2.26.0","eslint-plugin-jest":"^26.1.3","eslint-plugin-prettier":"^4.0.0","jest":"^27.5.1","prettier":"^2.6.2"},"publishConfig":{"access":"public"},"dependencies":{"@agarimo/cartesian":"^1.0.1"},"gitHead":"ebe181cde50048be3c04dfb0cf075a1e9dbd0b1c","_id":"@agarimo/pattern@1.0.0","_nodeVersion":"15.14.0","_npmVersion":"7.7.6","dist":{"integrity":"sha512-CPvF9lXGu91bG5UjwGWhvABYJsxhxQU4WGjEWzal215W+xFsXp3YJmYG98iEF7QRQH+wF6xPjZNDVeumoJIZ9Q==","shasum":"b93a1de2a699e5817415ac1f4c1cecd9a4f461b6","tarball":"https://registry.npmjs.org/@agarimo/pattern/-/pattern-1.0.0.tgz","fileCount":9,"unpackedSize":11610,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB0RCCXkRFdUFJpMlKLYtTSde8FW521+1sS9DCSVyy7CAiEA+Et5v6n7W7abaVToRvm29fweQnu1O3INus4UeCcBuaU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiWlvnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp+rg//e9yU92f1QU5InYnBY3WD8VRl5+BU1YY0kOeP+yUTEDeaM7K2\r\n04M8FtMEYORDXq0Aq73tfnW7PkeuWwPBGOb0lA8oCwmk5jIM1/AQwsZWkZ75\r\non8Ab37lMnSNY22D6QrtL3xdndUMWpKa8Xqhp92BzB7mew3cFWQAPFPZzTjb\r\nu/SRYG0IR7zCsSyaL65eTWf2pL7hfa9DcITpe9m89t+y88rgkrHRHUa0oTMp\r\nVfxDtIgQmengr305y6cs7sdp8JqW+sH60IHiTBNGHH+b61KdunVoR7Evej+Y\r\nJOa+J23O5d02Cu6oz4JBKS2CuCPG86L5vaFczmF9rPnCcpRRWmZZzwqouL1h\r\nPj/jTaGRxdLQ9VyA98JHReW9ZUPLOthjnJYqJymIAsL3jR1kWJ8Vg6fPcoBU\r\np04CGfxT2uSbZ9ZIL5dnIhu85crPRVBJeRMEemy4crcUWjB2t+5sjRafT35R\r\nL/aJSjKWUxShiDhyZV24H/3W/2uygJFLpnTL4VQ4gB+oAwiGXt6m9kqKPhal\r\n23HSOxp1IWQQwPP7U+f5Qd+uokoWE/nMFjgjmuVlt0/oDtQqo7Mxu2noMzT2\r\nNvVxZqYr0IUOdVH/gCFZsAIUEx2HUSFp0+BaVp+NxWpm0Y9SUs3IImRP5IFv\r\nzSrKQnfaffZYySJ2WLPP/KtIrnLFFivmVOY=\r\n=7i0k\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"jesus-seijas","email":"jseijas@gmail.com"},"directories":{},"maintainers":[{"name":"jesus-seijas","email":"jseijas@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pattern_1.0.0_1650088935141_0.606294134596894"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-16T06:02:15.076Z","1.0.0":"2022-04-16T06:02:15.386Z","modified":"2022-04-16T06:02:15.521Z"},"maintainers":[{"name":"jesus-seijas","email":"jseijas@gmail.com"}],"description":"Build several strings from a pattern using cartesian product","homepage":"https://github.com/agarimojs/pattern#readme","repository":{"type":"git","url":"git+https://github.com/agarimojs/pattern.git"},"author":{"name":"Jesus Seijas","email":"jseijas@gmail.com"},"bugs":{"url":"https://github.com/agarimojs/pattern/issues"},"license":"MIT","readme":"# pattern\nBuild several strings from a pattern using cartesian product\n\n## Example\n\nIt's able to build an array of strings as the cartesian product from the options described in the pattern string.\nTo add options in the pattern, use text between brackets and separated by |\n\n\n```javascript\nconst { composeFromPattern } = require('@agarimo/pattern');\n\nconst input = 'I [am having|have] a [problem|question] that I have to [solve|investigate]';\nconst actual = composeFromPattern(input);\nconsole.log(actual);\n// [\n//   'I am having a problem that I have to solve',\n//   'I am having a problem that I have to investigate',\n//   'I am having a question that I have to solve',\n//   'I am having a question that I have to investigate',\n//   'I have a problem that I have to solve',\n//   'I have a problem that I have to investigate',\n//   'I have a question that I have to solve',\n//   'I have a question that I have to investigate'\n// ]\n```\n\n## Example with corpus\n\nIt's able to build strings from patterns in a corpus like object. It will apply to the patterns found at the data array of the object, for utterances, tests and answers.\n\n```javascript\nconst { composeCorpus } = require('@agarimo/pattern');\n\nconst input = {\n  name: 'Corpus Pattern',\n  locale: 'en-US',\n  data: [\n    {\n      intent: 'test1',\n      utterances: ['this is [great|nice|perfect]', 'this is a test'],\n      tests: ['this should be [great|nice|perfect]'],\n    },\n    {\n      intent: 'test2',\n      utterances: [\n        'I [am having|have] a [problem|question] that have to [solve|investigate]',\n        'We should investigate',\n      ],\n      tests: ['Investigate this'],\n      answers: [],\n    },\n  ],\n};\nconst actual = composeCorpus(input);\nconsole.log(JSON.stringify(actual, null, 2));\n// {                                                             \n//   \"name\": \"Corpus Pattern\",                                   \n//   \"locale\": \"en-US\",                                          \n//   \"data\": [                                                   \n//     {                                                         \n//       \"intent\": \"test1\",                                      \n//       \"utterances\": [                                         \n//         \"this is great\",                                      \n//         \"this is nice\",                                       \n//         \"this is perfect\",                                    \n//         \"this is a test\"                                      \n//       ],                                                      \n//       \"tests\": [                                              \n//         \"this should be great\",                               \n//         \"this should be nice\",                                \n//         \"this should be perfect\"                              \n//       ]                                                       \n//     },                                                        \n//     {                                                         \n//       \"intent\": \"test2\",                                      \n//       \"utterances\": [                                         \n//         \"I am having a problem that have to solve\",           \n//         \"I am having a problem that have to investigate\",     \n//         \"I am having a question that have to solve\",          \n//         \"I am having a question that have to investigate\",    \n//         \"I have a problem that have to solve\",                \n//         \"I have a problem that have to investigate\",          \n//         \"I have a question that have to solve\",               \n//         \"I have a question that have to investigate\",         \n//         \"We should investigate\"                               \n//       ],                                                      \n//       \"tests\": [                                              \n//         \"Investigate this\"                                    \n//       ],                                                      \n//       \"answers\": []                                           \n//     }                                                         \n//   ]                                                           \n// }                                                             \n```","readmeFilename":"README.md"}