{"id":15334330,"url":"https://github.com/richardstartin/multi-matcher","last_synced_at":"2026-03-09T19:02:15.818Z","repository":{"id":57743670,"uuid":"123423284","full_name":"richardstartin/multi-matcher","owner":"richardstartin","description":"simple rules engine","archived":false,"fork":false,"pushed_at":"2020-04-16T17:52:10.000Z","size":6839,"stargazers_count":91,"open_issues_count":15,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T03:03:13.428Z","etag":null,"topics":["classification","classifier","decision-table","decision-tree"],"latest_commit_sha":null,"homepage":"https://richardstartin.github.io/posts/classifying-documents","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardstartin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-01T11:00:59.000Z","updated_at":"2024-10-29T23:48:47.000Z","dependencies_parsed_at":"2022-09-12T10:10:56.917Z","dependency_job_id":null,"html_url":"https://github.com/richardstartin/multi-matcher","commit_stats":null,"previous_names":["richardstartin/bitrules"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardstartin%2Fmulti-matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardstartin%2Fmulti-matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardstartin%2Fmulti-matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardstartin%2Fmulti-matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardstartin","download_url":"https://codeload.github.com/richardstartin/multi-matcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997084,"owners_count":21195798,"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":["classification","classifier","decision-table","decision-tree"],"created_at":"2024-10-01T10:06:48.192Z","updated_at":"2026-03-09T19:02:10.769Z","avatar_url":"https://github.com/richardstartin.png","language":"Java","readme":"# multi-matcher\n[![Build Status](https://travis-ci.org/richardstartin/multi-matcher.svg?branch=master)](https://travis-ci.org/richardstartin/multi-matcher)\n[![Coverage Status](https://coveralls.io/repos/github/richardstartin/bitrules/badge.svg?branch=master)](https://coveralls.io/github/richardstartin/multi-matcher?branch=master)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/uk.co.openkappa/bitrules/badge.svg)](https://maven-badges.herokuapp.com/maven-central/uk.co.openkappa/bitrules)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Javadoc](https://javadoc-badge.appspot.com/uk.co.openkappa/multi-matcher.svg?label=javadoc)](http://www.javadoc.io/doc/uk.co.openkappa/multi-matcher)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/richardstartin/multi-matcher.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/richardstartin/multi-matcher/alerts/)\n[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/richardstartin/multi-matcher.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/richardstartin/multi-matcher/context:java)\n\nI have often needed to implement tedious classification logic in data processing projects. The requirements are often ambiguous to the extent that it would be difficult to implement them even in SQL, with aspects such as fallback and overlap. This logic often ends up expressed as large blocks of nested if statements which are hard to read or modify and perform poorly. This small project aims to make such classification logic easier, and improve performance too. \n\n# usage\n\nBuild a generic classification engine\n```java\n    Classifier\u003cProduct, String\u003e classifier = Classifier.\u003cString, Product, String\u003ebuilder(\n                Schema.\u003cString, Product, String\u003ecreate()\n                        .withAttribute(\"productType\", Product::getProductType)\n                        .withAttribute(\"issueDate\", Product::getIssueDate, Comparator.naturalOrder().reversed())\n                        .withAttribute(\"productName\", Product::getProductName)\n                        .withAttribute(\"availability\", Product::getAvailability)\n                        .withAttribute(\"discountedPrice\", value -\u003e 0.2 * value.getPrice())\n                ).build(Arrays.asList(\n                    MatchingConstraint.\u003cString, String\u003enamed(\"rule1\") \n                            .eq(\"productType\", \"silk\")\n                            .startsWith(\"productName\", \"luxury\")\n                            .gt(\"discountedPrice\", 1000)\n                            .priority(0)\n                            .classification(\"EXPENSIVE_LUXURY_PRODUCTS\")\n                            .build(),\n                    MatchingConstraint.\u003cString, String\u003enamed(\"rule2\")\n                            .eq(\"productType\", \"caviar\")\n                            .gt(\"discountedPrice\", 100)\n                            .priority(1)\n                            .classification(\"EXPENSIVE_LUXURY_PRODUCTS\")\n                            .build(),\n                    MatchingConstraint.\u003cString, String\u003eanonymous()\n                            .eq(\"productName\", \"baked beans\")\n                            .priority(2)\n                            .classification(\"CHEAP_FOOD\")\n                            .build()\n                )\n            );\n```\n\nClassify\n\n```java\n  Product p = getProduct();\n  String classification = classifier.classification(p).orElse(\"UNCLASSIFIED\");\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardstartin%2Fmulti-matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardstartin%2Fmulti-matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardstartin%2Fmulti-matcher/lists"}