0

Apparently ArrayList.getValue().size() is not the right answer.

I've looked around, not an easy question to pose to Google.

I've explained pretty comprehensively what I'm trying to do in the pseudocode comments, maybe someone knows how to iterate over that array list?

public static void perceptron_data_struc_generateur(Set<String> GLOBO_DICT, 
 Map<File, ArrayList<String> > fileDict,
 Map<File, int[] > perceptron_input)
{
 //create a new entry in the array list 'perceptron_input'
 //with the key as the file name from fileDict
 //create a new array which is the length of GLOBO_DICT
 //iterate through the indicies of GLOBO_DICT
 //for all words in globo dict, if that word appears in fileDict,
 //increment the perceptron_input index that corresponds to that
 //word in GLOBO_DICT by the number of times that word appears in fileDict
 for (Map.Entry entry : fileDict.entrySet()) 
 {
 //System.out.println(entry.getKey());
 int[] cross_czech = new int[GLOBO_DICT.size()];
 for (String s : GLOBO_DICT)
 {
 for(int i = 0; i < entry.getValue() ).size(); i++)
 {
 }
 }
 }
}

Ultimately the goal is to achieve the first answer to this question, in case you're interested.

asked Feb 17, 2015 at 7:23

1 Answer 1

2

Iterating over the ArrayList values of your map :

for (Map.Entry<File, ArrayList<String>> entry : fileDict.entrySet()) 
{
 int[] cross_czech = new int[GLOBO_DICT.size()];
 for (String s : GLOBO_DICT)
 {
 for(String st : entry.getValue()) // iterates over all the Strings
 // of the ArrayList of the 
 // current entry
 {
 }
 }
}
answered Feb 17, 2015 at 7:28
5
  • 1
    do you know how I could structure the internal component so replicate the data structure described in the linked question, i.e. this one Commented Feb 17, 2015 at 7:34
  • how could I grab the index of GLOBO_DICT in place of 's'? Commented Feb 17, 2015 at 7:42
  • @flavius_valens What do you mean by index of GLOBO_DICT? GLOBO_DICT is a Set, so the elements don't have indices. Commented Feb 17, 2015 at 7:46
  • i just tried with this wierd method, but... didn't work, i edited the answer to show you how I did it. is that a faux pas by the way? Commented Feb 17, 2015 at 7:49
  • maybe convert the set to a list? Commented Feb 17, 2015 at 7:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.