{"record":{"id":"8703966274829c24","repo":"stanfordnlp/CoreNLP","slug":"line-doesn-t-contain-two-tokens-line","errorCode":null,"errorMessage":"Line doesn't contain two tokens: ${line}","messagePattern":"Line doesn't contain two tokens: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/stats/SimpleGoodTuring.java","lineNumber":203,"sourceCode":"  }\n\n\n  // static methods -------------------------------------------------------------\n\n  /**\n   * Reads from STDIN a sequence of lines, each containing two integers,\n   * separated by whitespace.  Returns a pair of int arrays containing the\n   * values read.\n   */\n  private static int[][] readInput() throws Exception {\n    List<Integer> rVals = new ArrayList<>();\n    List<Integer> nVals = new ArrayList<>();\n    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n    String line;\n    while ((line = in.readLine()) != null) {\n      String[] tokens = line.trim().split(\"\\\\s+\");\n      if (tokens.length != 2)\n        throw new Exception(\"Line doesn't contain two tokens: \" + line);\n      Integer r = Integer.valueOf(tokens[0]);\n      Integer n = Integer.valueOf(tokens[1]);\n      rVals.add(r);\n      nVals.add(n);\n    }\n    in.close();\n    int[][] result = new int[2][];\n    result[0] = integerList2IntArray(rVals);\n    result[1] = integerList2IntArray(nVals);\n    return result;\n  }\n\n  /**\n   * Helper to readInput().\n   */\n  private static int[] integerList2IntArray(List<Integer> integers) {\n    int[] ints = new int[integers.size()];\n    int i = 0;","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/stats/SimpleGoodTuring.java#L185-L221","documentation":"readInput() reads SimpleGoodTuring's stdin input format, which expects each line to contain exactly two whitespace-separated tokens: the count r and the number of types n. Any line with a different token count throws a generic Exception naming the offending line.","triggerScenarios":"Feeding the main()/input() entry point stdin lines that don't have exactly two whitespace-separated integers, e.g. blank-but-not-empty lines, extra columns, comments, or a header row.","commonSituations":"Piping a file with a header or trailing annotation lines into the program, copy-pasting data with stray whitespace or an index column, or Windows line endings combining tokens unexpectedly.","solutions":["Fix the input so every line has exactly two whitespace-separated integer tokens (r and n).","Strip header/comment/blank lines from the input before piping it in.","Pre-validate each line in your own code (split on whitespace, check length == 2) before feeding it to the program."],"exampleFix":"// before\necho \"5 3 extra\" | java SimpleGoodTuring ...\n// after\necho \"5 3\" | java SimpleGoodTuring ...","handlingStrategy":"validation","validationCode":"// Java: validate lines before piping\nboolean valid = line.trim().split(\"\\\\s+\").length == 2;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Preprocess input: remove headers, comments, and blank/non-empty whitespace lines.","Ensure exactly two whitespace-separated integers per line (r and n).","Normalize line endings before feeding stdin."],"tags":["nlp","input-format","parsing"],"backgroundTag":"invalid-argument-format","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"}