mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
word segmentation and clipboard first word detector
This commit is contained in:
1 parent
29a4d14893
commit
1614db6e99
19 files changed
+502
-13
No files matched your search
Binary file not shown.
@@ -4,3 +4,5 @@
|
||||
jmdict.db
|
||||
|
||||
manifest.json
|
||||
# vibrato dicts from https://github.com/daac-tools/vibrato/releases
|
||||
system.dic.zst
|
||||
@@ -0,0 +1,73 @@
|
||||
Copyright 2000, 2001, 2002, 2003 Nara Institute of Science
|
||||
and Technology.
|
||||
Copyright 2023, LegalOn Technologies, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
Use, reproduction, and distribution of this software is permitted.
|
||||
Any copy of this software, whether in its original form or modified,
|
||||
must include both the above copyright notice and the following
|
||||
paragraphs.
|
||||
|
||||
Nara Institute of Science and Technology (NAIST),
|
||||
the copyright holders, disclaims all warranties with regard to this
|
||||
software, including all implied warranties of merchantability and
|
||||
fitness, in no event shall NAIST be liable for
|
||||
any special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether in an
|
||||
action of contract, negligence or other tortuous action, arising out
|
||||
of or in connection with the use or performance of this software.
|
||||
|
||||
A large portion of the dictionary entries
|
||||
originate from ICOT Free Software. The following conditions for ICOT
|
||||
Free Software applies to the current dictionary as well.
|
||||
|
||||
Each User may also freely distribute the Program, whether in its
|
||||
original form or modified, to any third party or parties, PROVIDED
|
||||
that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear
|
||||
on, or be attached to, the Program, which is distributed substantially
|
||||
in the same form as set out herein and that such intended
|
||||
distribution, if actually made, will neither violate or otherwise
|
||||
contravene any of the laws and regulations of the countries having
|
||||
jurisdiction over the User or the intended distribution itself.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
The program was produced on an experimental basis in the course of the
|
||||
research and development conducted during the project and is provided
|
||||
to users as so produced on an experimental basis. Accordingly, the
|
||||
program is provided without any warranty whatsoever, whether express,
|
||||
implied, statutory or otherwise. The term "warranty" used herein
|
||||
includes, but is not limited to, any warranty of the quality,
|
||||
performance, merchantability and fitness for a particular purpose of
|
||||
the program and the nonexistence of any infringement or violation of
|
||||
any right of any third party.
|
||||
|
||||
Each user of the program will agree and understand, and be deemed to
|
||||
have agreed and understood, that there is no warranty whatsoever for
|
||||
the program and, accordingly, the entire risk arising from or
|
||||
otherwise connected with the program is assumed by the user.
|
||||
|
||||
Therefore, neither ICOT, the copyright holder, or any other
|
||||
organization that participated in or was otherwise related to the
|
||||
development of the program and their respective officials, directors,
|
||||
officers and other employees shall be held liable for any and all
|
||||
damages, including, without limitation, general, special, incidental
|
||||
and consequential damages, arising out of or otherwise in connection
|
||||
with the use or inability to use the program or any product, material
|
||||
or result produced or otherwise obtained by using the program,
|
||||
regardless of whether they have been advised of, or otherwise had
|
||||
knowledge of, the possibility of such damages at any time during the
|
||||
project or thereafter. Each user will be deemed to have agreed to the
|
||||
foregoing by his or her commencement of use of the program. The term
|
||||
"use" as used herein includes, but is not limited to, the use,
|
||||
modification, copying and distribution of the program and the
|
||||
production of secondary products from the program.
|
||||
|
||||
In the case where the program, whether in its original form or
|
||||
modified, was distributed or delivered to or received by a user from
|
||||
any person, organization or entity other than ICOT, unless it makes or
|
||||
grants independently of ICOT any specific warranty to the user in
|
||||
writing, such person, organization or entity, will also be exempted
|
||||
from and not be held liable to the user for any such damages as noted
|
||||
above as far as the program is concerned.
|
||||
÷÷
|
||||
@@ -0,0 +1,7 @@
|
||||
This software includes a binary version of data from
|
||||
|
||||
http://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/mecab-ipadic-2.7.0-20070801.tar.gz,
|
||||
|
||||
where the connection ids are remapped using CORE data in BCCWJ (except the PN category)
|
||||
|
||||
https://clrd.ninjal.ac.jp/bccwj/.
|
||||
@@ -3,7 +3,9 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use cjdic2_core::{AppService, CJDicError, SqlParam, YomitanRow, YomitanZipImportResult};
|
||||
use cjdic2_core::{
|
||||
AppService, CJDicError, SqlParam, TokenizeSegment, YomitanRow, YomitanZipImportResult,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::{AppHandle, Emitter, Manager};
|
||||
use tauri_plugin_http::reqwest::Client;
|
||||
@@ -242,3 +244,11 @@ pub async fn download_url(
|
||||
.await
|
||||
.map_err(|e| CJDicError::Error(e.to_string()))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn tokenize(
|
||||
text: String,
|
||||
state: tauri::State<'_, AppService>,
|
||||
) -> Result<Vec<TokenizeSegment>, CJDicError> {
|
||||
state.ja_tokenize(text)
|
||||
}
|
||||
+23
-3
@@ -1,8 +1,9 @@
|
||||
use std::fs::create_dir_all;
|
||||
use std::fs::{self, create_dir_all};
|
||||
|
||||
use crate::command::*;
|
||||
use cjdic2_core::*;
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_fs::FsExt;
|
||||
|
||||
mod command;
|
||||
|
||||
@@ -17,9 +18,27 @@ pub fn run() {
|
||||
let app_dir = app.path().app_config_dir()?;
|
||||
create_dir_all(&app_dir)?;
|
||||
|
||||
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",
|
||||
tauri::path::BaseDirectory::Resource,
|
||||
)?;
|
||||
|
||||
// Use Tauri's fs abstraction — works on both Android and desktop
|
||||
let bytes = app.fs().read(&resource_path)?;
|
||||
|
||||
// Write to app's cache dir, which IS a real writable filesystem path on Android
|
||||
let cache_dir = app.path().cache_dir()?;
|
||||
create_dir_all(&cache_dir)?;
|
||||
let dict_path = cache_dir.join("system.dic.zst");
|
||||
fs::write(&dict_path, &bytes)?;
|
||||
|
||||
dict_path
|
||||
};
|
||||
|
||||
// db_path is app_dir;
|
||||
let db_dir = app_dir.as_path();
|
||||
let service = AppService::new(&db_dir)?;
|
||||
let service = AppService::new(&app_dir, &dict_path)?;
|
||||
app.manage(service);
|
||||
|
||||
let app_data_dir = app.path().app_data_dir()?;
|
||||
@@ -34,6 +53,7 @@ pub fn run() {
|
||||
search_yomitan,
|
||||
execute_sql,
|
||||
download_url,
|
||||
tokenize,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"resources": [
|
||||
"resources/**/system.dic.zst"
|
||||
],
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
|
||||
Reference in new issue
Block a user