diff --git a/src-core/examples/common/mod.rs b/src-core/examples/common/mod.rs index bffcd9b..429707e 100644 --- a/src-core/examples/common/mod.rs +++ b/src-core/examples/common/mod.rs @@ -5,5 +5,5 @@ pub fn get_db_dir() -> PathBuf { } pub fn get_vibrato_dict_dir() -> PathBuf { - PathBuf::from("src-tauri/resources/ipadic-mecab/system.dic.zst") + PathBuf::from("src-tauri/resources/naist-jdic-mecab/system.dic.zst") } diff --git a/src-core/examples/ja_tokenize.rs b/src-core/examples/ja_tokenize.rs index 43f8ef8..301112f 100644 --- a/src-core/examples/ja_tokenize.rs +++ b/src-core/examples/ja_tokenize.rs @@ -1,3 +1,5 @@ +use std::env::args; + use cjdic2_core::AppService; mod common; @@ -8,11 +10,14 @@ use crate::common::get_vibrato_dict_dir; fn main() -> Result<(), anyhow::Error> { let service = AppService::new(get_db_dir(), get_vibrato_dict_dir())?; + let mut arg_it = args(); + arg_it.next(); + println!( "{:#?}", - service.ja_tokenize( - "予約キャンセル・変更は【配信日前日の19時頃】までに行ってください。".to_string() - )? + service.ja_tokenize(arg_it.next().unwrap_or( + "武器・防具≪エルガー武器商会≫の裏の鍛冶場を調べ「錆びた鍵」を入手します ".to_string() + ))? ); Ok(()) diff --git a/src-react/src/pages/SearchPage.tsx b/src-react/src/pages/SearchPage.tsx index 25a7846..dbc2413 100644 --- a/src-react/src/pages/SearchPage.tsx +++ b/src-react/src/pages/SearchPage.tsx @@ -53,7 +53,7 @@ function SearchPage() { if (!isMonitorClipboard) return; const intervalId = setInterval(async () => { - const newText = await readText(); + const newText = (await readText()).replace(/ /g, ""); set_clipboardText((clipboardText) => { if (clipboardText !== newText) { @@ -134,7 +134,7 @@ function SearchPage() { }); if (isNew) { - if (!result.length && !isFromSplit && ender === "" && q.length > 2) { + if (!result.length && !isFromSplit && /^[^ ]{3,} $/.test(q)) { const segs = await invoke<{ surface: string }[]>("tokenize", { text: q, }); diff --git a/src-tauri/gen/android/app/.gitignore b/src-tauri/gen/android/app/.gitignore index 762a56a..422acb7 100644 --- a/src-tauri/gen/android/app/.gitignore +++ b/src-tauri/gen/android/app/.gitignore @@ -6,4 +6,6 @@ /tauri.properties /src/main/assets/**/*.zip +/src/main/assets/**/*.zst +/src/main/assets/**/*.db /src/main/assets/**/manifest.json diff --git a/src-tauri/gen/android/app/src/main/assets/resources/ipadic-mecab/system.dic.zst b/src-tauri/gen/android/app/src/main/assets/resources/ipadic-mecab/system.dic.zst deleted file mode 100644 index 230307b..0000000 Binary files a/src-tauri/gen/android/app/src/main/assets/resources/ipadic-mecab/system.dic.zst and /dev/null differ diff --git a/src-tauri/resources/naist-jdic-mecab/COPYING b/src-tauri/resources/naist-jdic-mecab/COPYING new file mode 100644 index 0000000..b2e68f4 --- /dev/null +++ b/src-tauri/resources/naist-jdic-mecab/COPYING @@ -0,0 +1,32 @@ +Copyright (c) 2009, Nara Institute of Science and Technology, Japan. +Copyright 2023, LegalOn Technologies, Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +Neither the name of the Nara Institute of Science and Technology +(NAIST) nor the names of its contributors may be used to endorse or +promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + diff --git a/src-tauri/resources/naist-jdic-mecab/NOTICE b/src-tauri/resources/naist-jdic-mecab/NOTICE new file mode 100644 index 0000000..d54f261 --- /dev/null +++ b/src-tauri/resources/naist-jdic-mecab/NOTICE @@ -0,0 +1,7 @@ +This software includes a binary version of data from + + https://ja.osdn.net/projects/naist-jdic/downloads/53500/mecab-naist-jdic-0.6.3b-20111013.tar.gz + +where the connection ids are remapped using CORE data in BCCWJ (except the PN category) + + https://clrd.ninjal.ac.jp/bccwj/. diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 1d087a3..290b9e9 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -21,7 +21,7 @@ pub fn run() { let dict_path = { // Resolve the resource path (returns asset://localhost/ URI on Android) let resource_path = app.path().resolve( - "resources/ipadic-mecab/system.dic.zst", + "resources/naist-jdic-mecab/system.dic.zst", tauri::path::BaseDirectory::Resource, )?; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 195fa9e..57f5bce 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -24,7 +24,7 @@ }, "bundle": { "resources": [ - "resources/**/system.dic.zst" + "resources/naist-jdic-mecab/system.dic.zst" ], "active": true, "targets": "all",