private Map<String, String> loadInteger2OutcomeMapping(File tcModelLocation) throws IOException { if (isRegression()) { return new HashMap<>(); } Map<String, String> map = new HashMap<>(); List<String> readLines = FileUtils.readLines( new File(tcModelLocation, AdapterFormat.getOutcomeMappingFilename()), "utf-8"); for (String l : readLines) { String[] split = l.split("\t"); map.put(split[1], split[0]); } return map; }
protected Map<String, String> loadInteger2OutcomeMapping(File tcModelLocation) throws IOException { if (isRegression()) { return new HashMap<>(); } Map<String, String> map = new HashMap<>(); List<String> readLines = FileUtils.readLines( new File(tcModelLocation, AdapterFormat.getOutcomeMappingFilename()), UTF_8); for (String l : readLines) { String[] split = l.split("\t"); map.put(split[1], split[0]); } return map; }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { try { File tempFile = createInputFile(aJCas); File prediction = runPrediction(tempFile); List<TextClassificationOutcome> outcomes = getOutcomeAnnotations(aJCas); List<String> writtenPredictions = FileUtils.readLines(prediction, UTF_8); checkErrorConditionNumberOfOutcomesEqualsNumberOfPredictions(outcomes, writtenPredictions); for (int i = 0; i < outcomes.size(); i++) { if (isRegression()) { String val = writtenPredictions.get(i); outcomes.get(i).setOutcome(val); } else { String val = writtenPredictions.get(i).replaceAll("\\.0", ""); String pred = integer2OutcomeMapping.get(val); outcomes.get(i).setOutcome(pred); } } } catch (Exception e) { throw new AnalysisEngineProcessException(e); } }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { try { File tempFile = createInputFile(jcas); File prediction = runPrediction(tempFile); List<TextClassificationOutcome> outcomes = getOutcomeAnnotations(jcas); List<String> writtenPredictions = FileUtils.readLines(prediction, "utf-8"); checkErrorConditionNumberOfOutcomesEqualsNumberOfPredictions(outcomes, writtenPredictions); for (int i = 0; i < outcomes.size(); i++) { if (isRegression()) { String val = writtenPredictions.get(i); outcomes.get(i).setOutcome(val); } else { String val = writtenPredictions.get(i).replaceAll("\\.0", ""); String pred = integer2OutcomeMapping.get(val); outcomes.get(i).setOutcome(pred); } } } catch (Exception e) { throw new AnalysisEngineProcessException(e); } }