{"record":{"id":"069136551eb863ad","repo":"stanfordnlp/CoreNLP","slug":"ctbunk-i-o-error-filename","errorCode":null,"errorMessage":"CTBunk I/O error: ${filename}","messagePattern":"CTBunk I/O error: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/tagger/maxent/CTBunkDict.java","lineNumber":56,"sourceCode":"\n      BufferedReader CTBunkDetectorReader = new BufferedReader(new InputStreamReader(new FileInputStream(filename), \"GB18030\"));\n      for (String CTBunkDetectorLine; (CTBunkDetectorLine = CTBunkDetectorReader.readLine()) != null; ) {\n        String[] fields = CTBunkDetectorLine.split(\" \");\n        String tag=fields[1];\n        Set<String> words=CTBunk_dict.get(tag);\n\n        if(words==null){\n          words = Generics.newHashSet();\n          CTBunk_dict.put(tag,words);\n        }\n        words.add(fields[0]);\n\n      }\n\n    } catch (FileNotFoundException e) {\n      throw new RuntimeIOException(\"CTBunk file not found: \" + filename, e);\n    } catch (IOException e) {\n      throw new RuntimeIOException(\"CTBunk I/O error: \" + filename, e);\n    }\n  }\n\n\n\n  /**\n   * Returns \"1\" as true if the dictionary listed this word with this tag,\n   *  and \"0\" otherwise.\n   *\n   * @param tag  The POS tag\n   * @param word The word\n   * @return \"1\" as true if the dictionary listed this word with this tag,\n   *  and \"0\" otherwise.\n   */\n  protected static String getTag(String tag, String word) {\n    CTBunkDict dict = CTBunkDict.getInstance();\n    Set<String> words = dict.get(tag);\n    if (words != null && words.contains(word)) {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/tagger/maxent/CTBunkDict.java#L38-L74","documentation":"While reading the CTBunk dictionary file, readCTBunkDict() can also fail with a general IOException (I/O error other than file-not-found, e.g., read failure, permissions, or stream corruption). It is rethrown as RuntimeIOException with this message, keeping the original exception as the cause.","triggerScenarios":"Calling the CTBunkDict constructor when opening/reading the CTBunk file throws IOException — unreadable file, permission errors, disk/network stream failure, or a truncated/corrupt file raising an I/O error mid-read.","commonSituations":"File with restrictive permissions, file on a flaky network mount, or resource loaded from a damaged jar/classpath entry where the stream fails during reading.","solutions":["Check file permissions and readability (chmod/chown) for the user running the JVM.","Verify the file isn't truncated or corrupt — re-extract or re-download the tagger resource distribution.","Inspect the wrapped cause (e.getCause()) of the RuntimeIOException to identify the exact underlying I/O problem."],"exampleFix":"// before\n// CTBunk file with mode 0600 owned by another user\njava ... // RuntimeIOException: CTBunk I/O error\n// after\nchmod 644 /path/to/ctbunki.txt","handlingStrategy":"try-catch","validationCode":"// Java: check readability before load\nFile f = new File(ctbunkPath);\nboolean readable = f.isFile() && f.canRead() && f.length() > 0;","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n  CTBunkDict d = new CTBunkDict(filename);\n} catch (RuntimeIOException e) {\n  logger.severe(\"CTBunk read failed: \" + e.getCause()); // inspect cause\n  throw e;\n}","preventionTips":["Ensure the JVM user has read permission on all resource files.","Verify jar/archive integrity after download (re-extract on failure).","Avoid loading resources from flaky network mounts; copy locally first.","Always inspect the wrapped cause for the real I/O failure."],"tags":["nlp","chinese","pos-tagger","io"],"backgroundTag":"file-read-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}