Skip to content

Commit

Permalink
Update Lindera to 0.13.2 (#48)
Browse files Browse the repository at this point in the history
* Update Lindera to 0.13.2

* Update CHANGES.md
  • Loading branch information
mosuka authored Apr 8, 2022
1 parent aaf2178 commit 1ccf9fe
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 0.13.2 (2022-04-08)
- Update Lindera to 0.13.2 #48 @mosuka

## 0.13.1 (2022-04-08)
- Update Lindera to 0.13.1 #47 @mosuka

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lindera-tantivy"
version = "0.13.1"
version = "0.13.2"
edition = "2021"
description = "Lindera Tokenizer for Tantivy."
documentation = "https://docs.rs/lindera-tantivy"
Expand All @@ -22,7 +22,7 @@ cc-cedict = ["lindera/cc-cedict"] # Chinese dictionary
[dependencies]
tantivy = "0.17"

lindera = "0.13.1"
lindera = "0.13.2"

[dev-dependencies]
criterion = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ fn bench_indexing(c: &mut Criterion) {
use tantivy::schema::{IndexRecordOption, Schema, TextFieldIndexing, TextOptions};
use tantivy::Index;

use lindera::mode::{Mode, Penalty};
use lindera::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};
use lindera_tantivy::mode::{Mode, Penalty};
use lindera_tantivy::tokenizer::LinderaTokenizer;
use lindera_tantivy::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};

// create schema builder
let mut schema_builder = Schema::builder();
Expand Down
4 changes: 2 additions & 2 deletions examples/cc-cedict_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ fn main() -> tantivy::Result<()> {
use tantivy::schema::{IndexRecordOption, Schema, TextFieldIndexing, TextOptions};
use tantivy::Index;

use lindera::mode::{Mode, Penalty};
use lindera::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};
use lindera_tantivy::mode::{Mode, Penalty};
use lindera_tantivy::tokenizer::LinderaTokenizer;
use lindera_tantivy::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};

// create schema builder
let mut schema_builder = Schema::builder();
Expand Down
4 changes: 2 additions & 2 deletions examples/ipadic_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ fn main() -> tantivy::Result<()> {
use tantivy::schema::{IndexRecordOption, Schema, TextFieldIndexing, TextOptions};
use tantivy::Index;

use lindera::mode::{Mode, Penalty};
use lindera::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};
use lindera_tantivy::mode::{Mode, Penalty};
use lindera_tantivy::tokenizer::LinderaTokenizer;
use lindera_tantivy::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};

// create schema builder
let mut schema_builder = Schema::builder();
Expand Down
4 changes: 2 additions & 2 deletions examples/ko-dic_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ fn main() -> tantivy::Result<()> {
use tantivy::schema::{IndexRecordOption, Schema, TextFieldIndexing, TextOptions};
use tantivy::Index;

use lindera::mode::{Mode, Penalty};
use lindera::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};
use lindera_tantivy::mode::{Mode, Penalty};
use lindera_tantivy::tokenizer::LinderaTokenizer;
use lindera_tantivy::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};

// create schema builder
let mut schema_builder = Schema::builder();
Expand Down
4 changes: 2 additions & 2 deletions examples/unidic_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ fn main() -> tantivy::Result<()> {
use tantivy::schema::{IndexRecordOption, Schema, TextFieldIndexing, TextOptions};
use tantivy::Index;

use lindera::mode::{Mode, Penalty};
use lindera::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};
use lindera_tantivy::mode::{Mode, Penalty};
use lindera_tantivy::tokenizer::LinderaTokenizer;
use lindera_tantivy::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};

// create schema builder
let mut schema_builder = Schema::builder();
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
pub mod mode;
pub mod stream;
pub mod tokenizer;

use lindera::LinderaResult as LLinderaResult;

pub type LinderaResult<T> = LLinderaResult<T>;
4 changes: 4 additions & 0 deletions src/mode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use lindera::mode::{Mode as LinderaMode, Penalty as LinderaPenalty};

pub type Penalty = LinderaPenalty;
pub type Mode = LinderaMode;
22 changes: 13 additions & 9 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use tantivy::tokenizer::{BoxTokenStream, Tokenizer};
use tantivy::tokenizer::{BoxTokenStream, Tokenizer as TTokenizer};

use lindera::tokenizer::{Tokenizer as LTokenizer, TokenizerConfig};
use lindera::LinderaResult;
use lindera::tokenizer::{
DictionaryType as LDictionaryType, Tokenizer as LTokenizer,
TokenizerConfig as LTokenizerConfig, UserDictionaryType as LUserDictionaryType,
};

use crate::stream::LinderaTokenStream;
use crate::LinderaResult;

pub type DictionaryType = LDictionaryType;
pub type UserDictionaryType = LUserDictionaryType;
pub type TokenizerConfig = LTokenizerConfig;

/// Tokenize text with the specified mode and dictionary.
pub struct LinderaTokenizer {
pub tokenizer: LTokenizer,
}
Expand All @@ -32,7 +38,7 @@ impl LinderaTokenizer {
}
}

impl Tokenizer for LinderaTokenizer {
impl TTokenizer for LinderaTokenizer {
fn token_stream<'a>(&self, text: &'a str) -> BoxTokenStream<'a> {
let result = match self.tokenizer.tokenize(text) {
Ok(result) => result,
Expand All @@ -53,10 +59,8 @@ impl Tokenizer for LinderaTokenizer {
mod tests {
use tantivy::tokenizer::{BoxTokenStream, Token, Tokenizer};

use lindera::mode::{Mode, Penalty};
use lindera::tokenizer::{DictionaryType, TokenizerConfig, UserDictionaryType};

use crate::tokenizer::LinderaTokenizer;
use crate::mode::{Mode, Penalty};
use crate::tokenizer::{DictionaryType, LinderaTokenizer, TokenizerConfig, UserDictionaryType};

fn test_helper(mut tokenizer: BoxTokenStream) -> Vec<Token> {
let mut tokens: Vec<Token> = vec![];
Expand Down

0 comments on commit 1ccf9fe

Please sign in to comment.