diff --git a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java b/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java index 795eca09c0..5930271ff5 100644 --- a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java +++ b/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java @@ -217,6 +217,10 @@ public String getEncoding() { return properties.getProperty("encoding", "UTF-8"); } + public boolean getPrintSingletons() { + return PropertiesUtils.getBool(properties, "printable.printSingletonEntities", false); + } + public static boolean isXMLOutputPresent() { try { Class clazz = Class.forName("edu.stanford.nlp.pipeline.XMLOutputter"); diff --git a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.properties b/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.properties index 82d027c746..0e921d2993 100644 --- a/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.properties +++ b/src/edu/stanford/nlp/pipeline/StanfordCoreNLP.properties @@ -56,6 +56,7 @@ annotators = tokenize, ssplit, pos, lemma, ner, parse, dcoref #dcoref.female = /scr/nlp/data/Bergsma-Gender/female.unigrams.txt #dcoref.plural = /scr/nlp/data/Bergsma-Gender/plural.unigrams.txt #dcoref.singular = /scr/nlp/data/Bergsma-Gender/singular.unigrams.txt +#printable.printSingletonEntities = false # This is the regular expression that describes which xml tags to keep # the text from. In order to on off the xml removal, add cleanxml diff --git a/src/edu/stanford/nlp/pipeline/XMLOutputter.java b/src/edu/stanford/nlp/pipeline/XMLOutputter.java index 179dcb83f0..1c0b9ba5e4 100644 --- a/src/edu/stanford/nlp/pipeline/XMLOutputter.java +++ b/src/edu/stanford/nlp/pipeline/XMLOutputter.java @@ -51,6 +51,8 @@ public static class Options { public String encoding = "UTF-8"; /** How to print a constituent tree */ public TreePrint constituentTreePrinter = DEFAULT_CONSTITUENT_TREE_PRINTER; + /** Print only non-singleton entities*/ + public boolean printSingletons = false; } /** @@ -61,6 +63,7 @@ public static Options getOptions(StanfordCoreNLP pipeline) { options.relationsBeam = pipeline.getBeamPrintingOption(); options.constituentTreePrinter = pipeline.getConstituentTreePrinter(); options.encoding = pipeline.getEncoding(); + options.printSingletons = pipeline.getPrintSingletons(); return options; } @@ -325,7 +328,7 @@ private static void addRelations(List relations, Element top, S { boolean foundCoref = false; for (CorefChain chain : corefChains.values()) { - if (chain.getMentionsInTextualOrder().size() <= 1) + if (!options.printSingletons && chain.getMentionsInTextualOrder().size() <= 1) continue; foundCoref = true; Element chainElem = new Element("coreference", curNS);