public static void reconstruct( String input, String output, boolean isDirectory, boolean excludeCommon) { List<DEPTree> trees; PrintWriter writer; Pair<List<AbstractMention>, CoreferantSet> resolution; /* Coref Configuration */ SieveSystemCongiuration config = new SieveSystemCongiuration(TLanguage.ENGLISH); config.loadMentionDetectors(true, true, true); config.loadDefaultSieves(true, true, true, true, true, true, true, true); AbstractCoreferenceResolution coref = new SieveSystemCoreferenceResolution(config); /* ************* */ if (isDirectory) { List<String> l_filePaths = FileUtils.getFileList(input, ".cnlp", true); for (String filePath : l_filePaths) { trees = CoreferenceTestUtil.getTestDocuments(filePath, 9); resolution = coref.getEntities(trees); writer = new PrintWriter( IOUtils.createBufferedPrintStream( output + FileUtils.getBaseName(filePath) + ".reconstructed")); writer.println(reconstruct(trees, resolution.o1, resolution.o2, excludeCommon)); writer.close(); } } else { trees = CoreferenceTestUtil.getTestDocuments(input, 9); resolution = coref.getEntities(trees); writer = new PrintWriter(IOUtils.createBufferedPrintStream(output + ".reconstructed")); writer.println(reconstruct(trees, resolution.o1, resolution.o2, excludeCommon)); writer.close(); } }
public static void reconstruct( List<DEPTree> trees, List<AbstractMention> mentions, CoreferantSet links, String output, boolean excludeCommon) { PrintWriter writer = new PrintWriter(IOUtils.createBufferedPrintStream(output + ".reconstructed")); writer.println(reconstruct(trees, mentions, links, excludeCommon)); writer.close(); }