/** * Append a list of strings to a file, one per line */ public static void append(String fileName, Iterable<String> list) throws IOException { append(fileName, list, new StringTransformer<String>()); }
public static void logwrite(String msg, HttpSession hs){ SessionData sd = new SessionData(hs); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String time = dateFormat.format(date); msg = time + "\t" + msg; try { LineIO.append(sd.logfile, msg); } catch (IOException e) { logger.error("Cannot log to: " + sd.logfile); e.printStackTrace(); } }
/** * Append a string to a file */ public static void append(String fileName, String line) throws IOException { append(fileName, line, new StringTransformer<String>()); } }
/** * Append a list of strings to a file, one per line */ public static void append(String fileName, Iterable<String> list) throws IOException { append(fileName, list, new StringTransformer<String>()); }
/** * Append a string to a file */ public static void append(String fileName, String line) throws IOException { append(fileName, line, new StringTransformer<String>()); } }
public TextAnnotation getProcessed(TextAnnotation ta) { int key = ta.hashCode(); //TODO Check that the returned TextAnnotation contains all the views needed if (!taMap.containsKey(key) && !failed.contains(key)) { try { getPreprocessor().annotate(ta); } catch (AnnotatorException | RuntimeException e) { logger.error("Unable to preprocess TextAnnotation {}. Skipping", ta.getId()); failed.add(key); try { LineIO.append(failedFile, Integer.toString(key)); } catch (IOException e1) { logger.error("Unable to add TextAnnotation {} to the failed file", ta.getId()); } return null; } try { LineIO.append(directory + "/ta." + key + ".json", SerializationHelper.serializeToJson(ta)); } catch (IOException e) { logger.error("Unable to store processed TextAnnotation {}", ta.getId()); } taMap.put(key, ta); } return taMap.get(key); }
String line = "Example " + processed + "\tprediction:\t" + prediction + "\t gold:\t" + gold; line += "\t" + (gold.equals(prediction) ? "correct" : "incorrect"); LineIO.append(outFile, line); } catch (IOException e) { e.printStackTrace();