我想使用日本形态分析器库Kuromoji到Android应用程序,但得到一个错误

时间:2014-11-07 06:54:30

标签: android scala

我是日本的高中生。 我的英语不好。

文字难以阅读,你可能会说粗鲁的话。

如果你能帮助我,我很高兴。

我正在开发一款Android应用。

我想在Android应用程序中使用日语形态分析器库“Kuromoji”

我使用sbt下载了Kuromoji。

build.sbt
resolvers += "Atilika Open Source repository" at "http://www.atilika.org/nexus/content/repositories/atilika"

libraryDependencies += "org.atilika.kuromoji" % "kuromoji" % "0.7.7"

但是当你运行

时出现以下错误
java.lang.ExceptionInInitializerError
            at org.atilika.kuromoji.Tokenizer.<init>(Tokenizer.java:64)
            at org.atilika.kuromoji.Tokenizer$Builder.build(Tokenizer.java:237)
            at jp.ac.jec.KuromojiPalyground$.test(KuromojiPalyground.scala:13)
            at jp.ac.jec.MainActivity.onCreate(MainActivity.scala:24)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.RuntimeException: Could not load dictionaries!  Ouch, ouch, ouch...
            at org.atilika.kuromoji.dict.Dictionaries.load(Dictionaries.java:50)
            at org.atilika.kuromoji.dict.Dictionaries.<clinit>(Dictionaries.java:34)
            at org.atilika.kuromoji.Tokenizer.<init>(Tokenizer.java:64)
            at org.atilika.kuromoji.Tokenizer$Builder.build(Tokenizer.java:237)
            at jp.ac.jec.KuromojiPalyground$.test(KuromojiPalyground.scala:13)
            at jp.ac.jec.MainActivity.onCreate(MainActivity.scala:24)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.io.InvalidClassException: org.atilika.kuromoji.dict.CharacterDefinition; Incompatible class (SUID): org.atilika.kuromoji.dict.CharacterDefinition: static final long serialVersionUID =-1436753619176638532L; but expected org.atilika.kuromoji.dict.CharacterDefinition: static final long serialVersionUID =-7276304819937849219L;
            at java.io.ObjectInputStream.verifyAndInit(ObjectInputStream.java:2341)
            at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1640)
            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:658)
            at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1781)
            at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:762)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1981)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1938)
            at org.atilika.kuromoji.dict.UnknownDictionary.loadCharDef(UnknownDictionary.java:137)
            at org.atilika.kuromoji.dict.UnknownDictionary.getInstance(UnknownDictionary.java:131)
            at org.atilika.kuromoji.dict.Dictionaries.load(Dictionaries.java:45)
            at org.atilika.kuromoji.dict.Dictionaries.<clinit>(Dictionaries.java:34)
            at org.atilika.kuromoji.Tokenizer.<init>(Tokenizer.java:64)
            at org.atilika.kuromoji.Tokenizer$Builder.build(Tokenizer.java:237)
            at jp.ac.jec.KuromojiPalyground$.test(KuromojiPalyground.scala:13)
            at jp.ac.jec.MainActivity.onCreate(MainActivity.scala:24)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)

使用它的地方

import android.util.Log
import org.atilika.kuromoji.Tokenizer
import org.atilika.kuromoji.Token
import scala.collection.JavaConversions._

/**
 * Created by you on 2014/11/07.
 */

object KuromojiPalyground {
  def test() = {
    val tokenizer = Tokenizer.builder().build()
    tokenizer.tokenize("お寿司食べたい").foreach({
      (token: Token) => Log.d("Kuromoji", s"${token.getSurfaceForm} \t ${token.getAllFeatures}")
    })
  }
}

我是,但没有找到检查解决方案。

如果有人知道如何解决,我希望你让我知道

0 个答案:

没有答案