{"id":39081696,"url":"https://github.com/lovit/levenshtein_finder","last_synced_at":"2026-01-17T18:30:48.826Z","repository":{"id":49302522,"uuid":"104165432","full_name":"lovit/levenshtein_finder","owner":"lovit","description":"Similar string search in Levenshtein distance","archived":false,"fork":false,"pushed_at":"2021-06-19T02:30:44.000Z","size":3162,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-04T00:33:33.531Z","etag":null,"topics":["levenshtein","string-distance"],"latest_commit_sha":null,"homepage":"","language":"Python","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/lovit.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}},"created_at":"2017-09-20T04:26:27.000Z","updated_at":"2025-02-24T17:05:18.000Z","dependencies_parsed_at":"2022-08-29T20:01:19.874Z","dependency_job_id":null,"html_url":"https://github.com/lovit/levenshtein_finder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lovit/levenshtein_finder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovit%2Flevenshtein_finder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovit%2Flevenshtein_finder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovit%2Flevenshtein_finder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovit%2Flevenshtein_finder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovit","download_url":"https://codeload.github.com/lovit/levenshtein_finder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovit%2Flevenshtein_finder/sbom","scorecard":{"id":600230,"data":{"date":"2025-08-11","repo":{"name":"github.com/lovit/levenshtein_finder","commit":"33e0e958812f9eb0a8745e2a80ab5727a0de5455"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/10 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T00:13:27.930Z","repository_id":49302522,"created_at":"2025-08-21T00:13:27.930Z","updated_at":"2025-08-21T00:13:27.930Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28515730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:28:00.501Z","status":"ssl_error","status_checked_at":"2026-01-17T18:28:00.150Z","response_time":85,"last_error":"SSL_read: 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":["levenshtein","string-distance"],"created_at":"2026-01-17T18:30:48.086Z","updated_at":"2026-01-17T18:30:48.818Z","avatar_url":"https://github.com/lovit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Similar string search in Levenshtein-distance\n\n## Install\n\nfrom source\n```\ngit clone https://github.com/lovit/levenshtein_finder\ncd levenshtein_finder\npython setup.py install\n```\n\nfrom PyPI\n```\npip install levenshtein_finder\n```\n\n## Usage\n\n### Define Tokenizer\n\n`levenshtein_finder` provides two basic tokenizers.\n\nIn [1]\n```python\nfrom levenshtein_finder import CharacterTokenizer, BigramTokenizer\n\nchar_tokenizer = CharacterTokenizer()\nbigram_tokenizer = BigramTokenizer()\n\nchar_tokenizer.tokenize(\"abc de\")  # ['a', 'b', 'c', ' ', 'd', 'e']\nbigram_tokenizer.tokenize(\"abc de\")  # ['ab', 'bc', 'c ', ' d', 'de']\n\nchar_tokenizer.train(\"path/to/text\")  # or\nchar_tokenizer.train([\"list\", \"of\", \"words\"])\n```\n\nWhen you use word piece tokenizer in Huggingface's [`tokenizers`](https://github.com/huggingface/tokenizers), wrap the class instance with `WordpieceTokenizersWrapper`\n\nIn [2]\n```python\nfrom tokenizers import BertWordPieceTokenizer\nfrom levenshtein_finder import WordpieceTokenizersWrapper\n\ntokenizer = WordpieceTokenizersWrapper(BertWordPieceTokenizer())\ntokenizer.train(\"path/to/text\")\ntokenizer.tokenize(\"abc\")  # [\"ab\", \"#c\"]\ntokenizer.encode(\"abc\"  # [53, 2]\ntokenizer.decode(tokenizer.tokenize(\"abc\"))  # \"abc\"\n```\n\nSet tokenizer which Levenshtein Finder uses. Default is `CharacterTokenizer`\n\nIn [3]\n```python\nfrom levenshtein_finder import LevenshteinFinder()\n\nfinder = LevenshteinFinder()\nfinder = LevenshteinFinder(BigramTokenizer())\nfinder = LevenshteinFinder(WordpieceTokenizersWrapper(BertWordPieceTokenizer()))\n```\n\n### Indexing\n\nIn [4]\n```python\nfinder = LevenshteinFinder()\nfinder.indexing(\"path/to/text\")\n\n# when you use CharacterTokenizer or BigramTokenizer, you can index with list of words\nfinder.indexing([\"list\", \"of\", \"words\"])\n```\n\n### Searching\n\nBasic search. The form of `similars` is `dict{term: distance}`.\n\nIn [5]\n```python\nfinder.search(\"query\")\n```\n\nIf you want to check details in searching, set `verbose=True`\n\nIn [6]\n```python\nfinder.search(\"분식회계\", verbose=True)\n```\n\nOut [6]\n```\nquery               : 분식회계\ntokens              : ['분', '식', '회', '계']\nnum data            : 132864\nnum 1st candidates  : 10137\nnum final candidates: 7\nnum similars        : 4\nelapsed time        : 0.00542903 sec\n[{'idx': 84243, 'data': '분식회계', 'distance': 0},\n {'idx': 36211, 'data': '분식회', 'distance': 1},\n {'idx': 113942, 'data': '분식회계설', 'distance': 1},\n {'idx': 114122, 'data': '분석회계', 'distance': 1}]\n```\n\n### For decomposing Korean to Jamo (NFKD)\n\nTo decompose Korean character to jamo components (`감` -\u003e [`ㄱ`, `ㅏ`, `ㅁ`]), use `Normalizers`.\n\nIn [7]\n```python\nnormalizer = Normalizers.create_normalizer(unicodedata=True)\ntokenizer = CharacterTokenizer(normalizer=normalizer)\nfinder = LevenshteinFinder(tokenizer=tokenizer)\nfinder.indexing(\"text.txt\")\nfinder.search(\"분식회계\", verbose=True)\n```\n\nOut [7]\n```\nquery               : 분식회계\ntokens              : ['ᄇ', 'ᅮ', 'ᆫ', 'ᄉ', 'ᅵ', 'ᆨ', 'ᄒ', 'ᅬ', 'ᄀ', 'ᅨ']\nnum data            : 132864\nnum 1st candidates  : 125925\nnum final candidates: 4\nnum similars        : 2\nelapsed time        : 0.0863643 sec\n[{'idx': 84243, 'data': '분식회계', 'distance': 0},\n {'idx': 114122, 'data': '분석회계', 'distance': 1}]\n```\n\n## Demo\n\n### Searching similar words\n\n`LevenshteinFinder` needs ` seconds`.\n\nIn [8]\n```python\nimport json\nwith open(\"data/nouns_from_financial_news.json\") as f:\n    words = list(json.load(f).keys())\n\nfinder = LevenshteinFinder()\nfinder.indexing(words)\nfinder.search(\"분식회계\", verbose=True)\n```\n\nOut [8]\n```\nelapsed time        : 0.00542903 sec\n```\n\nBrute-force distance computation needs `1.495 seconds`\n\nIn [9]\n```python\nimport time\nfrom levenshtein_finder import levenshtein\n\nquery = '분식회계'\n\nbegin_time = time.time()\ndistance = {word:levenshtein(word, query) for word in words}\nsearch_time = time.time() - begin_time\nprint('search time = {} sec'.format('%.3f'%search_time))\n\nsimilars = sorted(filter(lambda x:x[1] \u003c= 1, distance.items()), key=lambda x:x[1])\nelapsed_time = time.time() - begin_time\nprint('total elapsed time = {} sec'.format('%.3f'%elapsed_time))\nprint(similars)\n```\n\nOut [9]\n```\nsearch time = 1.480 sec\ntotal elapsed time = 1.495 sec\n[('분식회계', 0), ('분식회', 1), ('분식회계설', 1), ('분석회계', 1)]\n```\n\n### Searching similar strings\n\nFind similar sentence from NSMC corpus (20M).\n\nIn [10]\n```python\nfinder = LevenshteinFinder()\nfinder.indexing(\"~/Korpora/nsmc/corpus.txt\")\nfinder.search(\"음악이 주가 된 최고의 음악영화\", max_distance=1, verbose=True)\n```\n\nOut [10]\n```\nquery               : 음악이 주가 된 최고의 음악영화\ntokens              : ['음', '악', '이', ' ', '주', '가', ' ', '된', ' ', '최', '고', '의', ' ', '음', '악', '영', '화']\nnum data            : 200002\nnum 1st candidates  : 189663\nnum final candidates: 1\nnum similars        : 1\nelapsed time        : 0.123322 sec\n[{'idx': 6, 'data': '음악이 주가 된, 최고의 음악영화', 'distance': 1}]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovit%2Flevenshtein_finder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovit%2Flevenshtein_finder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovit%2Flevenshtein_finder/lists"}