stanfordnlp/CoreNLP · error · java.lang.IllegalArgumentException

Arabic does not support feature type: " + feat.toString()

Error message

Arabic does not support feature type: " + feat.toString()

What it means

ArabicMorphoFeatureSpecification.getValues throws this IllegalArgumentException when queried with a MorphoFeatureType the Arabic specification does not implement at all (anything other than DEF, CASE, GEN, NUM, PER, VOICE, MOOD, TENSE). It is the terminal else-branch of the feature dispatch, signaling an unrecognized or not-modeled feature type for Arabic.

Solutions

  1. Restrict feature queries to the types the Arabic spec supports (DEF, GEN, NUM, PER, VOICE, MOOD, TENSE).
  2. Filter the MorphoFeatureType set before calling getValues for Arabic documents.
  3. Ensure you are using the morpho feature specification matching your language/pipeline.
  4. If you control the code, add an explicit supportedFeatures() check instead of relying on the exception.

Example fix

// before
List<String> vals = arabicSpec.getValues(someNewFeatureType);
// after
if (EnumSet.of(DEF, GEN, NUM, PER, VOICE, MOOD, TENSE).contains(someNewFeatureType)) {
  List<String> vals = arabicSpec.getValues(someNewFeatureType);
}
Defensive patterns

Strategy: type-guard

Validate before calling

// java
private static final Set<MorphoFeatureType> ARABIC_SUPPORTED = EnumSet.of(
    MorphoFeatureType.DEF, MorphoFeatureType.GEN, MorphoFeatureType.NUM,
    MorphoFeatureType.PER, MorphoFeatureType.VOICE, MorphoFeatureType.MOOD,
    MorphoFeatureType.TENSE);
boolean ok = ARABIC_SUPPORTED.contains(feat);

Type guard

// java
if (!ARABIC_SUPPORTED.contains(feat)) return Collections.emptyList();
List<String> vals = arabicSpec.getValues(feat);

Try / catch

try {
  vals = arabicSpec.getValues(feat);
} catch (IllegalArgumentException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Arabic does not support feature type")) {
    vals = Collections.emptyList();
  } else throw e;
}

Prevention

When it happens

Trigger: Calling getValues(feat) with a MorphoFeatureType outside the Arabic-supported set — e.g. a feature added in a newer CoreNLP version, or a custom/other-language feature type passed to the Arabic specification.

Common situations: Generic code iterating all enum values across language-specific specifications; mixing specifications so an English-only feature type reaches the Arabic handler; upgrading CoreNLP and getting a new MorphoFeatureType that the Arabic branch predates.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/b52bc666189ea496. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/international/arabic/ArabicMorphoFeatureSpecification.java:71

    else if(feat == MorphoFeatureType.CASE) {
      throw new RuntimeException(this.getClass().getName() + ": Case is presently unsupported!");
//      return Arrays.asList(caseVals);
    } else if(feat == MorphoFeatureType.GEN)
      return Arrays.asList(genVals);
    else if(feat == MorphoFeatureType.NUM)
      return Arrays.asList(numVals);
    else if(feat == MorphoFeatureType.PER)
      return Arrays.asList(perVals);
    else if(feat == MorphoFeatureType.POSS)
      return Arrays.asList(possVals);
    else if(feat == MorphoFeatureType.VOICE)
      return Arrays.asList(voiceVals);
    else if(feat == MorphoFeatureType.MOOD)
      return Arrays.asList(moodVals);
    else if(feat == MorphoFeatureType.TENSE)
      return Arrays.asList(tenseVals);
    else
      throw new IllegalArgumentException("Arabic does not support feature type: " + feat.toString());
  }

  /**
   * Hand-written rules to convert SAMA analyses to feature structures.
   */
  @Override
  public MorphoFeatures strToFeatures(String spec) {
    MorphoFeatures features = new ArabicMorphoFeatures();

    // Check for the boundary symbol
    if(spec == null || spec.equals("")) {
      return features;
    }
    //Possessiveness
    if(isActive(MorphoFeatureType.POSS) && spec.contains("POSS")) {
      features.addFeature(MorphoFeatureType.POSS,possVals[0]);
    }

View on GitHub (pinned to 1b7edd19c4)