{"record":{"id":"9b9f87b75bbeabac","repo":"stanfordnlp/CoreNLP","slug":"training-is-not-supported","errorCode":null,"errorMessage":"Training is not supported!","messagePattern":"Training is not supported!","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/arabic/process/ArabicSegmenter.java","lineNumber":208,"sourceCode":"      if (tokenizerOptions == null) {\n        tokFactory = ArabicTokenizer.atbFactory();\n        String atbVocOptions = \"removeProMarker,removeMorphMarker,removeLengthening\";\n        tokFactory.setOptions(atbVocOptions);\n      } else {\n        if (tokenizerOptions.contains(\"removeSegMarker\")) {\n          throw new RuntimeException(\"Option 'removeSegMarker' cannot be used with ArabicSegmenter\");\n        }\n        tokFactory = ArabicTokenizer.factory();\n        tokFactory.setOptions(tokenizerOptions);\n      }\n      log.info(\"Loaded ArabicTokenizer with options: \" + tokenizerOptions);\n    }\n    return tokFactory;\n  }\n\n  @Override\n  public void initializeTraining(double numTrees) {\n    throw new UnsupportedOperationException(\"Training is not supported!\");\n  }\n\n  @Override\n  public void train(Collection<Tree> trees) {\n    throw new UnsupportedOperationException(\"Training is not supported!\");\n  }\n\n  @Override\n  public void train(Tree tree) {\n    throw new UnsupportedOperationException(\"Training is not supported!\");\n  }\n\n  @Override\n  public void train(List<TaggedWord> sentence) {\n    throw new UnsupportedOperationException(\"Training is not supported!\");\n  }\n\n  @Override","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/arabic/process/ArabicSegmenter.java#L190-L226","documentation":"ArabicSegmenter is an annotation-based segmenter that cannot be trained as a parser/treebank component. initializeTraining is overridden to always throw UnsupportedOperationException with this message.","triggerScenarios":"Invoking initializeTraining(double numTrees) on an ArabicSegmenter instance, typically through generic training driver code (e.g. a TreebankLanguagePack-driven training loop).","commonSituations":"Plugging ArabicSegmenter into a pipeline that trains all annotators uniformly, or calling the training API out of habit from ArabicParser usage.","solutions":["Do not call initializeTraining on ArabicSegmenter; use testToSegment or load a serialized model instead","Train an external CRF segmenter separately and load it via loadSegmenter/serialization","Branch your pipeline code to skip training for segmentation annotators"],"exampleFix":"// before\nsegmenter.initializeTraining(numTrees);\n// after\nif (!(segmenter instanceof ArabicSegmenter)) segmenter.initializeTraining(numTrees);","handlingStrategy":"try-catch","validationCode":"if (annotator instanceof ArabicSegmenter) {\n  throw new IllegalStateException(\"ArabicSegmenter does not support training\");\n}","typeGuard":"boolean supportsTraining(Annotator a) { return !(a instanceof ArabicSegmenter); }","tryCatchPattern":"try {\n  segmenter.initializeTraining(numTrees);\n} catch (UnsupportedOperationException e) {\n  // load serialized model instead\n  segmenter.loadSegmenter(modelPath, props);\n}","preventionTips":["Treat ArabicSegmenter as inference-only","Branch training pipelines by annotator capability","Distribute pre-trained segmenter models"],"tags":["arabic-nlp","segmentation","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}