diff --git a/kuromoji-core/src/main/java/com/atilika/kuromoji/TokenizerBase.java b/kuromoji-core/src/main/java/com/atilika/kuromoji/TokenizerBase.java index e215a4c..ae4413f 100644 --- a/kuromoji-core/src/main/java/com/atilika/kuromoji/TokenizerBase.java +++ b/kuromoji-core/src/main/java/com/atilika/kuromoji/TokenizerBase.java @@ -403,6 +403,18 @@ protected void loadDictionaries() { */ public abstract T build(); + /** + * Sets user-defined {@link ResourceResolver}. + * + * @param resolver {@link com.atilika.kuromoji.util.SimpleResourceResolver SimpleResourceResolver} + * or user-defined implementation. + * @return this builder + */ + public Builder resolver(ResourceResolver resolver) { + this.resolver = resolver; + return this; + } + /** * Sets an optional user dictionary as an input stream *

diff --git a/kuromoji-ipadic-neologd/src/main/java/com/atilika/kuromoji/ipadic/neologd/Tokenizer.java b/kuromoji-ipadic-neologd/src/main/java/com/atilika/kuromoji/ipadic/neologd/Tokenizer.java index eee48b5..535f272 100644 --- a/kuromoji-ipadic-neologd/src/main/java/com/atilika/kuromoji/ipadic/neologd/Tokenizer.java +++ b/kuromoji-ipadic-neologd/src/main/java/com/atilika/kuromoji/ipadic/neologd/Tokenizer.java @@ -112,6 +112,8 @@ public Builder() { readingFeature = DictionaryEntry.READING_FEATURE; partOfSpeechFeature = DictionaryEntry.PART_OF_SPEECH_FEATURE; + resolver = new SimpleResourceResolver(this.getClass()); + tokenFactory = new TokenFactory() { @Override public Token createToken(int wordId, @@ -211,8 +213,6 @@ protected void loadDictionaries() { penalties.add(otherPenaltyLengthThreshold); penalties.add(otherPenalty); - resolver = new SimpleResourceResolver(this.getClass()); - try { fst = FST.newInstance(resolver); connectionCosts = ConnectionCosts.newInstance(resolver); diff --git a/kuromoji-ipadic/src/main/java/com/atilika/kuromoji/ipadic/Tokenizer.java b/kuromoji-ipadic/src/main/java/com/atilika/kuromoji/ipadic/Tokenizer.java index 3e90125..4908377 100644 --- a/kuromoji-ipadic/src/main/java/com/atilika/kuromoji/ipadic/Tokenizer.java +++ b/kuromoji-ipadic/src/main/java/com/atilika/kuromoji/ipadic/Tokenizer.java @@ -112,6 +112,8 @@ public Builder() { readingFeature = DictionaryEntry.READING_FEATURE; partOfSpeechFeature = DictionaryEntry.PART_OF_SPEECH_FEATURE; + resolver = new SimpleResourceResolver(this.getClass()); + tokenFactory = new TokenFactory() { @Override public Token createToken(int wordId, @@ -211,8 +213,6 @@ protected void loadDictionaries() { penalties.add(otherPenaltyLengthThreshold); penalties.add(otherPenalty); - resolver = new SimpleResourceResolver(this.getClass()); - try { fst = FST.newInstance(resolver); connectionCosts = ConnectionCosts.newInstance(resolver);