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;
}
if (tree == null) {
System.out.println("Not SGF file or file read error, skip " + filePath + " at " + offset);
break;
}
Problem entry = new Problem();
entry.path = path;
entry.subPath = subPath;
entry.resource = resource;
entry.offset = offset;
try {
entry.genre = tree.getProperty(SGFPropertyName.GE).getText();
} catch (SGFException e) {
entry.genre = "undefined";
}
int i = genres.indexOf(entry.genre);
if (i < 0)
genres.addElement(entry.genre);
else
entry.genre = (String)genres.elementAt(i);
try {
entry.difficulty = Filter.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.tried = 0;