The Artima Developer Community
Sponsored Link

Java Answers Forum
Lookup table & multiple jars

2 replies on 1 page. Most recent reply: May 22, 2003 7:24 AM by Michael

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Michael

Posts: 4
Nickname: yaruki
Registered: May, 2003

Lookup table & multiple jars Posted: May 20, 2003 7:26 PM
Reply to this message Reply
Advertisement
I need to implement a class to essentially become a huge lookup table (12k entries) - I feed it a "key" and it returns a value.

1) What is the best way to do this - just build a big HashMap?

2) To initialize it, I'm planning on loading the data from a tab-delimited text file, but I'm a little confused about where that file should live and how I should point my class to it.

3) Related to the previous point, this class will be packaged in a jar that is one of several jars to be passed in through the command line classpath to launch the application. I don't really understand how the "virtual filesystems" represented in each jar relate to each other, and what kind of views of the various namespaces are available to classes in the various jars.

I hope that some of you Java gurus can enlighten me or point me at some resources where I can learn more about these sorts of things.

Thanks!


Jaycee

Posts: 26
Nickname: jaycee
Registered: Apr, 2003

Re: Lookup table & multiple jars Posted: May 21, 2003 9:00 AM
Reply to this message Reply
> 1) What is the best way to do this - just build a big
> HashMap?

If your keys and values are both Strings, use a Properties object.

>
> 2) To initialize it, I'm planning on loading the data from
> a tab-delimited text file, but I'm a little confused about
> where that file should live and how I should point my
> class to it.

Create a lookup.properties file which uses a name=value format instead of tab-delimited. You can put this properties file anywhere, as long as the path is specified when creating the FileInputStream. If you just want to specify the properties file name, and not the full path, you can put it in the same package as the code loading the Properties object.

e.g. one line from lookup.properties
country=Canada

Properties lookupTable = new Properties();
lookupTable.load(new FileInputStream("lookup.properties));



>
> 3) Related to the previous point, this class will be
> packaged in a jar that is one of several jars to be passed
> in through the command line classpath to launch the
> application. I don't really understand how the "virtual
> filesystems" represented in each jar relate to each other,
> and what kind of views of the various namespaces are
> available to classes in the various jars.

I believe there are some good articles on class loading on the Artima site.

Michael

Posts: 4
Nickname: yaruki
Registered: May, 2003

Re: Lookup table & multiple jars Posted: May 22, 2003 7:24 AM
Reply to this message Reply
Jaycee,

>If your keys and values are both Strings, use a Properties object.
Thanks a lot for replying, I really appreciate it. I used that trick once for another project, but it feels like kind of a kludge in this case and a violation of the properties semantics as I understand them. (Or maybe I just have delicate sensibilities :)

Actually, I'm doing a two-stage lookup for natural language processing/corpus linguistics. I want to look a word token up in a list and return the corresponding lemma from a table, and then look up that lemma in a table to get its frequency ranking (an integer, not a string value).

>You can put this properties file anywhere, as long as the path is
>specified when creating the FileInputStream. If you just want to
>specify the properties file name, and not the full path, you can put
>it in the same package as the code loading the Properties object.
That's what I don't understand - what if two of the jars collide with a file or folder name? How can put a text file in a "package"? Do you mean jar?

Still a little hazy, sorry for being so dense.

Flat View: This topic has 2 replies on 1 page
Topic: need interview questions Previous Topic   Next Topic Topic: Class class, array of objects ...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use