【发布时间】:2016-06-21 04:59:59
【问题描述】:
死 Stackoverflow,
我通过 Hadoop 编写代码作为分配,以编写从文本文件中读取的值的矩阵表。基本上它必须读取一个字符在某个其他字符之后出现了多少次。
虽然我在 hadoop 中的代码,但我已经有了这些值,并将它们放入哈希图中 > 并将它们传递给一个名为频率表的函数:
public void FrequencieTable(HashMap<Character, HashMap<Character,Integer>> charFrequentie){
String theRowList = "";
String theColumnList = "";
for(Character row : charFrequentie.keySet()){
theRowList += "\n" + row;
for(Character column : charFrequentie.get(row).keySet()) {
theColumnList += column.charValue() + "\t";
theRowList += "\t" + charFrequentie.get(row).get(column);
}
System.out.println("\t" + theColomList + "\n");
System.out.println(theRowList);
}
}
只有这样会给出错误的输出,因为它应该只在一行和一列上显示像“H”这样的每个字符一次,如果那里没有任何数据,它应该显示 0。
基本上它给出了这个输出:
u s a o e m g d t n j t a n g t e m a t e e a o e u s g l j k
g 1 1 2 2
d 1 1
e 1 2 2 1 1
a 2 2 3
n 2 2
o 2 1
虽然它应该是这样的:(没有重复)
u s a o e m g d t n j
g 0 0 0 0 0 0 0 1 1 2 2
d 1 1 0 0 1 0 3 0 0 0 0
有人知道我们应该做什么吗?我们完全一无所知。
已经谢谢你了
【问题讨论】:
-
Dead Stackoverflow- RIP ;)
标签: java matrix hashmap duplicates