0

I wanted to find some way to integrate wordnet database into android app and accessing it directly

My code

@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
        }

i have tried this from

Regarding the assets folder and environment variables on android

read this but doesnt help Access WordNet dict files in Android app

I read here and there that assets folder cannot have more than 1 mb file, but some of the files are more than 1 mb almost 5 or 8 mb. if so 1. how to make app copy required files copy to external locations?

error i receive

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) 

used this database first http://wordnetcode.princeton.edu/wn3.1.dict.tar.gz

later tries this http://wordnetcode.princeton.edu/3.0/WNdb-3.0.tar.gz

But cant resolve the error

All suggestions are appriciated

Community
  • 1
  • 1

0 Answers0