{"id":20759841,"url":"https://github.com/owsas/open-categories","last_synced_at":"2025-04-30T05:21:55.616Z","repository":{"id":27699117,"uuid":"114931940","full_name":"owsas/open-categories","owner":"owsas","description":"Open Categorization system, available as a node module","archived":false,"fork":false,"pushed_at":"2025-04-13T10:30:24.000Z","size":435,"stargazers_count":3,"open_issues_count":12,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T11:33:22.779Z","etag":null,"topics":["categories","categorization","categorize","data","data-structures","node","open-source","typescript","yaml"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/owsas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-20T21:17:26.000Z","updated_at":"2023-09-08T17:34:11.000Z","dependencies_parsed_at":"2024-02-02T18:44:24.593Z","dependency_job_id":"eca31c73-fa03-42c1-856b-6f37097582ef","html_url":"https://github.com/owsas/open-categories","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fopen-categories","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fopen-categories/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fopen-categories/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fopen-categories/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owsas","download_url":"https://codeload.github.com/owsas/open-categories/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645983,"owners_count":21620846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["categories","categorization","categorize","data","data-structures","node","open-source","typescript","yaml"],"created_at":"2024-11-17T10:08:29.981Z","updated_at":"2025-04-30T05:21:55.577Z","avatar_url":"https://github.com/owsas.png","language":"TypeScript","readme":"# Open Categories\n\nAn open categorization system for platforms that handle information about food, fashion, technology and others\n\nSee ALL the categories in [CATEGORIES.md](./CATEGORIES.md)\n\n\u003c!-- TOC --\u003e\n\n- [Open Categories](#open-categories)\n  - [Why Open Categories?](#why-open-categories)\n  - [Principles](#principles)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Importing the class](#importing-the-class)\n    - [Getting a specific category](#getting-a-specific-category)\n    - [Searching](#searching)\n    - [Getting the topmost category for any subcategory](#getting-the-topmost-category-for-any-subcategory)\n    - [Getting the parent category](#getting-the-parent-category)\n    - [Getting all the slugs for one or several given categories](#getting-all-the-slugs-for-one-or-several-given-categories)\n  - [Files](#files)\n  - [Collaboration](#collaboration)\n  - [Dev Features](#dev-features)\n  - [Credits](#credits)\n  - [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n## Why Open Categories?\n\nOpen Categories aim to be an aid for the developers and the companies that need to categorize information.\n\nThese are some of the products that may use Open Categories. For example:\n  - AI Applications\n    - Image recognition\n    - Chatbots\n  - Online stores\n  - Search engines\n  - Games (For categorizing in-game items)\n\nWe want to build a categorization system that is both semantic, fast and useful for everybody to use, and not to reinvent the wheel on each new application.\n\nAt the end, having a common categorization system makes it easier to communicate between different apps and platforms.\n\n## Principles\n\nIn Open Categories, whatever can be categorized with a simple slug. A slug is a piece of texts that contains very useful information.\n\nFor example, if we had the string `food_fast_pizza`, we could split it in the following way:\n- `food_fast_pizza`: The sub sub category (Pizza)\n- `food_fast`: The sub category (Fast Food)\n- `food`: The topmost category (Food in general)\n\nSo, with one simple string we can classify whatever.\n\nLet's take a look at other example: \n- `food_drinks_liquor_tequila`: The sub sub sub category (Tequila)\n- `food_drinks_liquor`: The sub sub category (Liquor)\n- `food_drinks`: The sub category (Drinks)\n- `food`: The topmost category (Food in general)\n\nThis categorization is available as a node module, but we provide JSON and YAML files for you to copy and use with other languages :)\n\nThis module will help you parse and understand more about the categories, and also perform fuzzy searches\n\nWe are also commited to `semver`, so our versions and releases will be semantic \n\n## Installation\nWith npm: \n`npm install --save open-categories`\n\nWith yarn:\n`yarn add open-categories`\n\n## Usage\n\n### Importing the class\n```js\nimport { OpenCategories } from 'open-categories';\n\n// or, with require:\nconst { OpenCategories } = require('open-categories');\n```\n\n### Getting a specific category\n\n```js\nconst category = OpenCategories.getCategory('fashion_shoes_sport');\nconsole.log(category); \n/*\n{\n  \"name\":\"sport shoes\",\n  \"translationsArray\":[\n    {\"lang\":\"es\",\"text\":\"zapatos deportivos\"},\n    {\"lang\":\"en\",\"text\":\"sport shoes\"}\n  ],\n  \"translations\": {\"es\":\"zapatos deportivos\",\"en\":\"sport shoes\"},\n  \"path\":\"fashion_shoes_sport\"\n}\n*/\n```\n\n### Searching\n\nThis library also comes with fuzzy search, backed up by `fuse.js`, so you can easily run:\n\n```js\nconst results = OpenCategories.search('sport sho');\nconsole.log(results); \n/*\n[{\n  \"name\":\"sport shoes\",\n  \"translationsArray\":[\n    {\"lang\":\"es\",\"text\":\"zapatos deportivos\"},\n    {\"lang\":\"en\",\"text\":\"sport shoes\"}\n  ],\n  \"translations\": {\"es\":\"zapatos deportivos\",\"en\":\"sport shoes\"},\n  \"path\":\"fashion_shoes_sport\"\n}, {...}, {...}]\n*/\n```\n\n### Getting the topmost category for any subcategory \n\nAt some point you would like to get information about the topmost category for any given subcategory\n\nFor example: `food_mexican` -\u003e `food`\n\nYou could do this with `getTopMostCategory`\n\n```js\nconst topMost = OpenCategories.getTopMostCategory('food_mexican');\nconsole.log(topMost);\n/*\n{\n  \"name\":\"food\",\n  \"translationsArray\":[{\"lang\":\"es\",\"text\":\"comida\"}],\n  \"translations\":{\"es\":\"comida\"},\n  \"path\":\"food\",\n  \"topmost\":true\n}\n*/\n```\n\n### Getting the parent category\n\nFor example: `food_drinks_liquor` -\u003e `food_drinks`\n\nYou could do this with `getParentCategory`\n\n```js\nconst topMost = OpenCategories.getTopMostCategory('food_drinks_liquor');\nconsole.log(topMost);\n/*\n{\n  \"path\":\"food_drinks\",\n  ...\n}\n*/\n```\n\n### Getting all the slugs for one or several given categories\n\nThis is useful for understanding all the posible categories and subcategories that are present in any given array of slugs\n\nFor example: `['food_drinks_liquor']` =\u003e `['food','food_drinks','food_drinks_liquor']` \n\n```js\nconst slugs = OpenCategories.getAllSlugsForCategories(['food_drinks_liquor', 'fashion_jewelry']);\nconsole.log(slugs);\n/*\nfood\nfood_drinks\nfood_drinks_liquor\nfashion\nfashion_jewelry\n*/\n```\n\n## Files\n- `categories.yaml`: Main file for the categories\n- `src/_postBuild.ts`: Generates the `categories-array` and `categories-tree` JSON files out of `categories.yaml`\n- `src/index.ts`: Exposes the Typescript API later compiled to `out/index.js` (main package file)\n- `src/Converter.ts`: Handles the conversion from YAML to JSON\n\n## Collaboration\n\n- Clone this repo, and start adding your code in the `index.ts` file, or adding categories / translations in `categories.yaml`\n- When you are done, write the tests in the `index.test.ts` file. For testing, this repo works with [Jest](https://facebook.github.io/jest/).\n\n**Thank you for helping us build a better categorization for the world :)**\n\n## Dev Features\n* Testing with Jest\n* Linting out of the box (checks the style of your code), with TSLint\n* Build, prepublish and other scripts to help you to develop\n* Works with Typescript: Static typing for your JS Applications, reducing amount of runtime errors\n* Coverage out of the box, thanks to Jest\n* Uses deterministic module resolving, with Yarn\n\n## Credits\n\nDeveloped by Juan Camilo Guarín Peñaranda,  \nOtherwise SAS, Colombia  \n2017\n\n## License \n\nMIT.\n\n## Support us on Patreon \n[![patreon](./repo/patreon.png)](https://patreon.com/owsas)","funding_links":["https://patreon.com/owsas"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowsas%2Fopen-categories","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowsas%2Fopen-categories","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowsas%2Fopen-categories/lists"}