{"record":{"id":"d3e6706da27921f3","repo":"stanfordnlp/CoreNLP","slug":"relative-word-pattern-not-defined-for","errorCode":null,"errorMessage":"Relative word pattern not defined for ","messagePattern":"Relative word pattern not defined for ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/ud/ProcessUniversalEnhancerRequest.java","lineNumber":84,"sourceCode":"\n  /**\n   * Figure out a relative patterns pronoun to use based on the information given in the request\n   */\n  public static Pattern getRelativePronouns(CoreNLPProtos.DependencyEnhancerRequest request) {\n    if (request.hasRelativePronouns()) {\n      return Pattern.compile(request.getRelativePronouns());\n    }\n    if (request.hasLanguage()) {\n      switch(request.getLanguage()) {\n      case English:\n      case UniversalEnglish:\n        return EnglishPatterns.RELATIVIZING_WORD_PATTERN;\n      case Chinese:\n      case UniversalChinese:\n        // there are no relative pronouns in Chinese!\n        return null;\n      default:\n        throw new IllegalArgumentException(\"Relative word pattern not defined for \" + request.getLanguage());\n      }\n    }\n    throw new IllegalArgumentException(\"Could not find Language or predefined relative pronouns pattern in the request\");\n  }\n\n  /**\n   * Process a single request, adding enhanced dependencies to each sentence in the document\n   */\n  @Override\n  public void processInputStream(InputStream in, OutputStream out) throws IOException {\n    CoreNLPProtos.DependencyEnhancerRequest request = CoreNLPProtos.DependencyEnhancerRequest.parseFrom(in);\n\n    Pattern relativePronounsPattern = getRelativePronouns(request);\n\n    CoreNLPProtos.Document response = processRequest(relativePronounsPattern, request);\n    response.writeTo(out);\n  }\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/ud/ProcessUniversalEnhancerRequest.java#L66-L102","documentation":"ProcessUniversalEnhancerRequest.getRelativePronouns maps a request language to a relative-pronoun regex pattern; for languages with no defined mapping (any case other than English/Arabic/etc. and the Chinese variants that return null deliberately) it throws IllegalArgumentException(\"Relative word pattern not defined for <language>\").","triggerScenarios":"Calling relativePronounsPattern/getRelativePronouns with a request whose language enum/setting is a language the enhancer has no RELATIVIZING_WORD_PATTERN for.","commonSituations":"Configuring the UD enhancer for an unsupported language; a new Language enum value added by an upgrade without a pattern entry; passing default/unset language to the enhancer request.","solutions":["Use a supported language (e.g. English) in the ProcessUniversalEnhancerRequest","Add a RELATIVIZING_WORD_PATTERN case for the language before using it with the enhancer","Check Language enum vs. request configuration consistency after a library upgrade","Pre-validate the language and skip enhancement for unsupported languages"],"exampleFix":"// before\nrequest.setLanguage(Language.Germanic); // no pattern defined\nenhancer.process(request);\n// after\nif (request.getLanguage() == Language.English) {\n  enhancer.process(request);\n}","handlingStrategy":"validation","validationCode":"Set<Language> supported = Set.of(Language.English, Language.Arabic, Language.UniversalEnglish);\nif (!supported.contains(request.getLanguage())) {\n  throw new IllegalArgumentException(\"No relative pronoun pattern for \" + request.getLanguage());\n}","typeGuard":null,"tryCatchPattern":"try { enhancer.process(request); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Relative word pattern not defined\")) { skipEnhancement(request); } else throw e; }","preventionTips":["Only enable the universal enhancer for languages with defined patterns","Re-check language support after CoreNLP upgrades adding new Language values","Provide explicit patterns in the request for languages lacking defaults"],"tags":["ud-enhancer","unsupported-language","illegal-argument"],"backgroundTag":"unsupported-enum-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}