{"_id":"@ascari/reco","_rev":"3-6a52a5eaa646d51bafb072c771808023","name":"@ascari/reco","description":"Generic text classifier for Mexican electronic invoices.","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ascari/reco","version":"1.0.0","description":"Generic text classifier for Mexican electronic invoices.","main":"index.js","bin":{"reco":"bin/cli.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["sat","invoice","factura","factura electronica","recognition","text recognition"],"author":{"name":"Carlos Ascari Gutierrez Hermosillo","email":"ascari.gtz@gmail.com"},"license":"MIT","dependencies":{"async":"^2.5.0","fs-extra":"^4.0.1","knex":"^0.13.0","minimist":"^1.2.0","natural":"^0.5.4","onepath":"^1.1.2","xml2js":"^0.4.19"},"gitHead":"f8da8b201b3d8e030d8351f250db581c310caaea","_id":"@ascari/reco@1.0.0","_shasum":"d0d7cd38ccce2052fffb3ff0d107aa2b278ff74f","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"ascari","email":"ascari.gtz@gmail.com"},"dist":{"shasum":"d0d7cd38ccce2052fffb3ff0d107aa2b278ff74f","tarball":"https://registry.npmjs.org/@ascari/reco/-/reco-1.0.0.tgz","integrity":"sha512-gxoCPzawL2ItAQ7uU4aNG2J+UDuG0UlH7N9BmBu5sgs1m/IKdowFVX6Z58NqkTX9+avbKR3N97UGHsBEKjBgvw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDHSC6CTD6BYU0+dzZNVBA0keAsSSfvuu0ySPSe+JND1AiA4KNp8w9Zkxc7SAcUzHLF/V2EUaMXpMVofq5Xm5T1u6A=="}]},"maintainers":[{"name":"ascari","email":"ascari.gtz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reco-1.0.0.tgz_1505276399143_0.47770807472988963"}},"1.0.1":{"name":"@ascari/reco","version":"1.0.1","description":"Generic text classifier for Mexican electronic invoices.","main":"index.js","bin":{"reco":"bin/cli.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["sat","invoice","factura","factura electronica","recognition","text recognition"],"author":{"name":"Carlos Ascari Gutierrez Hermosillo","email":"ascari.gtz@gmail.com"},"license":"MIT","dependencies":{"async":"^2.5.0","fs-extra":"^4.0.1","knex":"^0.13.0","minimist":"^1.2.0","natural":"^0.5.4","onepath":"^1.1.2","xml2js":"^0.4.19"},"gitHead":"d2db64a72d6d44f11184233ae0083cbd672296d8","_id":"@ascari/reco@1.0.1","_shasum":"d6eb5ca5dd7750977d41f4ad82de75b667b0b8a9","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"ascari","email":"ascari.gtz@gmail.com"},"dist":{"shasum":"d6eb5ca5dd7750977d41f4ad82de75b667b0b8a9","tarball":"https://registry.npmjs.org/@ascari/reco/-/reco-1.0.1.tgz","integrity":"sha512-fHVx+7g8K6tojlEwPYPIV8LHilMNwlNCwaRXC4GOl4e+EvthFYIl8qiTsNura631SXX5jQSdZ5pHL0/1NwMF5A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDF866ravATIEAVygZ4OJ7nxRr7kK8NK5fWS09oWrekIAIgaXJHsNztklS2ekTZn05oAXRm+/19ruiVB7FWH/itd+k="}]},"maintainers":[{"name":"ascari","email":"ascari.gtz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reco-1.0.1.tgz_1505276941814_0.40482300030998886"}}},"readme":"# [reco]()\n\nA text **reco**gnition engine that classifies concept descriptions found in electronic invoices used in Mexico.\n\n## Installation\n\n### Command Line Utility\n\nYou must install reco globally to use the command line interface.\n\n```\nnpm i @ascari/reco -g\n```\n\n### Module\n\n```\nnpm i @ascari/reco --save\n```\n\n## USAGE\n\n### Command Line Utility\n\n##### Create reco.json\n\n```\nreco init\n```\n\nA `./reco.json` file will be created with default values. \nBy default it uses a sqlite3 database.\n\nYou may edit the configuration now.\n\n##### Scaffold a new project\n\nRequires a valid `./reco.json` file to be present.\n\n```\nreco create\n```\n\nA database will be scaffolded in the current directory.\n\nBy default it creates a `./database` folder where a sqlite3 database file will be stored.\n\nYou may edit the first migration: `./database/migrations/0.js` to better accomodate your database structure.\n**Keep in mind that the autogenerated tables and columns are required.**\n\n-----------\n\n> **NOTE** The following commands can only be called after creating a project.\n\n-----------\n\n##### Add a single invoice\n\nLoad xml, parse information and store unique: suppliers, clients & concepts found.\n\n```\nreco xml path/to/invoice.xml\n```\n\n**Note** Ideally, valid SAT invoices should be fed to reco, however reco does not verify its integrity, this means you can feed non-compliant xml invoices as well, as long as they follow a similar structure:\n\n```\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Comprobante fecha=\"{{INVOICE_DATE}}\" sello=\"{{SELLO_DIGITAL}}\">\n  <Emisor rfc=\"{{CLIENT_RFC}}\" name=\"{{CLIENT_NAME}}\" />\n  <Receptor rfc=\"{{SUPPLIER_RFC}}\" name=\"{{SUPPLIER_NAME}}\" />\n  <Conceptos>\n    <Concepto descripcion=\"{{CONCEPT_DESCRIPTION_A}}\" />\n    <Concepto descripcion=\"{{CONCEPT_DESCRIPTION_B}}\" />\n  </Conceptos>\n</Comprobante>\n```\n\n##### Add all invoices in a folder\n\nLoad and store all invoice files found in a folder.\n\n```\nreco xmls path/to/invoices\n```\n\n*Currenly, reco cannot read folders recursively*\n\n##### Label a concept for training\n\nWill create a label that is used to train a classifier.\n\n```\nreco label \"LABEL\" \"CONCEPT\"\n```\n\nYou may use the `--rfc` option to scope a label to a supplier.\n\n```\nreco label \"LABEL\" \"CONCEPT\" --rfc XXX0123456X7\n```\n\nScoping a label improves recognition accuracy.\nThe imporovment comes from weighting higher classifications that belong to a supplier when a recognition test is also scoped to a supplier.\nThe reasoning being that a supplier will generally have their own unique set of concepts for their products and or services, that will more likely match a label scoped to the same supplier.\n\n> In other words, a Pizza supplier will tend to better identify concepts with the word \"pizza\", since its products have the word \"pizza\" in them, when we are classifying a concept from the Pizza supplier. Otherwise, a Toy supplier with toy pizza games may rank higher.\n\n> One more time: When we know a invoice concept comes from a certain supplier, it is better to test it against a classifier that has only been trained on its own invoice concepts and labels from the same supplier.\n\n##### Add all labels found in a file\n\nAdd labels found in a list.\n\n```\nreco labels path/to/labels.lst\n```\n\nLabels are seperated by new lines, where labels and concept are seperated by a (:) colon.\n\nexample: \n\n```\napple:I WANT AN APPLE\norange:ORANGE YOU GLAD?\nlemon:EAT SOME LEMON PIE\n```\nYou may use the `-v` option to see progress.\n\nYou may use the `--rfc` option to scope labels to a supplier.\n\nYou may use the `--delim` option to specify a different delimeter.\n\nYou mau use the `--no-delim` option to specify that the list is not delimeted, that is, it does not have a label and a concept, instead the label and the concept are the same.\n\nThis is usefull for adding a supplier's catalog, when identifying their concepts.\n\n##### Train classifiers\n\nTrain classifiers. \n\n*Be patient, it may take a while.*\n\n```\nreco train\n```\n\n##### Test an arbitrary concept\n\nTest recognition by classifying a specified concept.\nWill return label with the best score.\n\n```\nreco test \"CONCEPT\"\n```\n\nYou may use the `--rfc` option to scope test to a supplier.\n\nYou may use the `-v` option to return classification information.\n10 rows are returned by default, if you specify a number: `-v 20`, you can specify how many classification rows to return, ordered from best match to least.\n\n### Module\n\n```\nconst Reco = require('reco');\n\n// Reco configuration\nconst recoConfig = { .... };\n\n// instanciate\nconst reco = new Reco(recoConfig);\n```\n\n#### API\n\nReco::**contructor**(recoConfig);\n\nWhere recoConfig can have the follwing options:\n\n**Note** the `database` property is fed to [knex](https://github.com/tgriesser/knex).\n\n```\n{\n  database: {\n    client: 'sqlite3',\n    connection: {\n      filename: './database/database.sqlite'\n    },\n    migrations: {\n      tableName: 'migrations',\n      directory: './database/migrations',\n      stub: './database/stub.migration.js'\n    },\n    seeds: {\n      directory: './database/seeds',\n    },\n    useNullAsDefault: true,\n  },\n}\n```\n\n*Promise* Reco::**addLabel**(*String* label, *String* concept, *String* [supplierRfc=null]);\n\nAdd a label.\n\n*Promise* Reco::**addXmlInvoice**(*String* xml);\n\nAdd an invoice.\n\n*Promise* Reco::**train**();\n\nTrain classifiers.\n\n*Promise* Reco::**test**(*String* input, *String* [supplierRfc=null]);\n\nTest classifiers\n\n#### License\n\nSee LICENSE in respository.","maintainers":[{"name":"ascari","email":"ascari.gtz@gmail.com"}],"time":{"modified":"2022-06-12T14:49:09.887Z","created":"2017-09-13T04:20:00.148Z","1.0.0":"2017-09-13T04:20:00.148Z","1.0.1":"2017-09-13T04:29:01.987Z"},"keywords":["sat","invoice","factura","factura electronica","recognition","text recognition"],"author":{"name":"Carlos Ascari Gutierrez Hermosillo","email":"ascari.gtz@gmail.com"},"license":"MIT","readmeFilename":"README.md"}