Wordnet与Android

时间:2016-02-15 16:21:30

标签: android integration wordnet

我想找到一些方法将wordnet数据库集成到Android应用程序并直接访问它

我的代码

@Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.dictionary_test);

            URL url=null;
            IDictionary dict=null;
            AssetManager assetManager = getAssets();
            try {

            String path = "file:///android_asset/dict/";<----problem probabaly

            url = new URL("file", null, path);
            //construct the Dictionary object and open it
            dict = new Dictionary(url);
            dict.open();
            }
            catch (Exception e){
                e.printStackTrace();}

            // look up first sense of the word "dog "
            IIndexWord idxWord = dict.getIndexWord ("dog", POS.NOUN );
            IWordID wordID = idxWord.getWordIDs().get(0) ;
            IWord word = dict.getWord (wordID);
//            System.out.println("Id = " + wordID);
//            System.out.println(" Lemma = " + word.getLemma());
//            System.out.println(" Gloss = " + word.getSynset().getGloss());
i used toast for above printlns
        }

我从

尝试了这个

Regarding the assets folder and environment variables on android

阅读此内容但没有帮助 Access WordNet dict files in Android app

我在这里读到资产文件夹的文件不能超过1 mb,但有些文件超过1 mb,差不多有5或8 mb。 如果是这样 1.如何将应用程序复制所需文件复制到外部位置?

我收到错误

java.lang.RuntimeException: Unable to start activity ComponentInfo{dictionaryTest}: edu.mit.jwi.data.IHasLifecycle$ObjectClosedException
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
         at android.app.ActivityThread.access$600(ActivityThread.java:130)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
         at android.os.Handler.dispatchMessage(Handler.java:99)
         at android.os.Looper.loop(Looper.java:137)
         at android.app.ActivityThread.main(ActivityThread.java:4745)
         at java.lang.reflect.Method.invokeNative(Native Method)
         at java.lang.reflect.Method.invoke(Method.java:511)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
         at dalvik.system.NativeStart.main(Native Method)
      Caused by: edu.mit.jwi.data.IHasLifecycle$ObjectClosedException
         at edu.mit.jwi.CachingDictionary.checkOpen(CachingDictionary.java:112)
         at edu.mit.jwi.CachingDictionary.getIndexWord(CachingDictionary.java:191)
         at com.blogspot.lsdhillon.makinglist.dictionaryTest.onCreate(dictionaryTest.java:58)
         at android.app.Activity.performCreate(Activity.java:5008)
         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
         at android.app.ActivityThread.access$600(ActivityThread.java:130) 
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
         at android.os.Handler.dispatchMessage(Handler.java:99) 
         at android.os.Looper.loop(Looper.java:137) 
         at android.app.ActivityThread.main(ActivityThread.java:4745) 
         at java.lang.reflect.Method.invokeNative(Native Method) 
         at java.lang.reflect.Method.invoke(Method.java:511) 
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
         at dalvik.system.NativeStart.main(Native Method) 

首先使用此数据库 http://wordnetcode.princeton.edu/wn3.1.dict.tar.gz

稍后尝试这个 http://wordnetcode.princeton.edu/3.0/WNdb-3.0.tar.gz

但无法解决错误

所有建议都适用

0 个答案:

没有答案