{"record":{"id":"9a1b558760af0539","repo":"stanfordnlp/CoreNLP","slug":"unparsable-sentence","errorCode":null,"errorMessage":"Unparsable sentence: ","messagePattern":"Unparsable sentence: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/ParseAndPrintMatrices.java","lineNumber":116,"sourceCode":"    DVModel model = DVParser.getModelFromLexicalizedParser(parser);\n\n    File outputFile = new File(outputPath);\n    FileSystem.checkNotExistsOrFail(outputFile);\n    FileSystem.mkdirOrFail(outputFile);\n\n    int count = 0;\n    if (inputPath != null) {\n      Reader input = new BufferedReader(new FileReader(inputPath));\n      DocumentPreprocessor processor = new DocumentPreprocessor(input);\n      for (List<HasWord> sentence : processor) {\n        count++; // index from 1\n        ParserQuery pq = parser.parserQuery();\n        if (!(pq instanceof RerankingParserQuery)) {\n          throw new IllegalArgumentException(\"Expected a RerankingParserQuery\");\n        }\n        RerankingParserQuery rpq = (RerankingParserQuery) pq;\n        if (!rpq.parse(sentence)) {\n          throw new RuntimeException(\"Unparsable sentence: \" + sentence);\n        }\n        RerankerQuery reranker = rpq.rerankerQuery();\n        if (!(reranker instanceof DVModelReranker.Query)) {\n          throw new IllegalArgumentException(\"Expected a DVModelReranker\");\n        }\n        DeepTree deepTree = ((DVModelReranker.Query) reranker).getDeepTrees().get(0);\n        IdentityHashMap<Tree, SimpleMatrix> vectors = deepTree.getVectors();\n\n        for (Map.Entry<Tree, SimpleMatrix> entry : vectors.entrySet()) {\n          log.info(entry.getKey() + \"   \" +  entry.getValue());\n        }\n\n        FileWriter fout = new FileWriter(outputPath + File.separator + \"sentence\" + count + \".txt\");\n        BufferedWriter bout = new BufferedWriter(fout);\n\n        bout.write(SentenceUtils.listToString(sentence));\n        bout.newLine();\n        bout.write(deepTree.getTree().toString());","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/ParseAndPrintMatrices.java#L98-L134","documentation":"When the reranking parser fails to find a parse for a sentence, ParseAndPrintMatrices.main() throws RuntimeException(\"Unparsable sentence: ...\") including the token list. With no parse produced there are no deep trees or matrices to print, so the tool aborts that run.","triggerScenarios":"rpq.parse(sentence) returns false inside the DocumentPreprocessor loop — typically sentences that exceed parser length/beam limits, contain only punctuation or unknown tokens, or are malformed input text in the input file.","commonSituations":"Feeding long sentences or noisy text (web data, OCR output) to the parser; empty lines producing degenerate token lists; unusually low nThreads/beam settings causing parse failures.","solutions":["Wrap rpq.parse in a try/catch or check the boolean and skip/log unparsable sentences instead of letting main throw","Pre-filter sentences: length limits, strip noise, ensure non-empty token lists","Increase parser limits (e.g. maximum sentence length / beam size options) for long sentences"],"exampleFix":"// before\nif (!rpq.parse(sentence)) {\n  throw new RuntimeException(\"Unparsable sentence: \" + sentence);\n}\n// after\nif (!rpq.parse(sentence)) {\n  System.err.println(\"Skipping unparsable sentence: \" + sentence);\n  continue;\n}","handlingStrategy":"try-catch","validationCode":"List<HasWord> tokens = sentence;\nif (tokens.isEmpty() || tokens.size() > maxSentenceLength) {\n  continue; // skip sentences the parser cannot handle\n}","typeGuard":null,"tryCatchPattern":"if (!rpq.parse(sentence)) {\n  System.err.println(\"Skipping unparsable sentence: \" + sentence);\n  continue;\n}\n// or wrap the whole loop:\ntry {\n  processAllSentences();\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Unparsable sentence\")) { logAndSkip(e); } else { throw e; }\n}","preventionTips":["Pre-filter input: remove empty/overly long lines and non-text noise","Log skipped sentences instead of aborting the batch","Tune parser limits (length, beam) for your data domain","Run a small sample of the input through the parser first"],"tags":["java","parsing","runtime","input-validation"],"backgroundTag":"http-request-failed","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"}