I've changed my ~/.bashrc
file. I've changed /etc/environment
. I've done export WNHOME="/usr/local/WordNet-3.0"
. I tried everything here and more. (I'm running arch linux, in case that's of any consequence).
I think the environment variable must be set on my machine, if I check it with echo $WNHOME
I get the correct result.
However when I call System.out.println(System.getenv("WNHOME"));
in my java program I keep getting null
, what could be the reason for this?
The output looks like this:
Path is 'null/dict'
null
Exception in thread "main" java.io.IOException: Dictionary directory does not exist: null/dict
at edu.mit.jwi.data.FileProvider.open(FileProvider.java:306)
at edu.mit.jwi.DataSourceDictionary.open(DataSourceDictionary.java:92)
at edu.mit.jwi.CachingDictionary.open(CachingDictionary.java:133)
at MITJavaWordNetInterface.main(MITJavaWordNetInterface.java:30)
The code looks like this:
public static void main(String[] args) throws IOException
{
// construct the URL to the Wordnet dictionary directory
String wnhome = System.getenv("WNHOME");
String path = wnhome + File.separator + "dict";
System.out.println("Path is '" + path + "'");
URL url = new URL ("file", null , path );
System.out.println(System.getenv("WNHOME"));
//final URL url = Paths.get(wnhome, "dict").toUri().toURL();
// construct the dictionary object and open it
IDictionary dict = new Dictionary ( url ) ;
dict . open () ;
// 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 () ) ;
}