{"record":{"id":"878431699e8e114c","repo":"stanfordnlp/CoreNLP","slug":"unknown-grammatical-relation-grelstring-fields","errorCode":null,"errorMessage":"Unknown grammatical relation '<grelString>' fields: <fields>\nNode: <node>\nKnown Grammatical relations: [<knownRelations>]","messagePattern":"Unknown grammatical relation '<grelString>' fields: <fields>\nNode: <node>\nKnown Grammatical relations: \\[<knownRelations>\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/GrammaticalStructure.java","lineNumber":1159,"sourceCode":"    rootLabel.setValue(\"ROOT\");\n    rootLabel.setWord(\"ROOT\");\n    rootLabel.setIndex(0);\n    IndexedWord dependencyRoot = new IndexedWord(rootLabel);\n    for (int i = 0; i < tgWords.size(); i++) {\n      String parentIdStr = tokenFields.get(i).get(CoNLLX_GovField);\n      if (StringUtils.isNullOrEmpty(parentIdStr)) {\n        continue;\n      }\n      String grelString = tokenFields.get(i).get(CoNLLX_RelnField);\n      if (grelString.equals(\"null\") || grelString.equals(\"erased\"))\n        continue;\n      GrammaticalRelation grel = shortNameToGRel.get(grelString.toLowerCase());\n      TypedDependency tdep;\n      if (grel == null) {\n        if (grelString.toLowerCase().equals(\"root\")) {\n          tdep = new TypedDependency(ROOT, dependencyRoot, tgWords.get(i));\n        } else {\n          throw new RuntimeException(\"Unknown grammatical relation '\" +\n                                     grelString + \"' fields: \" +\n                                     tokenFields.get(i) + \"\\nNode: \" +\n                                     tgWords.get(i) + '\\n' +\n                                     \"Known Grammatical relations: [\"+shortNameToGRel.keySet() + ']');\n        }\n      } else {\n        int parentId = Integer.parseInt(parentIdStr) - 1;\n        if (parentId >= tgWords.size()) {\n          System.err.printf(\"Warning: Invalid Parent Id %d Sentence Length: %d%n\", parentId+1, tgWords.size());\n          System.err.printf(\"         Assigning to root (0)%n\");\n          parentId = -1;\n        }\n        tdep = new TypedDependency(grel, (parentId == -1 ? dependencyRoot : tgWords.get(parentId)),\n                                   tgWords.get(i));\n      }\n      tdeps.add(tdep);\n    }\n    return factory.build(tdeps, root);","sourceCodeStart":1141,"sourceCodeEnd":1177,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/GrammaticalStructure.java#L1141-L1177","documentation":"When reading a CoNLL-X file, the deprel string of each token is looked up in shortNameToGRel (the map of known short-name GrammaticalRelations for the current language, e.g. EnglishGrammaticalRelations). If the relation string is not recognized and is not the special case 'root', the reader throws this RuntimeException naming the unknown relation, the raw fields, the node, and the list of known relations.","triggerScenarios":"readCoNLLXGrammaticalStructure-style reading where a token's deprel column (field 8) contains a short name not present in the loaded language's GrammaticalRelations set; calling with a deprel that has wrong case beyond lowercasing, or a language-specific relation from a different treebank.","commonSituations":"Using CoNLL-X files annotated with universal or language-specific relations different from the loaded GrammaticalStructure language (e.g. UniversalEnglish relations fed to the English reader); typos like 'nsubjpass' vs 'nsubj:pass'; custom relations added in a newer CoreNLP release than the one in use.","solutions":["Check the 'Known Grammatical relations' list in the message and correct the deprel strings in the file to a supported name.","Use the language/universal GrammaticalStructure (e.g. UniversalEnglishGrammaticalStructure) matching the annotation scheme of your file.","Upgrade to a CoreNLP version whose relation set includes the relations used in your treebank, or register the missing relation if you have a custom GrammaticalRelations class.","Pre-map unsupported relations to nearest supported equivalents before parsing."],"exampleFix":"// before: deprel column 'acl:relcl' with English (non-universal) reader\n// after: parse with UniversalEnglishGrammaticalStructure.fromReader(...) which knows 'acl:relcl',\n// or rewrite the column to 'relcl'","handlingStrategy":"try-catch","validationCode":"// Check deprel names against the known relation set before reading\nSet<String> known = GrammaticalStructure.shortNameToGRel != null\n  ? new HashSet<>(knownRelationShortNames) : null;\n// or simply: verify every field 8 value is in the printed 'Known Grammatical relations' list","typeGuard":null,"tryCatchPattern":"try {\n  GrammaticalStructure gs = readCoNLLX(reader);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown grammatical relation\")) {\n    String rel = e.getMessage().split(\"'\")[1];\n    log.error(\"Unsupported deprel '\" + rel + \"'; remap or switch to the universal reader\");\n  } else throw e;\n}","preventionTips":["Match the GrammaticalStructure class (English vs UniversalEnglish vs other languages) to your treebank's annotation scheme.","Keep a mapping table from your treebank's relation inventory to the library's relation short names.","Pin and read the CoreNLP version docs for supported relation names."],"tags":["parsing","grammatical-relations","conll-x","dependency-trees"],"backgroundTag":"invalid-enum-value","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"}