Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a command line option to print singleton entities. #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/edu/stanford/nlp/pipeline/StanfordCoreNLP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/edu/stanford/nlp/pipeline/XMLOutputter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

Expand Down Expand Up @@ -325,7 +328,7 @@ private static void addRelations(List<RelationMention> 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);
Expand Down