private List<String> extractRoles(String t) throws IOException { /// logger.debug("\n" + t); List<String> list = new ArrayList<String>(); LineNumberReader lr = new LineNumberReader(new StringReader(t)); String line = null; String role = null; String annotation = null; while ((line = lr.readLine()) != null) { String[] s = line.split("\t"); if (s[6].toLowerCase().startsWith("b-")) { logger.debug("a\t\t" + role); if (role != null && annotation != null) { list.add(role + "\t" + annotation); logger.warn("adding " + role + "\t" + annotation); } role = new String(s[2]); annotation = s[5] + "\t" + s[6]; } else if (s[6].toLowerCase().startsWith("i-")) { if (role != null) { role += " " + s[2]; } } } if (role != null && annotation != null) { list.add(role + "\t" + annotation); logger.warn("adding " + role + "\t" + annotation); } return list; }
private List<String[]> extractExamples(String t) throws IOException { // logger.debug("\n" + t); List<String[]> list = new ArrayList<String[]>(); LineNumberReader lr = new LineNumberReader(new StringReader(t)); String line = null; String role = null; String annotation = null; while ((line = lr.readLine()) != null) { String[] s = line.split("\t"); list.add(s); } return list; }
private Map<String, String[]> readRoles(File f) throws IOException { Map<String, String[]> map = new TreeMap<String, String[]>(); LineNumberReader lr = new LineNumberReader(new InputStreamReader(new FileInputStream(f), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = lr.readLine()) != null) { String[] s = line.toLowerCase().split("\t"); if (s.length > 2) { logger.trace(Arrays.toString(s)); map.put(s[1], s); } } return map; }
private Map<Integer, String> readTraining(File f) throws IOException { Map<Integer, String> map = new TreeMap<Integer, String>(); LineNumberReader lr = new LineNumberReader(new InputStreamReader(new FileInputStream(f), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); int id = -1; while ((line = lr.readLine()) != null) { String[] s = line.split("\t"); if (s.length > 0 && s[0].length() > 0 && !s[0].equals("sid")) { sb.append(line + "\n"); id = Integer.parseInt(s[0]); } else { if (sb.length() > 0) { map.put(id, sb.toString()); } sb = new StringBuilder(); } } map.put(id, sb.toString()); return map; }