extract keys and values from hashmap and insert into more malleable structures

ぃ、小莉子 提交于 2019-12-12 01:28:15

问题


As input I have a hashmap which stores as a key an int array of the form [0,1,0,0,0,1,1,0,0,6,0,1] and as a key a String label, i.e. science. What I want to do is extract the array and deposit it into a 2D array. The I want to compare the label to another string and if it is a match save a 1 to outputs else save a zero. I thought the code below would do that trick, but it seems not. Where have I gone wrong?

   double[][] feature_matrix = new double[ number_of_files ][ globo_dict_size ];
   int[] outputs = new int [ number_of_files ];

   //likely not the best way to do this
   for(int z = 0; z < number_of_files; z++)
   {

       for( Map.Entry< int[] , String > entry : train_freq_count_against_globo_dict.entrySet() ) 
       {
           int[] container_of_feature_vector = entry.getKey();

           for (int q = 0; q < globo_dict_size; q++) 
           {
               feature_matrix[z][q] = container_of_feature_vector[q];
           }
           outputs[z] =  String.valueOf( entry.getValue() ).equals(LABEL) ? 1 : 0;
       }
   }

来源:https://stackoverflow.com/questions/28742832/extract-keys-and-values-from-hashmap-and-insert-into-more-malleable-structures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!