while (true) {
int offset = parser.getCharsConsumed();
// parse file to get tree
SGFNode tree = null;
try {
tree = parser.parse();
} catch (SGFEOFException e) {
// DO NOTHING
break;
} catch (SGFParseError e) {
System.out.println("Parse error " + filePath + ":" + e.getMessage());
break;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
break;
}
Problem entry = new Problem();
entry.subPath = subPath;
String gn;
try {
gn = tree.getProperty(SGFPropertyName.GN).getText();
} catch (SGFException e) {
gn = "unknown";
}
System.out.println(gn + ": " + offset);
String genre;
try {
genre = tree.getProperty(SGFPropertyName.GE).getText();
} catch (SGFException e) {
genre = "undefined";
}
int i = genres.indexOf(genre);
if (i < 0) {
i = genres.size();
genres.addElement(genre);
}
entry.genre = i;
try {
entry.difficulty = rank2int(tree.getProperty(SGFPropertyName.DI).getText());
} catch (SGFException e) {
entry.difficulty = 0;
}
try {
entry.difficultyP = tree.getProperty(SGFPropertyName.DP).getInt();
} catch (SGFException e) {
entry.difficultyP = -1;
}
try {
entry.popularity = tree.getProperty(SGFPropertyName.CO).getInt();
} catch (SGFException e) {
entry.popularity = -1;
}
entry.offset = offset;