diff --git a/crates/open_jtalk-sys/src/generated/android/aarch64/bindings.rs b/crates/open_jtalk-sys/src/generated/android/aarch64/bindings.rs index 61bc5cc..f0993c0 100644 --- a/crates/open_jtalk-sys/src/generated/android/aarch64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/android/aarch64/bindings.rs @@ -1697,6 +1697,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/android/x86_64/bindings.rs b/crates/open_jtalk-sys/src/generated/android/x86_64/bindings.rs index 61bc5cc..f0993c0 100644 --- a/crates/open_jtalk-sys/src/generated/android/x86_64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/android/x86_64/bindings.rs @@ -1697,6 +1697,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/ios/aarch64/bindings.rs b/crates/open_jtalk-sys/src/generated/ios/aarch64/bindings.rs index b937f38..3a570c4 100644 --- a/crates/open_jtalk-sys/src/generated/ios/aarch64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/ios/aarch64/bindings.rs @@ -2151,6 +2151,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/ios/x86_64/bindings.rs b/crates/open_jtalk-sys/src/generated/ios/x86_64/bindings.rs index b937f38..3a570c4 100644 --- a/crates/open_jtalk-sys/src/generated/ios/x86_64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/ios/x86_64/bindings.rs @@ -2151,6 +2151,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/linux/aarch64/bindings.rs b/crates/open_jtalk-sys/src/generated/linux/aarch64/bindings.rs index b297198..c90e99e 100644 --- a/crates/open_jtalk-sys/src/generated/linux/aarch64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/linux/aarch64/bindings.rs @@ -2249,6 +2249,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/linux/x86_64/bindings.rs b/crates/open_jtalk-sys/src/generated/linux/x86_64/bindings.rs index b297198..c90e99e 100644 --- a/crates/open_jtalk-sys/src/generated/linux/x86_64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/linux/x86_64/bindings.rs @@ -2249,6 +2249,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/macos/aarch64/bindings.rs b/crates/open_jtalk-sys/src/generated/macos/aarch64/bindings.rs index b937f38..3a570c4 100644 --- a/crates/open_jtalk-sys/src/generated/macos/aarch64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/macos/aarch64/bindings.rs @@ -2151,6 +2151,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/macos/x86_64/bindings.rs b/crates/open_jtalk-sys/src/generated/macos/x86_64/bindings.rs index b937f38..3a570c4 100644 --- a/crates/open_jtalk-sys/src/generated/macos/x86_64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/macos/x86_64/bindings.rs @@ -2151,6 +2151,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/windows/x86/bindings.rs b/crates/open_jtalk-sys/src/generated/windows/x86/bindings.rs index 478c077..fb07d2d 100644 --- a/crates/open_jtalk-sys/src/generated/windows/x86/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/windows/x86/bindings.rs @@ -1725,6 +1725,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk-sys/src/generated/windows/x86_64/bindings.rs b/crates/open_jtalk-sys/src/generated/windows/x86_64/bindings.rs index 98d0c85..eaa2c38 100644 --- a/crates/open_jtalk-sys/src/generated/windows/x86_64/bindings.rs +++ b/crates/open_jtalk-sys/src/generated/windows/x86_64/bindings.rs @@ -1725,6 +1725,13 @@ extern "C" { dicdir: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn Mecab_load_with_userdic( + m: *mut Mecab, + dicdir: *const ::std::os::raw::c_char, + userdic: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn Mecab_analysis( m: *mut Mecab, diff --git a/crates/open_jtalk/src/mecab/mod.rs b/crates/open_jtalk/src/mecab/mod.rs index 2c45830..8847d91 100644 --- a/crates/open_jtalk/src/mecab/mod.rs +++ b/crates/open_jtalk/src/mecab/mod.rs @@ -47,6 +47,27 @@ impl Mecab { )) } } + + /// # Panics + /// + /// 次の場合にパニックする。 + /// + /// - `dic_dir`または`userdic`が`\0`を含む。 + /// - `dic_dir`または`userdic`がUTF-8の文字列ではない。 + pub fn load_with_userdic(&mut self, dic_dir: &Path, userdic: Option<&Path>) -> bool { + let dic_dir = CString::new(dic_dir.to_str().unwrap()).unwrap(); + let userdic = &userdic.map(|userdic| CString::new(userdic.to_str().unwrap()).unwrap()); + unsafe { + bool_number_to_bool(open_jtalk_sys::Mecab_load_with_userdic( + self.as_raw_ptr(), + dic_dir.as_ptr(), + match userdic { + Some(userdic) => userdic.as_ptr(), + None => std::ptr::null(), + }, + )) + } + } pub fn get_feature(&self) -> Option<&MecabFeature> { unsafe { let feature = open_jtalk_sys::Mecab_get_feature(self.as_raw_ptr());