Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2007, 03:37 AM
zoe zoe is offline
Member
 
Join Date: Jul 2007
Posts: 40
zoe is on a distinguished road
Help with Lexical units, use hashmap
Hi, I have a file which holds lexical units (words). Lexical units have an ID, the word, and it's type. I can read the file using a file-reader and bufferedreader which gives this output.

Code:
record 138: 100038353 uncovering n record 139: 100038749 disposal n record 140: 100038749 disposition n record 141: 100039042 hit n record 142: 100039290 implementation n record 143: 100039290 effectuation n record 144: 100039595 egress n record 145: 100039595 egression n record 146: 100039595 emergence n record 147: 100039813 equalization n record 148: 100039813 equalisation n record 149: 100039813 leveling n record 130: 100037703 obstetrical delivery n
Basically, i want to put this into a hashmap so I can search the records. My problem is that sometimes a lexical unit comprises of more than one word example obstetrical delivery rather than just being ID word type.

Can anyone suggest how I put this data into a hashmap?
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 08:14 AM
Member
 
Join Date: Jul 2007
Posts: 40
fernando is on a distinguished road
Depends on how things are characterized. What you could do to solve the problem is to have read the line after the ID up until the carriage return. Then, use a StringTokenizer to separate words by spaces and then use the last word as the type, and combine the rest in order as the word.

So you would read in the ID, then read in the following string:

"obstetrical delivery n"

You would then tokenize it and it would separate into:
Code:
s[0] = "obstetrical" s[1] = "delivery" s[2] = "n"
So you would do:
Code:
type = s[s.length]; StringBuffer word = new StringBuffer(""); for (int i; i < s.length; i++) word = word + s[i];
Note, the above is pseudo code, don't copy it into your compiler.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HashMap with objects otoro_java New To Java 2 01-28-2008 05:28 PM
HashMap visual example jhetfield18 Advanced Java 1 12-12-2007 09:45 PM
Hashmap dirtycash New To Java 5 12-03-2007 04:58 AM
HashTable vs HashMap bugger New To Java 3 11-29-2007 02:28 PM
what is hashmap gabriel New To Java 5 08-03-2007 03:23 PM


All times are GMT +3. The time now is 09:47 AM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org