{"id":13573222,"url":"https://github.com/wareya/notmecab-rs","last_synced_at":"2025-04-04T12:30:24.058Z","repository":{"id":57645858,"uuid":"162726648","full_name":"wareya/notmecab-rs","owner":"wareya","description":"notmecab-rs is a very basic mecab clone, designed only to do parsing, not training.","archived":false,"fork":false,"pushed_at":"2020-07-25T05:03:14.000Z","size":186,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T09:30:31.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/wareya.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":"2018-12-21T15:00:30.000Z","updated_at":"2023-09-01T15:44:02.000Z","dependencies_parsed_at":"2022-09-08T16:41:40.004Z","dependency_job_id":null,"html_url":"https://github.com/wareya/notmecab-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wareya%2Fnotmecab-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wareya%2Fnotmecab-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wareya%2Fnotmecab-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wareya%2Fnotmecab-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wareya","download_url":"https://codeload.github.com/wareya/notmecab-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247148125,"owners_count":20891852,"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-08-01T15:00:31.992Z","updated_at":"2025-04-04T12:30:23.616Z","avatar_url":"https://github.com/wareya.png","language":"Rust","funding_links":[],"categories":["Natural Language Processing (preprocessing)"],"sub_categories":[],"readme":"notmecab-rs is a very basic mecab clone, designed only to do parsing, not training.\n\nThis is meant to be used as a library by other tools such as frequency analyzers. Not directly by people.\nIt also only works with UTF-8 dictionaries. (Stop using encodings other than UTF-8 for infrastructural software.)\n\nLicensed under the Apache License, Version 2.0.\n\n# Testing\n\nGet unidic's sys.dic, matrix.bin, unk.dic, and char.bin and put them in data/. Then invoke tests from the repository root. Unidic 2.3.0 (spoken language or written language variant, not kobun etc) is assumed, otherwise some tests will fail.\n\n# Performance\n\nnotmecab performs maginally worse than mecab, but there are many cases where mecab fails to find the lowest-cost string of tokens, so I'm pretty sure that mecab is just cutting corners somewhere performance sensitive when searching for an ideal parse.\n\nThere are a couple difficult-to-use caching features designed to improve performance. You can upload a matrix of connections between the most common connection edge types with ```prepare_fast_matrix_cache```, which is for extremely large dictionaries like modern versions of unidic, or you can load the entire matrix connection cache into memory with ```prepare_full_matrix_cache```, which is for small dictionaries like ipadic. Note that ```prepare_full_matrix_cache``` is actually slower than ```prepare_fast_matrix_cache``` for modern versions of unidic after long periods of pumping text through notmecab, though obviously ```prepare_full_matrix_cache``` is the best option for small dictionaries.\n\nThere are no stability guarantees about the presence or behavior of ```prepare_fast_matrix_cache```, because it's very hacky and if I find a better way to do what it's doing then I'm going to remove it.\n\n# Example (from tests)\n\n    // you need to acquire a mecab dictionary and place these files here manually\n    let sysdic = Blob::open(\"data/sys.dic\").unwrap();\n    let unkdic = Blob::open(\"data/unk.dic\").unwrap();\n    let matrix = Blob::open(\"data/matrix.bin\").unwrap();\n    let unkdef = Blob::open(\"data/char.bin\").unwrap();\n\n    let dict = Dict::load(sysdic, unkdic, matrix, unkdef).unwrap();\n\n    let result = parse(\u0026dict, \"これを持っていけ\").unwrap();\n    for token in \u0026result.0\n    {\n        println!(\"{}\", token.feature);\n    }\n    let split_up_string = tokenstream_to_string(\u0026result.0, \"|\");\n    println!(\"{}\", split_up_string);\n    assert_eq!(split_up_string, \"これ|を|持っ|て|いけ\"); // this test might fail if you're not testing with unidic (i.e. the correct parse might be different)\n\n## Output of example\n\n    代名詞,*,*,*,*,*,コレ,此れ,これ,コレ,これ,コレ,和,*,*,*,*,*,*,体,コレ,コレ,コレ,コレ,0,*,*,3599534815060480,13095\n    助詞,格助詞,*,*,*,*,ヲ,を,を,オ,を,オ,和,*,*,*,*,*,*,格助,ヲ,ヲ,ヲ,ヲ,*,\"動詞%F2@0,名詞%F1,形容詞%F2@-1\",*,11381878116459008,41407\n    動詞,一般,*,*,五段-タ行,連用形-促音便,モツ,持つ,持っ,モッ,持つ,モツ,和,*,*,*,*,*,*,用,モッ,モツ,モッ,モツ,1,C1,*,10391493084848772,37804\n    助詞,接続助詞,*,*,*,*,テ,て,て,テ,て,テ,和,*,*,*,*,*,*,接助,テ,テ,テ,テ,*,\"動詞%F1,形容詞%F2@-1\",*,6837321680953856,24874\n    動詞,非自立可能,*,*,五段-カ行,命令形,イク,行く,いけ,イケ,いく,イク,和,*,*,*,*,*,*,用,イケ,イク,イケ,イク,0,C2,*,470874478224161,1713\n    これ|を|持っ|て|いけ\n\nYou can also call parse_to_lexertoken, which does less string allocation, but you don't get the feature string as a string.\n\n# Notes\n\n- This software is unusably slow if optimizations are disabled.\n- Cost rewriting is not performed when user dictionaries are loaded.\n- There are some cases where multiple parses tie for the lowest cost. It's not defined which parse gets chosen in these cases.\n- There are some cases where mecab failed to find an ideal parse, but notmecab-rs does. Notmecab-rs should never produce a parse that has a higher total cost than the parse that mecab gives. If it does, it indicates some underlying bug, and should be reported, please.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwareya%2Fnotmecab-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwareya%2Fnotmecab-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwareya%2Fnotmecab-rs/lists"}