{"record":{"id":"d75fd64050252858","repo":"stanfordnlp/CoreNLP","slug":"invalid-contraction-provided-to-processcontraction","errorCode":null,"errorMessage":"Invalid contraction provided to processContraction","messagePattern":"Invalid contraction provided to processContraction","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/french/process/FrenchTokenizer.java","lineNumber":195,"sourceCode":"        first = \"à\";\n        second = \"le\";\n        secondOffset = 1;\n        secondLength = 1;\n        break;\n      case \"aux\":\n        first = \"à\";\n        second = \"les\";\n        secondOffset = 1;\n        secondLength = 2;\n        break;\n      case \"du\":\n        first = \"de\";\n        second = \"le\";\n        secondOffset = 1;\n        secondLength = 1;\n        break;\n      default:\n        throw new IllegalArgumentException(\"Invalid contraction provided to processContraction\");\n    }\n\n    int secondStart = cl.beginPosition() + secondOffset;\n    int secondEnd = secondStart + secondLength;\n    compoundBuffer.add(copyCoreLabel(cl, second, secondStart, secondEnd));\n    return copyCoreLabel(cl, first, cl.beginPosition(), secondStart);\n  }\n\n\n  /**\n   * A factory for French tokenizer instances.\n   *\n   * @author Spence Green\n   */\n  public static class FrenchTokenizerFactory<T extends HasWord> implements TokenizerFactory<T>, Serializable  {\n\n    private static final long serialVersionUID = 946818805507187330L;\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/french/process/FrenchTokenizer.java#L177-L213","documentation":"FrenchTokenizer splits known French contractions (e.g. 'au', 'du', 'aux') into two tokens; processContraction uses a switch over the contracted word. If the token passed in is not one of the handled contractions, the default branch throws this IllegalArgumentException.","triggerScenarios":"getNext() calls processContraction with a CoreLabel whose word is not in the supported set of French contractions, typically due to a code change adding a new contraction to a matcher without a corresponding case.","commonSituations":"Extending the tokenizer to handle additional contractions (e.g. 'poui' or regional forms) but forgetting to add the split in processContraction; version drift between the contraction regex and the switch.","solutions":["Add a case for the missing contraction in processContraction's switch with its first/second split and offsets","Update the contraction-matching regex so only contractions handled by the switch reach processContraction","Check FrenchTokenizer source for the complete list of supported contractions"],"exampleFix":"// before\ndefault:\n  throw new IllegalArgumentException(\"Invalid contraction provided to processContraction\");\n// after\ncase \"poui\":\n  first = \"pou\"; second = \"hi\"; secondOffset = 3; secondLength = 2;\n  break;\ndefault:\n  throw new IllegalArgumentException(\"Invalid contraction provided to processContraction: \" + cl.word());","handlingStrategy":"try-catch","validationCode":"private static final java.util.Set<String> SUPPORTED = java.util.Set.of(\"au\",\"aux\",\"du\",\"ou\",\"son\");\nif (!SUPPORTED.contains(word)) return java.util.Collections.singletonList(cl);","typeGuard":null,"tryCatchPattern":"try { tokens.addAll(processContraction(cl)); } catch (IllegalArgumentException e) { log.warn(\"Unhandled contraction: \" + cl.word()); tokens.add(cl); }","preventionTips":["Keep the contraction regex and processContraction switch in sync","Add a unit test per supported contraction","Fail with the offending word included in the message when editing the switch"],"tags":["tokenizer","contraction","illegal-argument"],"backgroundTag":"internal-invariant-violation","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"}