Results 1 to 11 of 11
Like Tree1Likes
  • 1 Post By JosAH

Thread: Java synonyms

  1. #1
    HH2H is offline Member
    Join Date
    May 2012
    Posts
    5
    Rep Power
    0

    Post Java synonyms

    I am quite new to Java, and need help with creating synonym with different words. I needed some help to get start with it. Do I need hashMap or I just use Nodes?

    appretiate all help, thanks! =)

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Java synonyms

    What have you tried? Where are you stuck? It's pretty impossible to answer general "how do I do this" type questions other than to point you to google or the basic tutorials. How would you do this without a computer?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    HH2H is offline Member
    Join Date
    May 2012
    Posts
    5
    Rep Power
    0

    Default Re: Java synonyms

    It havnt found anything on google that explains to me what I could use. I have searched a while now. thought if somebody in this forum could me just to get started, and then I'll post my work when I get stuck

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Java synonyms

    How would you use a HashMap? How would you use "nodes"?

    There are too many ways to solve a problem to simply list them, and how you should solve it depends on what you're familiar with.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    HH2H is offline Member
    Join Date
    May 2012
    Posts
    5
    Rep Power
    0

    Default Re: Java synonyms

    I thought of using HashMap, HashMap<String,String[]>. But with HashMap you can get one Value to a Key. Can I use a MultiMap to store more synonyms for a word, than just one?

  6. #6
    HH2H is offline Member
    Join Date
    May 2012
    Posts
    5
    Rep Power
    0

    Default Re: Java synonyms

    I will write a code now for it, and soon present to you using hashMap.

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Java synonyms

    Quote Originally Posted by HH2H View Post
    I thought of using HashMap, HashMap<String,String[]>. But with HashMap you can get one Value to a Key. Can I use a MultiMap to store more synonyms for a word, than just one?
    Seems reasonable to me. And having only one value per key is okay, as that one value is an array, which can contain multiple values. You might also consider using a Map of Strings to Lists of Strings.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: Java synonyms

    Or a Map<String, Set<String>>

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java synonyms

    Quote Originally Posted by DarrylBurke View Post
    Or a Map<String, Set<String>>
    You can take the idea a bit further: if B is a synonym for A then A is a key in the Map and B appears as an element in the value Set. But also B is a key in the Map and A appears as a member in the value Set. In other words: if B is a synonym for A then A is a synonym for B;. This implies that the value Sets for A and B can be one Set, pointed to by both A and B. A bit of careful construction of the Map takes care of this relation and it shrinks the footprint of the Map ...

    kind regards,

    Jos
    DarrylBurke likes this.
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    HH2H is offline Member
    Join Date
    May 2012
    Posts
    5
    Rep Power
    0

    Default Re: Java synonyms

    But How can I make a Set of Values to appear as Key. If B, C, D is synonym for A. If I make 100 different synonyms, is there an easy way to apply this for 100 synonyms for example?

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java synonyms

    Quote Originally Posted by HH2H View Post
    But How can I make a Set of Values to appear as Key. If B, C, D is synonym for A. If I make 100 different synonyms, is there an easy way to apply this for 100 synonyms for example?
    That is not what I was trying to say: my idea was that A, B, C and D all point to the same set [A, B, C, D] because all are synonyms.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

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