-
Notifications
You must be signed in to change notification settings - Fork 78
Optional Lindera tokenizer support (was: Custom tokenizer support) #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
d9fc544
6e82b23
64dc8df
27e2f41
a94c3cc
7ea1d8f
051e790
3765098
0a3f53c
a985769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,17 @@ | |
def test(session): | ||
session.install("-rrequirements-dev.txt") | ||
session.install("-e", ".", "--no-build-isolation") | ||
session.run("pytest", "-m", "not lindera", *session.posargs) | ||
|
||
|
||
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"]) | ||
def test_lindera(session): | ||
session.install("-rrequirements-dev.txt") | ||
session.install( | ||
"--no-build-isolation", | ||
'--config-settings', | ||
'build-args="--features=lindera"', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It took a surprisingly long time to discover the correct way to spell how to get this value sent down to the build backend! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, even with the unified There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maturin wasn't too bad, it is pretty easy to find "feature selection" and that shows up under the I had a quick look, I think this section is probably the best place to mention the |
||
"-e", | ||
".", | ||
) | ||
session.run("pytest", *session.posargs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use lindera_core::mode::Mode; | ||
use lindera_dictionary::{ | ||
load_dictionary_from_config, DictionaryConfig, DictionaryKind, | ||
}; | ||
use lindera_tantivy::tokenizer::LinderaTokenizer; | ||
|
||
pub fn create_tokenizer(mode: Mode) -> LinderaTokenizer { | ||
let dictionary_config = DictionaryConfig { | ||
kind: Some(DictionaryKind::IPADIC), | ||
cjrh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
path: None, | ||
}; | ||
let dictionary = load_dictionary_from_config(dictionary_config).unwrap(); | ||
let tokenizer = LinderaTokenizer::new(dictionary, None, mode); | ||
|
||
tokenizer | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
pytestmark = pytest.mark.lindera | ||
|
||
from tantivy import SchemaBuilder, Index, Document | ||
|
||
|
||
def test_basic(): | ||
sb = SchemaBuilder() | ||
sb.add_text_field("title", stored=True, tokenizer_name="lang_ja") | ||
schema = sb.build() | ||
index = Index(schema) | ||
index.register_lindera_tokenizer() | ||
writer = index.writer(50_000_000) | ||
doc = Document() | ||
doc.add_text("title", "成田国際空港") | ||
writer.add_document(doc) | ||
writer.commit() | ||
index.reload() |
Uh oh!
There was an error while loading. Please reload this page.