Results 1 to 2 of 2
  1. #1
    zoe
    zoe is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default 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.

    Java 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

  2. #2
    fernando is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default

    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:
    Java Code:
    s[0] = "obstetrical"
    s[1] = "delivery"
    s[2] = "n"
    So you would do:
    Java 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.

Similar Threads

  1. HashTable vs HashMap
    By bugger in forum New To Java
    Replies: 7
    Last Post: 01-06-2011, 04:15 PM
  2. HashMap with objects
    By otoro_java in forum New To Java
    Replies: 2
    Last Post: 01-28-2008, 04:28 PM
  3. HashMap visual example
    By jhetfield18 in forum Advanced Java
    Replies: 1
    Last Post: 12-12-2007, 08:45 PM
  4. Hashmap
    By dirtycash in forum New To Java
    Replies: 5
    Last Post: 12-03-2007, 03:58 AM
  5. what is hashmap
    By gabriel in forum New To Java
    Replies: 5
    Last Post: 08-03-2007, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •