stanfordnlp/CoreNLP · error · RuntimeException

Sorry, but dependencies cannot be output as part of the…

Error message

Sorry, but ${options.semanticGraphMode} dependencies cannot be output as part of the TextOutputter

What it means

TextOutputter prints dependency graphs per sentence based on options.semanticGraphMode. The switch handles BASIC, COLLAPSED, CCPROCESSED etc.; any other SemanticGraphMode value hits the default branch and throws a RuntimeException because the requested dependency representation cannot be rendered in text output.

Solutions

  1. Use -outputFormat json or xml, which support richer dependency modes
  2. Set the semanticGraphMode option to BASIC, COLLAPSED, or CCPROCESSED for text output
  3. Remove the dependencies option if you only need token/sentence text output

Example fix

// before
-outputFormat text -"output.options" semanticGraphMode=enhanced
// after
-outputFormat json -"output.options" semanticGraphMode=enhanced
Defensive patterns

Strategy: validation

Validate before calling

if ("text".equals(props.getProperty("outputFormat", "text"))) {
  String mode = props.getProperty("dependencies", props.getProperty("output.options", ""));
  if (mode != null && (mode.contains("enhanced") || mode.contains("SEMANTICGRAPH"))) {
    props.setProperty("outputFormat", "json");
  }
}

Try / catch

try {
  outputText(anno, options);
} catch (RuntimeException e) {
  if (e.getMessage().contains("cannot be output as part of the TextOutputter")) {
    options.semanticGraphMode = SemanticGraphMode.COLLAPSED;
    outputText(anno, options);
  } else throw e;
}

Prevention

When it happens

Trigger: Running CoreNLP with outputFormat=text while the output/dependencies option sets semanticGraphMode to an unhandled enum value (e.g. enhanced++ style modes not mapped in this outputter's switch).

Common situations: Setting -outputFormat text with modern dependency options (enhanced dependencies) that TextOutputter doesn't map; copying options meant for JSON output (which supports more modes) into text output.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/0bf59692ef48d489. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/TextOutputter.java:176

          break;
        case ENHANCED:
          graph = sentence.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class);
          graphName = "enhanced dependencies";
          break;
        case ENHANCED_PLUS_PLUS:
          graph = sentence.get(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation.class);
          graphName = "enhanced plus plus dependencies";
          break;
        case COLLAPSED:
          graph = sentence.get(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation.class);
          graphName = "collapsed dependencies";
          break;
        case CCPROCESSED:
          graph = sentence.get(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation.class);
          graphName = "cc processed dependencies";
          break;
        default:
          throw new RuntimeException("Sorry, but " + options.semanticGraphMode + " dependencies cannot be output as part of the TextOutputter");
        }
        if (graph != null) {
          pw.println();
          pw.println("Dependency Parse (" + graphName + "):");
          pw.print(graph.toList());
        }

        // display the entity mentions
        List<CoreMap> entityMentions = sentence.get(CoreAnnotations.MentionsAnnotation.class);
        if (entityMentions != null) {
          pw.println();
          pw.println("Extracted the following NER entity mentions:");
          for (CoreMap entityMention : entityMentions) {
            String nerConfidenceEntry;
            Map<String,Double> nerConfidences = entityMention.get(CoreAnnotations.NamedEntityTagProbsAnnotation.class);
            String nerConfidenceKey =
                    nerConfidences.keySet().size() > 0 ? (String) nerConfidences.keySet().toArray()[0] : "" ;
            if (!nerConfidenceKey.equals("") && !nerConfidenceKey.equals("O"))

View on GitHub (pinned to 1b7edd19c4)