{"record":{"id":"faac8336e903d7c3","repo":"stanfordnlp/CoreNLP","slug":"unknown-grammatical-relation","errorCode":null,"errorMessage":"Unknown grammatical relation '","messagePattern":"Unknown grammatical relation '","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/DependencyScoring.java","lineNumber":217,"sourceCode":"      int commaSpace = line.indexOf(\", \");\n      String depName = line.substring(0, firstParen);\n      String govName = line.substring(firstParen + 1, commaSpace);\n      String childName = line.substring(commaSpace+2, line.length() - 1);\n      GrammaticalRelation grel = GrammaticalRelation.valueOf(depName);\n      if (depName.startsWith(\"prep_\")) {\n        String prep = depName.substring(5);\n        grel = EnglishGrammaticalRelations.getPrep(prep);\n      }\n      if (depName.startsWith(\"prepc_\")) {\n        String prepc = depName.substring(6);\n        grel = EnglishGrammaticalRelations.getPrepC(prepc);\n      }\n      if (depName.startsWith(\"conj_\")) {\n        String conj = depName.substring(5);\n        grel = EnglishGrammaticalRelations.getConj(conj);\n      }\n      if (grel == null) {\n        throw new RuntimeException(\"Unknown grammatical relation '\" + depName+\"'\");\n      }\n\n      //Word govWord = new Word(govName.substring(0, govDash));\n      IndexedWord govWord = new IndexedWord();\n      govWord.setValue(normalizeNumbers(govName));\n      govWord.setWord(govWord.value());\n      //Word childWord = new Word(childName.substring(0, childDash));\n      IndexedWord childWord = new IndexedWord();\n      childWord.setValue(normalizeNumbers(childName));\n      childWord.setWord(childWord.value());\n      TypedDependency dep = new TypedDependencyStringEquality(grel, govWord, childWord);\n      deps.add(dep);\n      } catch (Exception e) {\n        breader.close();\n        throw new RuntimeException(\"Error on line \"+breader.getLineNumber()+\":\\n\\n\"+e);\n      }\n    }\n    if (deps.size() != 0) {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/DependencyScoring.java#L199-L235","documentation":"readDeps parses a dependency file where each line names a grammatical relation; the relation string is mapped to an EnglishGrammaticalRelations object (including conj_<x> handling). If no mapping is found (grel == null) the string is not a known English grammatical relation, so it throws with the offending relation name.","triggerScenarios":"Scoring a dependency file whose relation column contains a relation not in EnglishGrammaticalRelations — e.g. SD-style names not matching the loaded grammar, universal-dependencies names (nsubj:pass, obl:*) against the non-UD relation set, typos, or relations from another language.","commonSituations":"Mixing Universal Dependencies output with English (Stanford Dependencies) scoring; custom relations added by a parser; scoring CoNLL data with short names (nsubj vs. subj) that this reader doesn't accept; version drift between tool output and library relation inventory.","solutions":["Correct the relation name in the input file to a valid EnglishGrammaticalRelations name.","Match the reader to your data format — use the UniversalDependencies scoring variant or convert relations (e.g. nsubj:pass -> agent/auxpass equivalents) before scoring.","Regenerate system output with a matching GrammaticalStructureFactory so relation names agree with the scorer."],"exampleFix":"// before (input line)\n5\tobl:tmod\t3\n// after\n5\ttmod\t3","handlingStrategy":"validation","validationCode":"if (EnglishGrammaticalRelations.valueOf(depName) == null && !depName.startsWith(\"conj_\")) { throw new IllegalArgumentException(\"unknown rel: \" + depName); }","typeGuard":null,"tryCatchPattern":"try { scoring = new DependencyScoring(goldPath, ...); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unknown grammatical relation\")) { convertRelations(goldPath); scoring = new DependencyScoring(goldPath, ...); } }","preventionTips":["Generate dependency output with the same relation inventory the scorer expects","Convert UD relation names to Stanford Dependencies before scoring","Validate relation names in a preprocessing pass over the whole file"],"tags":["java","nlp","dependency-parsing","invalid-enum-value"],"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"}