(LangDescriptor language)
| 78 | } |
| 79 | |
| 80 | public static List<Float> checkStability(LangDescriptor language) throws Exception { |
| 81 | List<Float> errorRates = new ArrayList<>(); |
| 82 | |
| 83 | // format the corpus into tmp dir |
| 84 | LeaveOneOutValidator validator0 = new LeaveOneOutValidator(language.corpusDir, language); |
| 85 | Triple<List<Formatter>, List<Float>, List<Float>> results0 = validator0.validateDocuments(false, "/tmp/stability/1"); |
| 86 | errorRates.add( BuffUtils.median(results0.c) ); |
| 87 | |
| 88 | List<Formatter> formatters0 = results0.a; |
| 89 | // now try formatting it over and over |
| 90 | for (int i = 1; i<=STAGES; i++) { |
| 91 | String inputDir = "/tmp/stability/"+i; |
| 92 | String outputDir = "/tmp/stability/"+(i+1); |
| 93 | LeaveOneOutValidator validator = new LeaveOneOutValidator(inputDir, language); |
| 94 | Triple<List<Formatter>, List<Float>, List<Float>> results = |
| 95 | validator.validateDocuments(false, outputDir); |
| 96 | List<Formatter> formatters = results.a; |
| 97 | List<Float> distances = new ArrayList<>(); |
| 98 | for (int j = 0; j<formatters.size(); j++) { |
| 99 | Formatter f0 = formatters0.get(j); |
| 100 | Formatter f = formatters.get(j); |
| 101 | float editDistance = normalizedLevenshteinDistance(f.getOutput(), f0.getOutput()); |
| 102 | distances.add(editDistance); |
| 103 | } |
| 104 | errorRates.add( BuffUtils.median(distances) ); |
| 105 | } |
| 106 | |
| 107 | return errorRates; |
| 108 | } |
| 109 | } |
no test coverage detected