{"id":17922741,"url":"https://github.com/overtrue/double-array-trie","last_synced_at":"2025-03-24T02:32:47.841Z","repository":{"id":62354936,"uuid":"478480432","full_name":"overtrue/double-array-trie","owner":"overtrue","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-21T00:42:43.000Z","size":37,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T01:08:47.249Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/overtrue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["overtrue"]}},"created_at":"2022-04-06T08:58:17.000Z","updated_at":"2024-01-16T17:35:38.000Z","dependencies_parsed_at":"2022-10-31T10:30:34.684Z","dependency_job_id":null,"html_url":"https://github.com/overtrue/double-array-trie","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":"overtrue/php-package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fdouble-array-trie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fdouble-array-trie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fdouble-array-trie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fdouble-array-trie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overtrue","download_url":"https://codeload.github.com/overtrue/double-array-trie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245198773,"owners_count":20576443,"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":[],"created_at":"2024-10-28T20:40:41.245Z","updated_at":"2025-03-24T02:32:47.519Z","avatar_url":"https://github.com/overtrue.png","language":"PHP","funding_links":["https://github.com/sponsors/overtrue"],"categories":[],"sub_categories":[],"readme":"# DoubleArrayTrie\n\n[![Testing](https://github.com/overtrue/double-array-trie/actions/workflows/test.yml/badge.svg)](https://github.com/overtrue/double-array-trie/actions/workflows/test.yml)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/overtrue/laravel-socialite?style=flat-square)\n![GitHub License](https://img.shields.io/github/license/overtrue/laravel-socialite?style=flat-square)\n![Packagist Downloads](https://img.shields.io/packagist/dt/overtrue/laravel-socialite?style=flat-square)\n\n\nA PHP implementation of Double Array Trie.\n\n[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)\n\n## Installing\n\n```shell\n$ composer require overtrue/double-array-trie -vvv\n```\n\n## Usage\n\n### Build a DoubleArrayTrie\n\n#### build with a string array\n\n```php\nuse Overtrue\\DoubleArrayTrie\\Builder;\n\n$builder = new Builder();\n\n$trie = $builder-\u003ebuild(['foo', 'bar', 'baz']);\n\n$trie-\u003eexport()-\u003etoFile('trie.json');\n$trie-\u003eexport()-\u003etoFile('trie.php');\n$trie-\u003eexport()-\u003etoFile('trie.dat');\n```\n\n### build with a key-value array\n\n```php\nuse Overtrue\\DoubleArrayTrie\\Builder;\n\n$builder = new Builder();\n\n$trie = $builder-\u003ebuild([ \n            '一举' =\u003e 'yi ju',\n            '一举一动' =\u003e 'yi ju yi dong',\n        ]);\n```\n\n### Load a DoubleArrayTrie\n\n```php\nuse Overtrue\\DoubleArrayTrie\\Factory;\n\n$trie = Factory::loadFromFile('trie.json');\n$trie = Factory::loadFromFile('trie.php');\n$trie = Factory::loadFromFile('trie.dat');\n```\n\n### Matching\n\n```php\nuse Overtrue\\DoubleArrayTrie\\Matcher;\n\n$trie = Factory::loadFromFile('trie.json');\n$matcher = new Matcher($trie);\n```\n\nmatch a string no values:\n\n```php\n// ['foo', 'bar', 'baz']\n\n$matcher-\u003ematch('foo'); // true\n$matcher-\u003ematch('oo'); // false\n```\n\nmatch a string with values:\n\n```php\n// ['一举' =\u003e 'yi ju', '一举一动' =\u003e 'yi ju yi dong']\n\n$matcher-\u003ematch('一举'); // 'yi ju'\n$matcher-\u003ematch('一举一'); // false\n```\n\n### prefix matching\n\n```php\n// ['一举' =\u003e 'yi ju', '一举一动' =\u003e 'yi ju yi dong', '一举成名' =\u003e 'yi ju cheng ming',]\n$matcher-\u003eprefixMatch('一举一动都很奇怪'); \n// [\n//  '一举' =\u003e 'yi ju',\n//  '一举一动' =\u003e 'yi ju yi dong'\n//]\n```\n\n## Credits\n\n - [darts-java: Double-ARray Trie System Java implementation.](https://github.com/komiya-atsushi/darts-java)\n - [DoubleArrayTrie: A PHP implementation of Double Array Trie.](https://linux.thai.net/~thep/datrie/)\n - [双数组Trie树(DoubleArrayTrie)Java实现](https://www.hankcs.com/program/java/%E5%8F%8C%E6%95%B0%E7%BB%84trie%E6%A0%91doublearraytriejava%E5%AE%9E%E7%8E%B0.html)\n\n## :heart: Sponsor me\n\n[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue)\n\n如果你喜欢我的项目并想支持它，[点击这里 :heart:](https://github.com/sponsors/overtrue)\n\n## Project supported by JetBrains\n\nMany thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.\n\n[![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/overtrue)\n\n## Contributing\n\nYou can contribute in one of three ways:\n\n1. File bug reports using the [issue tracker](https://github.com/vendor/package/issues).\n2. Answer questions or fix bugs on the [issue tracker](https://github.com/vendor/package/issues).\n3. Contribute new features or update the wiki.\n\n_The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and\nPSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Fdouble-array-trie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovertrue%2Fdouble-array-trie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Fdouble-array-trie/lists"}