Associate
- Joined
- 23 Aug 2004
- Posts
- 1,493
I have a class Dictionary
public class Dictionary
{
private HashMap<String, ArrayList<String>> dictionary;
private HashMap<String, ArrayList<Details>> synset;
public Dictionary()
{
dictionary = new HashMap<String, ArrayList<String>>();
synset = new HashMap<String, ArrayList<Details>>();
}
//some methods
}
and a class Details
public class Details
{
private String word;
private String type;
private String meaning;
private String w_num;
private String sense_num;
private String tag_count;
private ArrayList<String> hyponyms;
private ArrayList<String> meronyms;
public Details(String word, String type, String meaning, String w_num, String sense_num, String tag_count)
{
this.word = word;
this.type = type;
this.meaning = meaning;
this.w_num = w_num;
this.sense_num = sense_num;
this.tag_count = tag_count;
hyponyms = new ArrayList<String>();
meronyms = new ArrayList<String>();
}
}
The dictionary class reads a file and creates Details objects. I have a method which allows me to enter a word into the dictionary HashMap which gives an id. I can put this into the synset HashMap to retrieve it's detail object. This can is passed to the Details class where a toString() method prints the details. A detail object has two array lists, hyponyms and meronyms (related words) which give an id.
What I want to do is pass the hyponym and meronym id's back to the synset HashMap in the dictionary class and retrieve the details. It is possible by using a pointer to the synset hashmap in the Detail constructer but I don't think the Detail class should be able to access the HashMaps at this level. I want a pointer to the dictionary class itself so I can access the HashMaps using defined accessor methods. Can anyone suggest how to do this?
public class Dictionary
{
private HashMap<String, ArrayList<String>> dictionary;
private HashMap<String, ArrayList<Details>> synset;
public Dictionary()
{
dictionary = new HashMap<String, ArrayList<String>>();
synset = new HashMap<String, ArrayList<Details>>();
}
//some methods
}
and a class Details
public class Details
{
private String word;
private String type;
private String meaning;
private String w_num;
private String sense_num;
private String tag_count;
private ArrayList<String> hyponyms;
private ArrayList<String> meronyms;
public Details(String word, String type, String meaning, String w_num, String sense_num, String tag_count)
{
this.word = word;
this.type = type;
this.meaning = meaning;
this.w_num = w_num;
this.sense_num = sense_num;
this.tag_count = tag_count;
hyponyms = new ArrayList<String>();
meronyms = new ArrayList<String>();
}
}
The dictionary class reads a file and creates Details objects. I have a method which allows me to enter a word into the dictionary HashMap which gives an id. I can put this into the synset HashMap to retrieve it's detail object. This can is passed to the Details class where a toString() method prints the details. A detail object has two array lists, hyponyms and meronyms (related words) which give an id.
What I want to do is pass the hyponym and meronym id's back to the synset HashMap in the dictionary class and retrieve the details. It is possible by using a pointer to the synset hashmap in the Detail constructer but I don't think the Detail class should be able to access the HashMaps at this level. I want a pointer to the dictionary class itself so I can access the HashMaps using defined accessor methods. Can anyone suggest how to do this?