logger.info("Reading grammar from file " + grammar_file);
boolean start = false;
int order = 0;
Regex blankLine = new Regex("^\\s*$");
Regex ngramsLine = new Regex("^\\\\\\d-grams:\\s*$");
LineReader grammarReader = new LineReader(grammar_file);
try { for (String line : grammarReader) {
line = line.trim();
if (blankLine.matches(line)) {
continue;
}
if (ngramsLine.matches(line)) { // \1-grams:
start = true;
order = Integer.parseInt(line.substring(1, 2));
if (order > ngramOrder) {
break;
}