{"id":22473534,"url":"https://github.com/chiragjn/flashtext-kt","last_synced_at":"2025-07-02T12:32:42.667Z","repository":{"id":97246141,"uuid":"196849072","full_name":"chiragjn/flashtext-kt","owner":"chiragjn","description":"A Kotlin port of https://github.com/vi3k6i5/flashtext","archived":false,"fork":false,"pushed_at":"2019-07-14T15:24:21.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T02:35:23.317Z","etag":null,"topics":["flashtext"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/chiragjn.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2019-07-14T14:53:29.000Z","updated_at":"2024-04-02T05:57:05.000Z","dependencies_parsed_at":"2024-02-23T02:30:57.855Z","dependency_job_id":null,"html_url":"https://github.com/chiragjn/flashtext-kt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chiragjn/flashtext-kt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragjn%2Fflashtext-kt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragjn%2Fflashtext-kt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragjn%2Fflashtext-kt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragjn%2Fflashtext-kt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chiragjn","download_url":"https://codeload.github.com/chiragjn/flashtext-kt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chiragjn%2Fflashtext-kt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263140352,"owners_count":23419862,"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":["flashtext"],"created_at":"2024-12-06T12:29:20.087Z","updated_at":"2025-07-02T12:32:42.626Z","avatar_url":"https://github.com/chiragjn.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kotlin port of [flashtext](https://github.com/vi3k6i5/flashtext/)\n---\n\nA modified version of Aho Corasick algorithm that only matches whole words instead of arbitrary substrings [1]\n\n[1] [https://arxiv.org/abs/1711.00046](https://arxiv.org/abs/1711.00046)\n\n---\n\nSee example.kt for usage till more documentation is added\n\n**Example Usage:**\n\n```kotlin\nimport flashtext.KeywordProcessor as KeywordProcessor\n\nfun main(args: Array\u003cString\u003e) {\n    val keywordProcessor = KeywordProcessor(caseSensitive=true)\n    keywordProcessor.addKeyword(\"NYC\", \"New York\")\n    keywordProcessor.addKeyword(\"APPL\", \"Apple\")\n    keywordProcessor.addKeywordsFromMap(\n        hashMapOf(\n            (\"java\" to arrayListOf(\"java_2e\", \"java programing\")),\n            (\"product manager\" to arrayListOf(\"PM\", \"product manager\"))\n        )\n    )\n    println(\"Terms in Trie: ${keywordProcessor.size()}\")\n    println(\"Data: ${keywordProcessor.getAllKeywords().toString()}\")\n\n    val text: String = \"I am a PM for a java_2e platform working from APPL, NYC\"\n    println(\"Text: ${text}\")\n    println(\"Extract: ${keywordProcessor.extractKeywords(text)}\")\n    println(\"Replace: ${keywordProcessor.replaceKeywords(text)}\")\n}\n```\n\n**Compile:**\n\n```\nkotlinc flashtext/TrieNode.kt flashtext/KeywordProcessor.kt example.kt -d flashtext.jar\n```\n\n**Run the example:**\n\n```\nkotlin -classpath flashtext.jar ExampleKt\n```\n\n**Output**\n\n```\nTerms in Trie: 6\nData: {APPL=Apple, java_2e=java, product manager=product manager, NYC=New York, java programing=java, PM=product manager}\nText: I am a PM for a java_2e platform working from APPL, NYC\nExtract: [(value=product manager, offset=7, length=2), (value=java, offset=16, length=7), (value=Apple, offset=46, length=4), (value=New York, offset=52, length=3)]\nReplace: I am a product manager for a java platform working from Apple, New York\n```\n---\n\n**Todo:**\n\n- [ ] Make it into a proper package, probably usable via gradle. Get help for this\n- [ ] Write tests\n- [ ] Compute benchmarks for Kotlin Regex vs this module\n- [ ] Profile memory for a bunch of dictionaries\n\n----\n\n**Disclaimer:** I am a Kotlin newbie, so any idiomatic Kotlin changes are welcome.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchiragjn%2Fflashtext-kt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchiragjn%2Fflashtext-kt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchiragjn%2Fflashtext-kt/lists"}