From dd388b8646c4f7d413e5dc95fb75d4569c5afe5f Mon Sep 17 00:00:00 2001 From: mh-northlander Date: Mon, 1 Jul 2024 09:18:47 +0900 Subject: [PATCH] small fix --- python/src/projection.rs | 7 +++---- sudachi/src/config.rs | 3 +-- sudachi/src/dic/build/mod.rs | 2 +- sudachi/src/plugin/input_text/default_input_text/mod.rs | 5 ++--- sudachi/src/plugin/oov/mecab_oov/mod.rs | 5 ++++- sudachi/src/plugin/oov/mecab_oov/test.rs | 2 +- sudachi/src/plugin/oov/regex_oov/mod.rs | 3 +-- .../plugin/path_rewrite/join_numeric/numeric_parser/mod.rs | 2 +- sudachi/src/util/user_pos.rs | 5 ++--- 9 files changed, 16 insertions(+), 18 deletions(-) diff --git a/python/src/projection.rs b/python/src/projection.rs index 8bea35be..2c2cc2be 100644 --- a/python/src/projection.rs +++ b/python/src/projection.rs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Works Applications Co., Ltd. + * Copyright (c) 2023-2024 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,9 +112,8 @@ impl MorphemeProjection for NormalizedNouns { } fn conjugating_matcher(dic: &D) -> PosMatcher { - make_matcher(dic, |pos| match pos[0].deref() { - "動詞" | "形容詞" | "助動詞" => true, - _ => false, + make_matcher(dic, |pos| { + matches!(pos[0].deref(), "動詞" | "形容詞" | "助動詞") }) } diff --git a/sudachi/src/config.rs b/sudachi/src/config.rs index b924e35a..d65dfb1c 100644 --- a/sudachi/src/config.rs +++ b/sudachi/src/config.rs @@ -100,9 +100,8 @@ impl PathResolver { } } -#[derive(Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +#[derive(Deserialize, Clone, Copy, Debug, Eq, PartialEq, Default)] #[serde(rename_all = "snake_case")] -#[derive(Default)] pub enum SurfaceProjection { #[default] Surface, diff --git a/sudachi/src/dic/build/mod.rs b/sudachi/src/dic/build/mod.rs index 6a034a8a..dbbdda1f 100644 --- a/sudachi/src/dic/build/mod.rs +++ b/sudachi/src/dic/build/mod.rs @@ -305,7 +305,7 @@ impl DictBuilder { } /// this function must only be used in resolve_impl - fn unsafe_make_resolver<'b>(&self) -> RawDictResolver<'b> { + fn unsafe_make_resolver<'a>(&self) -> RawDictResolver<'a> { let resolver = RawDictResolver::new(self.lexicon.entries(), self.user); // resolver borrows parts of entries, but it does not touch splits // resolve function only modifies splits diff --git a/sudachi/src/plugin/input_text/default_input_text/mod.rs b/sudachi/src/plugin/input_text/default_input_text/mod.rs index 7379587f..0f92ea56 100644 --- a/sudachi/src/plugin/input_text/default_input_text/mod.rs +++ b/sudachi/src/plugin/input_text/default_input_text/mod.rs @@ -236,10 +236,9 @@ impl DefaultInputTextPlugin { ch: char, ) { if let Some(ch2) = data.next() { - if ch2 == ch { - return; + if ch2 != ch { + replacer.replace_char_iter(start..start + len, ch2, data) } - replacer.replace_char_iter(start..start + len, ch2, data) } } } diff --git a/sudachi/src/plugin/oov/mecab_oov/mod.rs b/sudachi/src/plugin/oov/mecab_oov/mod.rs index c3895067..5c27524e 100644 --- a/sudachi/src/plugin/oov/mecab_oov/mod.rs +++ b/sudachi/src/plugin/oov/mecab_oov/mod.rs @@ -131,7 +131,10 @@ impl MeCabOovPlugin { let cols: Vec<_> = line.split(',').collect(); if cols.len() < 10 { - return Err(SudachiError::InvalidDataFormat(i, line.to_string())); + return Err(SudachiError::InvalidDataFormat( + i, + format!("Invalid number of columns ({})", line), + )); } let category_type: CategoryType = cols[0].parse()?; if !categories.contains_key(&category_type) { diff --git a/sudachi/src/plugin/oov/mecab_oov/test.rs b/sudachi/src/plugin/oov/mecab_oov/test.rs index 0e352ac6..f5ca6550 100644 --- a/sudachi/src/plugin/oov/mecab_oov/test.rs +++ b/sudachi/src/plugin/oov/mecab_oov/test.rs @@ -437,7 +437,7 @@ fn read_oov_with_too_few_columns() { &mut grammar, UserPosMode::Forbid, ); - assert_matches!(result, Err(SudachiError::InvalidDataFormat(0, s)) if s == data); + assert_matches!(result, Err(SudachiError::InvalidDataFormat(0, s)) if s.contains(data)); } #[test] diff --git a/sudachi/src/plugin/oov/regex_oov/mod.rs b/sudachi/src/plugin/oov/regex_oov/mod.rs index 20698e7d..1fdd1359 100644 --- a/sudachi/src/plugin/oov/regex_oov/mod.rs +++ b/sudachi/src/plugin/oov/regex_oov/mod.rs @@ -44,9 +44,8 @@ pub(crate) struct RegexOovProvider { boundaries: BoundaryMode, } -#[derive(Deserialize, Eq, PartialEq, Debug, Copy, Clone)] +#[derive(Deserialize, Eq, PartialEq, Debug, Copy, Clone, Default)] #[serde(rename_all = "lowercase")] -#[derive(Default)] pub enum BoundaryMode { #[default] Strict, diff --git a/sudachi/src/plugin/path_rewrite/join_numeric/numeric_parser/mod.rs b/sudachi/src/plugin/path_rewrite/join_numeric/numeric_parser/mod.rs index c8658f2f..27c3c481 100644 --- a/sudachi/src/plugin/path_rewrite/join_numeric/numeric_parser/mod.rs +++ b/sudachi/src/plugin/path_rewrite/join_numeric/numeric_parser/mod.rs @@ -27,7 +27,7 @@ pub enum Error { None, Point, Comma, - // OTHER, + // Other, } /// Parses number written by arabic or kanji diff --git a/sudachi/src/util/user_pos.rs b/sudachi/src/util/user_pos.rs index 87694189..06a2f332 100644 --- a/sudachi/src/util/user_pos.rs +++ b/sudachi/src/util/user_pos.rs @@ -20,13 +20,12 @@ use itertools::Itertools; use serde::Deserialize; use std::fmt::Display; -#[derive(Eq, PartialEq, Deserialize, Clone, Copy, Debug)] +#[derive(Eq, PartialEq, Deserialize, Clone, Copy, Debug, Default)] #[serde(rename_all = "lowercase")] -#[derive(Default)] pub enum UserPosMode { - Allow, #[default] Forbid, + Allow, } pub trait UserPosSupport {