private HashMap <Integer, String> ID_TAGS;
private HashMap <String, Integer> TAGS_ID;
private HashMap <String, String> TAGS_TRANSLATIONS;
private final ArrayList <Integer> INCLUSIONLIST;
private final ArrayList <Integer> EXCLUSIONLIST;
public DuplicationFinder(HashMap <Integer, String> id_tags, HashMap <String, String> tags_translations, ArrayList <Integer> exclusionList, ArrayList <Integer> inclusionList) {
this.ID_TAGS = id_tags;
this.TAGS_TRANSLATIONS = tags_translations;
this.INCLUSIONLIST = inclusionList;
this.EXCLUSIONLIST = exclusionList;
TAGS_ID = new HashMap <>();
for(Entry <Integer, String> e : ID_TAGS.entrySet()){
TAGS_ID.put(e.getValue(), e.getKey());
}
}
/**
* Findet die Duplikate und gibt die ID's zurück.
* @return
*/
public Set <Integer> findDuplicates(){
Set <Integer> duplicates = new LinkedHashSet <>();
for(Entry <Integer, String> e : ID_TAGS.entrySet()) {
HashMap <String, String> cloneWithoutTag= new HashMap <>(TAGS_TRANSLATIONS);
int id = e.getKey();
String tag = e.getValue();
cloneWithoutTag.remove(tag);
if(cloneWithoutTag.containsValue(TAGS_TRANSLATIONS.get(tag))) {
duplicates.add(id);
}
}
duplicates.addAll(EXCLUSIONLIST);
duplicates.removeAll(INCLUSIONLIST);
Iterator<Integer> nextD = duplicates.iterator();
while(nextD.hasNext()) {
System.out.println(lookUp(ID_TAGS.get(nextD.next())));
}
return duplicates;
}
public String lookUp(String tag) {
return TAGS_TRANSLATIONS.get(tag);
}
public int getID(String tag) {
return TAGS_ID.get(tag);
}
的价值,我不知道是否有人能帮助我与。我会尝试在TAGS_TRANSLATIONS-HashMap中找到一些具有相同值的Keys。我的想法是,当所选的键不是整数的映射克隆,你可以看看是否仍然存在相同的值。它工作到目前为止,但我有一个问题,像“会议”一些值只有一次在那里,也得到了输出。现在我会尝试找到错误。预先感谢帮助:)
你的代码实际上做了什么?你已经将这件事抛弃在我们身上,然后让我们修复它。 –
是的,这是我试图解释,我有HashMap与和这些标签是指一个标签,我在另一个HasMap <标签,翻译>实施。现在生病尝试在翻译中找到重复项,并且我想将该ID添加到重复项集中。但我有大约10重复,它不是没有重复 –
我试图在下面的答案,因为你的上面的评论使问题足够清楚,知道你想问什么。为了将来的参考,请提出更清晰的问题。 –