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
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
-
1do you know how I could structure the internal component so replicate the data structure described in the linked question, i.e. this onesmatthewenglish– smatthewenglish2015年02月17日 07:34:31 +00:00Commented Feb 17, 2015 at 7:34
-
how could I grab the index of GLOBO_DICT in place of 's'?smatthewenglish– smatthewenglish2015年02月17日 07:42:30 +00:00Commented 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.Eran– Eran2015年02月17日 07:46:52 +00:00Commented 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?smatthewenglish– smatthewenglish2015年02月17日 07:49:19 +00:00Commented Feb 17, 2015 at 7:49
-
maybe convert the set to a list?smatthewenglish– smatthewenglish2015年02月17日 07:53:40 +00:00Commented Feb 17, 2015 at 7:53
lang-java