package smieci; import java.io.File; import java.io.PrintWriter; import java.util.HashMap; import java.util.StringTokenizer; public class MGVAnnotationBuilder { public static void main (String[] args) throws Exception { File Index = new File("C:\\NEKST\\MGV\\mgv-bow\\files-annot\\annotation.list"); File Folder = new File("C:\\NEKST\\MGV\\mgv-bow\\png"); PrintWriter IndexOut = new PrintWriter(Index); PrintWriter FileOut; int N = 0; HashMap WordIndex = new HashMap(); for (File CurrentFile : Folder.listFiles()) { if (CurrentFile.getName().endsWith(".png")) { FileOut = new PrintWriter("C:\\NEKST\\MGV\\mgv-bow\\files-annot\\" + CurrentFile.getName() + ".annot"); System.out.println("Currently processing: " + CurrentFile.getName()); StringTokenizer Tokens = new StringTokenizer(CurrentFile.getName(), "_"); String CurrentToken = Tokens.nextToken(); while (Tokens.hasMoreTokens()) { System.out.print(CurrentToken + " -> "); if (!WordIndex.containsKey(CurrentToken)) { WordIndex.put(CurrentToken, N); IndexOut.println(N + ";" + CurrentToken); FileOut.print(N + " "); System.out.println(N + " (Newly added!)"); N++; } else { System.out.println(WordIndex.get(CurrentToken)); FileOut.print(WordIndex.get(CurrentToken) + " "); } CurrentToken = Tokens.nextToken(); } System.out.println(); FileOut.close(); } } IndexOut.close(); } }