public float getMeasureFromKeysChars(String[] state, List<String> attributes, String measure){
     
     float res = -1;
     
     String keys = "";
     
     for(int i = 0; attributes.size() > i; i++){
         
         if(state[i].equals("#")){
             continue;
         }
         
         keys = keys + attributes.get(i) + "#[";
         String[] indexes = state[i].split(",");
         for(int j = 0; indexes.length > j; j++){            
             keys = keys + indexes[j] + "-" + indexes[j] + ";";
         }
         keys = keys.substring(0, keys.length()-1);
         keys = keys + "],";
     }
     if(keys.length()>0){
         keys = keys.substring(0, keys.length()-1);
     }
     
     //considera os segmentos da chave indicados depois do simbolo '#' Ex: title#[2-8],author#[1-3;5-7]
     buildKeys2(keys.split(","), false);
     
     try{
             
         String query;
         List<Integer> occurrences = null;
         
         if(measure.equals("emptiness")){
             query = "SELECT count(obj_key1)/(SELECT count(*) FROM OBJ_KEYS) FROM OBJ_KEYS where replace(obj_key1,'#','') = ''";
         }
         else{
             //Tem em conta apenas os registos em que o conteudo nao esta vazio
             //query = "SELECT COUNT(obj_key1) FROM " + keysTable + " WHERE obj_key1 != ''GROUP BY obj_key1";
    
             //Tem em conta os registos em que o conteudo esta vazio
             query = "SELECT COUNT(obj_key1) FROM " + keysTable + " GROUP BY obj_key1";
         }
         
         ps = conn.prepareStatement(query);
        
         ResultSet rs = ps.executeQuery();

         occurrences = new ArrayList<Integer>();
         while(rs.next()){
             res = rs.getFloat(1);
             occurrences.add(rs.getInt(1));
         }
         
         Entropy e = new Entropy(this,"");
         if(measure.equals("entropy")){
             res = (float)e.getEntropyKey(occurrences);
         }
         
         if(measure.equals("distinctiveness")){
             res = (float) e.distinctiveness(occurrences);
         }

         rs.close();
         ps.close();
     }
     catch(Exception e){
         e.printStackTrace();
     }
     
     return res;
 }