public static DepContextCounts importFromReader(BufferedReader in) throws IOException { Helper.report("[ContextCounts] Importing context word counts..."); DepContextCounts dmc = new DepContextCounts(); String line; while ((line = in.readLine()) != null) { if (line.startsWith("<contextcounts")) { Matcher matcher = contextCountsPattern.matcher(line); if (matcher.find()) { // ignore first entry: corpus name Corpus.setName(matcher.group(1)); } } else if (line.startsWith("<deprelation")) { Matcher matcher = depRelationPattern.matcher(line); if (matcher.find()) { // ignore first entry: corpus name String depRelationString = matcher.group(1); importDepRelationCounts(in, dmc, depRelationString); } } else if (line.equals("</contextcounts>")) { break; } } Helper.report("[ContextCounts] ...Finished importing context word counts."); return dmc; }