Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Safe Rust bindings for mecab a part-of-speech and morphological analyzer library

License

NotificationsYou must be signed in to change notification settings

tsurai/mecab-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Safe Rust wrapper formecab a japanese language part-of-speech and morphological analyzer library.

Usage

The wrapper is almost identical to the C++ interface of mecab with the addition of various iterator for comfortable data access. It is build with the latest version of mecab v0.996.

Windows

Both Windows Rust versions (MSVC ABI and gcc toolchain) can just use theprebuilt 32bit library.Using mecab-rs with the Windows commandline is not recommended and can causeundefined behavior if you are not using the correct codepage and a font that supports japanese character.

CMake & 64bit library:

Thanks to@DoumanAsh for providing these files

Examples

Include this in your Cargo.toml to add mecab to your project:

[dependencies]mecab ="*"

Single-threaded environment

externcrate mecab;use mecab::Tagger;fnmain(){let input ="太郎は次郎が持っている本を花子に渡した。";println!("INPUT: {}", input);letmut tagger =Tagger::new("");// gets tagged result as Stringletmut result = tagger.parse_str(input);println!("RESULT: {}", result);// gets N best results as String  result = tagger.parse_nbest(3, input);println!("NBEST:\n{}", result);// gets N best in sequence  tagger.parse_nbest_init(input);for iin0..3{ifletSome(res) = tagger.next(){println!("{}:\n{}", i, res);}}// gets Node objectfor nodein tagger.parse_to_node(input).iter_next(){match node.statasi32{      mecab::MECAB_BOS_NODE =>{print!("{} BOS ", node.id);},      mecab::MECAB_EOS_NODE =>{print!("{} EOS ", node.id);},      _ =>{print!("{} {} ", node.id,&(node.surface)[..(node.lengthasusize)]);}}println!("{} {} {} {} {} {} {} {} {} {} {} {} {}",      node.feature,      input.len()asisize - node.surface.len()asisize,      input.len()asisize - node.surface.len()asisize  + node.lengthasisize,      node.rcattr,      node.lcattr,      node.posid,      node.char_type,      node.stat,      node.isbest,      node.alpha,      node.beta,      node.prob,      node.cost);}// dictionary infofor dictin tagger.dictionary_info().iter(){println!("\nfilename: {}", dict.filename);println!("charset: {}", dict.charset);println!("size: {}", dict.size);println!("type: {}", dict.dict_type);println!("lsize: {}", dict.lsize);println!("rsize: {}", dict.rsize);println!("version: {}", dict.version);}}

Multithreaded environment

See themultithreaded example

License

The MIT License (MIT)

Copyright (c) 2015-2016 Cristian Kubis

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

About

Safe Rust bindings for mecab a part-of-speech and morphological analyzer library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp