String[] parts = line.split("\\s");
if (parts.length == 2) {
int wid = Integer.parseInt(parts[0]);
String word = parts[1];
if (wid != expectedWid) {
throw new ModelParseException("Word ordering error");
}
vocabulary.putWord(word);
++expectedWid;
} else if (parts.length != 0) {
throw new ModelParseException("Bad number of " +
"line parts.");
}
}
return vocabulary;
} catch (NumberFormatException e) {
throw new ModelParseException("Part format error", e);
} catch (IOException e) {
throw new ModelParseException("IO error", e);
}
}