のHashMap <ハッシュマップ
---
---言葉がこれを行うためには
を通過した各ファイルを見つける---ファイル
内の各単語の位置のインデックスを見つけます。
HashMap<String, HashMap<Integer, ArrayList<Integer>>>
上記のような構造を使用します。
String word;
String pattern = "[[^\\w\\süÜıİöÖşŞğĞçÇ]\\d]+";
while ((word = infile.readLine()) != null) {
String[] wordList = word.replaceAll(pattern, " ").split("\\s+");
for (int j = 0; j < wordList.length; j++) {
if(!wordList[j].isEmpty()){
if(!refinedDict.containsKey(wordList[j])){
refinedDict.put(wordList[j], 1);
}
else{
refinedDict.put(wordList[j], refinedDict.get(wordList[j])+1);
}
}//end of for
}//end if
else{
//do something
}
}//end for
}//end while
Set<String> keys=refinedDict.keySet();
List<String> list=sortList(keys);
Iterator<String> it=list.iterator();
while(it.hasNext()){
String key=it.next();
outfile.write(key + "\t" + refinedDict.get(key) + "\n");
どのように私はtoto2のソリューションの実装の作品を適用した後にHashMap
EDIT
でのHashMapでのArrayListを使用することができます。しかし、---としてファイルに書き込むためには>何を
語[FILEID {位置}、{FILEID位置} ...]
を行うことができますか?
このような設計では、シリアライズ可能な実装は役に立ちません。
HashMap<String, HashMap<Integer, ArrayList<Integer>>> outer = ...
HashMap<Integer, ArrayList<Integer>> inner = ...
inner.put(1, new ArrayList<Integer>());
outer.put("key1", inner);
あなたがようArrayList
を取得できます:正確に
ArrayList<Integer> arr = outer.get("key1").get(1);
それは動作します!しかし、私は本当にそれをファイルに書き込むことを試み、失敗しました。 – anonym