{"id":36569673,"url":"https://github.com/shdev/phpflashtext","last_synced_at":"2026-01-12T07:13:49.384Z","repository":{"id":57049105,"uuid":"115342642","full_name":"shdev/phpflashtext","owner":"shdev","description":"Extract Keywords from sentence or Replace keywords in sentences.  @ https://github.com/vi3k6i5/flashtext","archived":false,"fork":false,"pushed_at":"2019-07-22T08:56:18.000Z","size":1265,"stargazers_count":20,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T13:59:02.666Z","etag":null,"topics":["data-analysis","data-extraction","flashtext","keyword-extraction","nlp","php","search-in-text","string-manipulation","string-matching","word2vec"],"latest_commit_sha":null,"homepage":"","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/shdev.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":"2017-12-25T14:11:58.000Z","updated_at":"2025-01-03T02:08:31.000Z","dependencies_parsed_at":"2022-08-23T19:10:19.605Z","dependency_job_id":null,"html_url":"https://github.com/shdev/phpflashtext","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/shdev/phpflashtext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shdev%2Fphpflashtext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shdev%2Fphpflashtext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shdev%2Fphpflashtext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shdev%2Fphpflashtext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shdev","download_url":"https://codeload.github.com/shdev/phpflashtext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shdev%2Fphpflashtext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data-analysis","data-extraction","flashtext","keyword-extraction","nlp","php","search-in-text","string-manipulation","string-matching","word2vec"],"created_at":"2026-01-12T07:13:47.337Z","updated_at":"2026-01-12T07:13:49.375Z","avatar_url":"https://github.com/shdev.png","language":"PHP","readme":"\n# Flashtext for PHP\n\n\n[![Build Status](https://travis-ci.org/shdev/phpflashtext.svg?branch=master)](https://travis-ci.org/shdev/phpflashtext) [![Coverage Status](https://coveralls.io/repos/github/shdev/phpflashtext/badge.svg?branch=master)](https://coveralls.io/github/shdev/phpflashtext?branch=master)\n\nIt's a port from the wonderful python project https://github.com/vi3k6i5/flashtext,\nfor internals of the algorithm look there. \n\nThis algorithm allows you to extract or replace several keywords at ones.\nIf you deal with 300 keywords, which have 5 variants each a regex approach is slower than the flashtext approach.\nFor 1000 keyword with 5 variants each the regex can't be build.\n\nIn PHP 5.6 using regex is really slow. In newer verions it performs better. \n\n## Install\n\n```bash\ncomposer require shdev/phpflashtext\n```\n\n## Usage\n\n```php\n\u003c?php\n\nuse Shdev\\FlashText\\KeywordProcessor;\n\n$keywordProcessor= new KeywordProcessor();\n\n$keywords = [\n\t'java'               =\u003e ['java_2e', 'java programing'],\n\t'product management' =\u003e ['product management techniques', 'product management'],\n];\n\n$keywordProcessor-\u003eaddKeywordsFromAssocArray($keywords);\n\n$sentence = 'I know java_2e and product management techniques';\n\n$keywordsExtracted = $keywordProcessor-\u003eextractKeywords($sentence);\n// $keywordsExtracted = ['java', 'product management']\n\n$keywordsExtractedWithSpanInfo = $keywordProcessor-\u003eextractKeywords($sentence, true);\n// $keywordsExtractedWithSpanInfo = [\n//\t['java', 7, 14],\n// \t['product management', 19, 48],\n//]\n\n\n$sentenceNew = $keywordProcessor-\u003ereplaceKeywords($sentence);\n// $sentenceNew = 'I know java and product management';\n\n```\n\n## Citation\n\n\nThe original paper published on [FlashText algorithm](https://arxiv.org/abs/1711.00046).\n\n```tex\n    @ARTICLE{2017arXiv171100046S,\n       author = {{Singh}, V.},\n        title = \"{Replace or Retrieve Keywords In Documents at Scale}\",\n      journal = {ArXiv e-prints},\n    archivePrefix = \"arXiv\",\n       eprint = {1711.00046},\n     primaryClass = \"cs.DS\",\n     keywords = {Computer Science - Data Structures and Algorithms},\n         year = 2017,\n        month = oct,\n       adsurl = {http://adsabs.harvard.edu/abs/2017arXiv171100046S},\n      adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n    }\n\n```\nThe article published on [Medium freeCodeCamp](https://medium.freecodecamp.org/regex-was-taking-5-days-flashtext-does-it-in-15-minutes-55f04411025f).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshdev%2Fphpflashtext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshdev%2Fphpflashtext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshdev%2Fphpflashtext/lists"}