{"record":{"id":"b81621063d466d18","repo":"stanfordnlp/CoreNLP","slug":"transform-on-actions-not-yet-implemented","errorCode":null,"errorMessage":"transform on actions not yet implemented","messagePattern":"transform on actions not yet implemented","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/SequencePattern.java","lineNumber":142,"sourceCode":"\n    nodeSequencePattern = new GroupPatternExpr(nodeSequencePattern, true);\n    nodeSequencePattern = nodeSequencePattern.optimize();\n    this.totalGroups = nodeSequencePattern.assignGroupIds(0);\n    Frag f = nodeSequencePattern.build();\n    f.connect(MATCH_STATE);\n    this.root = f.start;\n    varGroupBindings = new VarGroupBindings(totalGroups+1);\n    nodeSequencePattern.updateBindings(varGroupBindings);\n  }\n\n  @Override\n  public String toString() {\n    return this.pattern();\n  }\n\n  public <T2> SequencePattern<T2> transform(NodePatternTransformer<T,T2> transformer) {\n    if (action != null) {\n      throw new UnsupportedOperationException(\"transform on actions not yet implemented\");\n    }\n    SequencePattern.PatternExpr transformedPattern = this.patternExpr.transform(transformer);\n    // TODO: Make string unique by indicating this pattern was transformed\n    return new SequencePattern<>(this.patternStr, transformedPattern, null);\n  }\n\n  public String pattern() {\n    return patternStr;\n  }\n\n  protected PatternExpr getPatternExpr() {\n    return patternExpr;\n  }\n\n  public double getPriority() {\n    return priority;\n  }\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/SequencePattern.java#L124-L160","documentation":"SequencePattern.transform() applies a NodePatternTransformer to the pattern's expression tree, but if the pattern carries an action (SequenceMatchAction) the transformation would lose or mis-handle it, so it throws UnsupportedOperationException ('transform on actions not yet implemented'). It is a declared feature gap, not a misuse error.","triggerScenarios":"Calling pattern.transform(transformer) on a SequencePattern that was compiled with an action (e.g. a pattern string with ' :: ' action syntax, so pattern.getAction() != null).","commonSituations":"Programmatic pattern rewriting of TokensRegex patterns that include side-effect actions like tagging or annotation, common when normalizing or porting rule files.","solutions":["Strip or split off the action before transforming; transform only the pattern part and re-attach the action afterward","Rebuild the pattern from a transformed pattern string that omits the action","Implement the missing transform support by extending the transformer to carry actions","Avoid transform() and recompile an equivalent pattern string instead"],"exampleFix":"// before\nSequencePattern<CoreMap> t = patternWithAction.transform(transformer); // throws\n// after\nSequencePattern<CoreMap> t = new SequencePattern<>(patternStr,\n    patternWithAction.getPatternExpr().transform(transformer),\n    patternWithAction.getAction()); // keep action manually","handlingStrategy":"try-catch","validationCode":"if (pattern.getAction() != null) {\n  throw new IllegalArgumentException(\"Cannot transform a pattern that has an action attached\");\n}","typeGuard":"boolean isTransformable(SequencePattern<?> p) {\n  return p.getAction() == null;\n}","tryCatchPattern":"try {\n  SequencePattern<T2> t = pattern.transform(transformer);\n} catch (UnsupportedOperationException e) {\n  // pattern has an action; handle pattern without transform\n}","preventionTips":["Check getAction() != null before calling transform()","Split actions off rule strings before programmatic transformation","Track upstream CoreNLP releases for transform-with-action support"],"tags":["java","unsupported-operation","not-implemented","tokensregex"],"backgroundTag":"method-not-implemented","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"}