{"analyzedAt":"2022-07-07T21:54:55.357Z","collected":{"metadata":{"name":"neural-phrasex","scope":"unscoped","version":"1.0.18","description":"Matches a given phrase to the best match in a database and determines the wildcards using a slot filler.  This is like a regex, but much more flexible for phrase matching and alignment.","keywords":["regex","misspellings","slot filling","chatbot","tensorflow","phrase","matching","embeddings","knn","language model","one shot learning","intent","ai","machine learning","semantic","sentence embeddings","search","information extraction"],"date":"2019-12-24T18:57:21.563Z","author":{"name":"John Loverich"},"publisher":{"username":"jloveric","email":"john.loverich@gmail.com"},"maintainers":[{"username":"jloveric","email":"john.loverich@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/jloveric/NeuralPhraseX.git"},"links":{"npm":"https://www.npmjs.com/package/neural-phrasex","homepage":"https://github.com/jloveric/NeuralPhraseX#readme","repository":"https://github.com/jloveric/NeuralPhraseX","bugs":"https://github.com/jloveric/NeuralPhraseX/issues"},"license":"MIT","dependencies":{"clone":"^2.1.2","collections":"^5.1.9","debug":"^4.1.1","deepmerge":"^4.2.2","helper-clockmaker":"^1.0.11","neural-sentence-search":"^1.1.0","pos":"^0.4.2","sentence-similarity":"^3.0.0","similarity-score":"^1.0.0","slot-filler":"^1.0.6"},"devDependencies":{"@tensorflow/tfjs":"^1.5.1","husky":"^3.0.9","jest":"^24.9.0","lint-staged":"^9.4.2","prettier":"^1.18.2"},"releases":[{"from":"2022-06-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-04-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1},{"from":"2022-01-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1},{"from":"2021-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1},{"from":"2020-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1}],"hasTestScript":true,"readme":"[![Build Status](https://travis-ci.org/jloveric/NeuralPhraseX.svg?branch=master)](https://travis-ci.org/jloveric/NeuralPhraseX)\n\n# NeuralPhraseX\n\nTakes a javascript object that contains a set of possible pattern matches, phrases and wildcards.  These phrases are converted to sentence embeddings in tensorflow.  A search phrase is passed to Phrasex and an object is returned containing a list of close phrases as well is the slots that are filled in.  The algorithm relies on npm modules, neural-sentence-search, slot-filler and sentence-similarity.  Each \"match\" is scored based on how well it matched.  This can be used directly in processing text in a chatbot or a one shot information extraction pipeline.\n\n## Install\n\n```bash\nnpm install neural-phrasex\n```\n\n## How to use\n\n```javascript\nlet {Phrasex, UserData, BasicPhrasexDatabase} = require(\"neural-phrasex\");\n\nlet simpleDatabase = {\n  data: [\n    {\n      //The simplest entry has just a phrase and a class name - phraseType\n      phrase: [\"It is what it is.\"],\n      phraseType: \"isWhatIs\"\n    },\n    {\n      //A phrase and a response to a phrase can be included.\n      phrase: [\"what is your name?\"],\n      response: [\"My name is Bot\"],\n      phraseType: \"whatIsName\",\n      implies: [\"whatIsName\"]\n    }, {\n      //You can include just simple phrases with no wildcards\n      exampleWildcards: { value: [\"pig\"], ans: [\"animal\"] },\n      phrase: [\"What is a (value)?\"],\n      response: [\"A (value) is an (ans)\"],\n      phraseType: \"whatIsThing\",\n    }, {\n      //The wildcards are just examples of what could be put in the slots\n      //These are necessary so that they can be passed to the neural network\n      //to construct a sentence vector.\n      exampleWildcards: { value: [\"Seattle\"], ans: [\"Washington\"] },\n      phrase: [\"where is (value)\"],\n      response: [\"(value) is in (ans)\"],\n      phraseType: \"whereIsThing\"\n    }\n  ]\n}\n\nlet compute = async () => {\n  let ans = BasicPhrasexDatabase.generatePhraseDatabase(simpleDatabase)\n  let phrasex = new Phrasex(ans)\n  let res = await phrasex.initialize()\n  \n  let userData = new UserData();\n  userData.initialize();\n\n  let res1 = await phrasex.getWildcardsAndMatch(\"Where is Boston\", \"\", userData)\n  console.log(res1[0])\n\n  let res2 = await phrasex.getWildcardsAndMatch(\"What is a coconut\", \"\", userData)\n  console.log(res2[0])\n})\n\ncompute()\n\n```\nwith result\n```javascript\n\n    {\n      source: {\n        exampleWildcards: { value: [Array], ans: [Array] },\n        phrase: 'where is (value)',\n        response: [ '(value) is in (ans)' ],\n        phraseType: 'whereIsThing',\n        implies: [ 'whereIsThing', 'whereIsThing' ],\n        meta: { groupInex: 6 },\n        example: 'where is Seattle',\n        storage: null,\n        words: 'where is'\n      },\n      wildcards: { matched: true, value: 'Boston' },\n      confidence: 1,\n      wcScore: { score: 1, count: 1 },\n      score: {\n        queryIndex: [ [Object], [Object], [Object] ],\n        score: 2,\n        order: 1,\n        size: 0.5,\n        semantic: 0.580953918415687\n      }\n    }\n\n  \n    {\n      source: {\n        exampleWildcards: { value: [Array], ans: [Array] },\n        phrase: 'What is a (value)?',\n        response: [ 'A (value) is an (ans).' ],\n        phraseType: 'whatIsThing',\n        implies: [ 'whatIsThing', 'whatIsThing' ],\n        meta: { groupInex: 4 },\n        example: 'What is a pig',\n        storage: null,\n        words: 'What is a ?'\n      },\n      wildcards: { matched: true, value: 'coconut' },\n      confidence: 1,\n      wcScore: { score: 1, count: 1 },\n      score: {\n        queryIndex: [ [Object], [Object], [Object], [Object] ],\n        score: 3,\n        order: 1,\n        size: 0.3333333333333333,\n        semantic: 0.5399621217119523\n      }\n    }\n```\nThe result is a variation of the original database source plus the wildcards for filling\nin the data."},"npm":{"downloads":[{"from":"2022-07-06T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":3},{"from":"2022-06-30T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":3},{"from":"2022-06-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":40},{"from":"2022-04-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":212},{"from":"2022-01-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":568},{"from":"2021-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1032}],"starsCount":0},"github":{"starsCount":6,"forksCount":2,"subscribersCount":2,"issues":{"count":12,"openCount":4,"distribution":{"3600":0,"10800":0,"32400":0,"97200":0,"291600":0,"874800":4,"2624400":0,"7873200":1,"23619600":2,"70858800":5,"212576400":0},"isDisabled":false},"contributors":[{"username":"jloveric","commitsCount":49},{"username":"dependabot[bot]","commitsCount":7}],"commits":[{"from":"2022-06-30T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-06-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-04-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-01-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2021-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0}],"statuses":[{"context":"continuous-integration/travis-ci/push","state":"success"}]},"source":{"files":{"readmeSize":3857,"testsSize":44540},"badges":[{"urls":{"original":"https://travis-ci.org/jloveric/NeuralPhraseX.svg?branch=master","service":"https://api.travis-ci.org/jloveric/NeuralPhraseX.svg?branch=master","shields":"https://img.shields.io/travis/jloveric/NeuralPhraseX/master.svg","content":"https://img.shields.io/travis/jloveric/NeuralPhraseX/master.json"},"info":{"service":"travis","type":"build","modifiers":{"branch":"master"}}}],"linters":["prettier"]}},"evaluation":{"quality":{"carefulness":0.84,"tests":0.85,"health":1,"branding":0.15},"popularity":{"communityInterest":12,"downloadsCount":70.66666666666667,"downloadsAcceleration":-0.2914764079147641,"dependentsCount":0},"maintenance":{"releasesFrequency":0.9,"commitsFrequency":0.9,"openIssues":0.9,"issuesDistribution":0.9}},"score":{"final":0.6506784435294788,"detail":{"quality":0.9463761128642766,"popularity":0.04802090795717689,"maintenance":0.9998808339576686}}}