Skip to content

Commit

Permalink
Upgrade lindera 0.6.0 and tantivy 0.13.2 (#10)
Browse files Browse the repository at this point in the history
Closes #9
  • Loading branch information
johtani committed Oct 8, 2020
1 parent f66e9e2 commit 821df1c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Upgrade lindera 0.6.0 and tantivy 0.13.2 @johtani

## 0.2.0 (2020-08-25)
- Update Makefile #8 @mosuka
- Bump up version (tantivy 0.13.0) #7 @ken0x0a
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ categories = ["text-processing"]
license = "MIT"

[dependencies]
lindera = "0.5.1"
tantivy = "0.13.0"
lindera = "0.6.0"
lindera-core = "0.6.0"
tantivy = "0.13.2"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A Tokenizer for [Tantivy](https://github.com/tantivy-search/tantivy), based on [

The following products are required to build:

- Rust >= 1.39.0
- Rust >= 1.46.0
- make >= 3.81

```text
Expand Down
10 changes: 10 additions & 0 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::stream::LinderaTokenStream;
use lindera::tokenizer::Tokenizer as LTokenizer;
use lindera_core::core::viterbi::{Mode, Penalty};
use tantivy::tokenizer::{BoxTokenStream, Tokenizer};

/// Tokenize text with the specified mode and dictionary.
Expand Down Expand Up @@ -70,6 +71,15 @@ pub struct LinderaTokenizer {

impl LinderaTokenizer {
pub fn new(mode: &str, dict: &str) -> LinderaTokenizer {
let mode = match mode {
"normal" => Mode::Normal,
"decompose" => Mode::Decompose(Penalty::default()),
_ => {
// show error message
println!("unsupported mode: {}", mode);
Mode::Normal
}
};
LinderaTokenizer {
tokenizer: LTokenizer::new(mode, dict),
}
Expand Down

0 comments on commit 821df1c

Please sign in to comment.