Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-northlander committed Jul 1, 2024
1 parent 402c178 commit dd388b8
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 18 deletions.
7 changes: 3 additions & 4 deletions python/src/projection.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -112,9 +112,8 @@ impl MorphemeProjection for NormalizedNouns {
}

fn conjugating_matcher<D: DictionaryAccess>(dic: &D) -> PosMatcher {
make_matcher(dic, |pos| match pos[0].deref() {
"動詞" | "形容詞" | "助動詞" => true,
_ => false,
make_matcher(dic, |pos| {
matches!(pos[0].deref(), "動詞" | "形容詞" | "助動詞")
})
}

Expand Down
3 changes: 1 addition & 2 deletions sudachi/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sudachi/src/dic/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl<D: DictionaryAccess> DictBuilder<D> {
}

/// 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
Expand Down
5 changes: 2 additions & 3 deletions sudachi/src/plugin/input_text/default_input_text/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion sudachi/src/plugin/oov/mecab_oov/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion sudachi/src/plugin/oov/mecab_oov/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions sudachi/src/plugin/oov/regex_oov/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum Error {
None,
Point,
Comma,
// OTHER,
// Other,
}

/// Parses number written by arabic or kanji
Expand Down
5 changes: 2 additions & 3 deletions sudachi/src/util/user_pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit dd388b8

Please sign in to comment.