stanfordnlp/CoreNLP · error · IllegalArgumentException
Could not find Language or predefined relative pronouns…
Error message
Could not find Language or predefined relative pronouns pattern in the request
What it means
The second guard in ProcessUniversalEnhancerRequest.getRelativePronouns: if the request has no Language set (and no predefined relative-pronouns pattern supplied), the method throws IllegalArgumentException("Could not find Language or predefined relative pronouns pattern in the request"). It fires after the language-switch when the request lacks both pieces of information.
Solutions
- Call setLanguage(...) on the request before processing
- Supply a predefined relative-pronouns pattern in the request when language detection is unavailable
- Validate the request (language or pattern present) before invoking the enhancer
- Catch IllegalArgumentException and return a clear request-validation error to the caller
Example fix
// before ProcessUniversalEnhancerRequest request = new ProcessUniversalEnhancerRequest(); enhancer.process(request); // no language // after ProcessUniversalEnhancerRequest request = new ProcessUniversalEnhancerRequest(); request.setLanguage(Language.English); enhancer.process(request);
Defensive patterns
Strategy: validation
Validate before calling
if (request.getLanguage() == null && request.getRelativePronounsPattern() == null) {
throw new IllegalArgumentException("Request must set language or a relative pronouns pattern");
} Try / catch
try { enhancer.process(request); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Could not find Language")) { throw new RequestValidationException("language/pattern missing", e); } throw e; } Prevention
- Always call setLanguage before processing enhancement requests
- Validate request objects centrally before the pipeline
- Check deserialized requests for dropped language fields
When it happens
Trigger: Sending a ProcessUniversalEnhancerRequest with no language field populated and no predefined relative-pronouns pattern, then invoking relativePronounsPattern/getRelativePronouns during enhancement.
Common situations: Building the request programmatically and forgetting setLanguage; deserializing a request where the language field was dropped; calling the enhancer pipeline directly without a fully populated request object.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Relative word pattern not defined for
- Bad process cp1252
- Cannot interpret
- Cannot interpret for
- Cannot open null document path!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/ad19131d2b7008b2.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/ud/ProcessUniversalEnhancerRequest.java:87
*/
public static Pattern getRelativePronouns(CoreNLPProtos.DependencyEnhancerRequest request) {
if (request.hasRelativePronouns()) {
return Pattern.compile(request.getRelativePronouns());
}
if (request.hasLanguage()) {
switch(request.getLanguage()) {
case English:
case UniversalEnglish:
return EnglishPatterns.RELATIVIZING_WORD_PATTERN;
case Chinese:
case UniversalChinese:
// there are no relative pronouns in Chinese!
return null;
default:
throw new IllegalArgumentException("Relative word pattern not defined for " + request.getLanguage());
}
}
throw new IllegalArgumentException("Could not find Language or predefined relative pronouns pattern in the request");
}
/**
* Process a single request, adding enhanced dependencies to each sentence in the document
*/
@Override
public void processInputStream(InputStream in, OutputStream out) throws IOException {
CoreNLPProtos.DependencyEnhancerRequest request = CoreNLPProtos.DependencyEnhancerRequest.parseFrom(in);
Pattern relativePronounsPattern = getRelativePronouns(request);
CoreNLPProtos.Document response = processRequest(relativePronounsPattern, request);
response.writeTo(out);
}
/**
* The inherited main program will either enhance a single document,
* or will listen to stdin and enhance every document that comes inView on GitHub (pinned to 1b7edd19c4)