{"record":{"id":"57261f23aeb16c78","repo":"stanfordnlp/CoreNLP","slug":"cannot-use-custom-feature-factory-with-localfeatur","errorCode":null,"errorMessage":"Cannot use custom feature factory with localFeaturesOnly flag--have your custom feature factory extend ArabicSegmenterFeatureFactory instead of StartAndEndArabicSegmenterFeatureFactory and remove the localFeaturesOnly flag.","messagePattern":"Cannot use custom feature factory with localFeaturesOnly flag--have your custom feature factory extend ArabicSegmenterFeatureFactory instead of StartAndEndArabicSegmenterFeatureFactory and remove the localFeaturesOnly flag\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/arabic/process/ArabicSegmenter.java","lineNumber":132,"sourceCode":"   * Make an Arabic Segmenter.\n   *\n   *  @param props Options for how to tokenize. See the main method of {@link ArabicTokenizer} for details\n   */\n  public ArabicSegmenter(Properties props) {\n    isTokenized = props.containsKey(optTokenized);\n    tokenizerOptions = props.getProperty(optTokenizer, null);\n    tedEvalPrefix = props.getProperty(optTedEval, null);\n    hasDomainLabels = props.containsKey(optWithDomains);\n    domain = props.getProperty(optDomain, \"atb\");\n    noRewrites = props.containsKey(optNoRewrites);\n    tf = getTokenizerFactory();\n\n    prefixMarker = props.getProperty(optPrefix, \"\");\n    suffixMarker = props.getProperty(optSuffix, \"\");\n\n    if (props.containsKey(optLocalFeaturesOnly)) {\n      if (props.containsKey(optFeatureFactory))\n        throw new RuntimeException(\"Cannot use custom feature factory with localFeaturesOnly flag--\" +\n            \"have your custom feature factory extend ArabicSegmenterFeatureFactory instead of \" +\n            \"StartAndEndArabicSegmenterFeatureFactory and remove the localFeaturesOnly flag.\");\n\n      props.setProperty(optFeatureFactory, localOnlyFeatureFactory);\n    }\n    if (!props.containsKey(optFeatureFactory))\n      props.setProperty(optFeatureFactory, defaultFeatureFactory);\n\n    // Remove all command-line properties that are specific to ArabicSegmenter\n    props.remove(optTokenizer);\n    props.remove(optTokenized);\n    props.remove(optPrefix);\n    props.remove(optSuffix);\n    props.remove(optThreads);\n    props.remove(optTedEval);\n    props.remove(optWithDomains);\n    props.remove(optDomain);\n    props.remove(optNoRewrites);","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/arabic/process/ArabicSegmenter.java#L114-L150","documentation":"ArabicSegmenter supports a special StartAndEndArabicSegmenterFeatureFactory only when localFeaturesOnly is set; a custom featureFactory combined with localFeaturesOnly is contradictory and throws this RuntimeException during construction/initialization of the segmenter.","triggerScenarios":"Passing properties containing both optLocalFeaturesOnly (-localFeaturesOnly) and a custom optFeatureFactory (-featureFactory) to the ArabicSegmenter constructor.","commonSituations":"Reusing a serialized ArabicSegmenter training config that had localFeaturesOnly while adding a custom feature factory, or command-line flag accumulation from scripts.","solutions":["Remove the -localFeaturesOnly flag from the properties","Make your custom feature factory extend ArabicSegmenterFeatureFactory (not StartAndEndArabicSegmenterFeatureFactory) and drop localFeaturesOnly","If you need local-features-only behavior with a custom factory, subclass accordingly and supply it via -featureFactory alone"],"exampleFix":"// before\nprops.setProperty(\"localFeaturesOnly\", \"true\");\nprops.setProperty(\"featureFactory\", \"my.custom.Factory\");\n// after\nprops.setProperty(\"featureFactory\", \"my.custom.Factory\"); // localFeaturesOnly removed","handlingStrategy":"validation","validationCode":"Properties p = seg.props;\nif (p.containsKey(\"localFeaturesOnly\") && p.containsKey(\"featureFactory\")) {\n  throw new IllegalArgumentException(\"Remove -localFeaturesOnly when using a custom -featureFactory\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine localFeaturesOnly with featureFactory","Keep feature factory settings in one canonical properties source","Review serialized training configs before reuse"],"tags":["arabic-nlp","segmentation","config-conflict"],"backgroundTag":"conflicting-config-options","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"}