{"record":{"id":"b172296668148f6f","repo":"stanfordnlp/CoreNLP","slug":"no-grammaticalstructurefactory-typed-dependencies","errorCode":null,"errorMessage":"No GrammaticalStructureFactory (typed dependencies) available for language/treebank ","messagePattern":"No GrammaticalStructureFactory \\(typed dependencies\\) available for language/treebank ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/AbstractTreebankLanguagePack.java","lineNumber":604,"sourceCode":"   * will be used with this Treebank/Language pair, without tokenizing carriage returns (i.e., treating them as white space).  The implementation in AbstractTreebankLanguagePack\n   * returns a factory for {@link WhitespaceTokenizer}.\n   *\n   * @return A tokenizer\n   */\n  @Override\n  public TokenizerFactory<? extends HasWord> getTokenizerFactory() {\n    return WhitespaceTokenizer.factory(false);\n  }\n\n  /**\n   * Return a GrammaticalStructureFactory suitable for this language/treebank.\n   * (To be overridden in subclasses.)\n   *\n   * @return A GrammaticalStructureFactory suitable for this language/treebank\n   */\n  @Override\n  public GrammaticalStructureFactory grammaticalStructureFactory() {\n    throw new UnsupportedOperationException(\n            \"No GrammaticalStructureFactory (typed dependencies) available for language/treebank \" +\n                    getClass().getName());\n  }\n\n  /**\n   * Return a GrammaticalStructureFactory suitable for this language/treebank.\n   * (To be overridden in subclasses.)\n   *\n   * @return A GrammaticalStructureFactory suitable for this language/treebank\n   */\n  @Override\n  public GrammaticalStructureFactory grammaticalStructureFactory(Predicate<String> puncFilt) {\n    return grammaticalStructureFactory();\n  }\n\n  /**\n   * Return a GrammaticalStructureFactory suitable for this language/treebank.\n   * (To be overridden in subclasses.)","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/AbstractTreebankLanguagePack.java#L586-L622","documentation":"AbstractTreebankLanguagePack.grammaticalStructureFactory() is a stub that must be overridden by concrete language packs that support typed dependencies. The base implementation always throws UnsupportedOperationException, telling the caller this language/treebank has no GrammaticalStructureFactory — i.e. it cannot produce GrammaticalStructures (typed dependency graphs).","triggerScenarios":"Calling tlp.grammaticalStructureFactory() (directly or via SemanticGraphFactory / parsing pipelines that request typed dependencies) on a TreebankLanguagePack subclass that does not override the method, e.g. a generic or custom language pack.","commonSituations":"Building a SemanticGraph from trees parsed with a custom/minimal language pack; running dependency conversion on a treebank whose pack lacks dependency support; copying a language pack stub without implementing the factory.","solutions":["Use a language pack that supports dependencies (e.g. EnglishTreebankLanguagePack, UniversalEnglishTreebankLanguagePack) for the pipeline.","If you own the subclass, implement grammaticalStructureFactory() returning the appropriate GrammaticalStructureFactory.","Skip typed-dependency generation for this treebank or configure the pipeline to not request SemanticGraphs."],"exampleFix":"// before\nclass MyTreebankLanguagePack extends AbstractTreebankLanguagePack { }\n// after\n@Override\npublic GrammaticalStructureFactory grammaticalStructureFactory() {\n  return new MyGrammaticalStructureFactory(MyGrammaticalStructure::new);\n}","handlingStrategy":"try-catch","validationCode":"GrammaticalStructureFactory gsf = null; try { gsf = tlp.grammaticalStructureFactory(); } catch (UnsupportedOperationException e) { /* no dep support */ }","typeGuard":"boolean supportsDeps(TreebankLanguagePack tlp) { try { tlp.grammaticalStructureFactory(); return true; } catch (UnsupportedOperationException e) { return false; } }","tryCatchPattern":"try { gsf = tlp.grammaticalStructureFactory(); } catch (UnsupportedOperationException e) { log.warn(\"No typed dependencies for {}\", tlp.getClass()); gsf = null; }","preventionTips":["Choose a TreebankLanguagePack known to support typed dependencies before enabling SemanticGraph output","Feature-detect with a probe call at pipeline configuration time"],"tags":["java","nlp","dependencies","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-16T04:17:20.429Z"}