{"record":{"id":"34938cb092595134","repo":"stanfordnlp/CoreNLP","slug":"inconsistent-u2b-b2u-arrays","errorCode":null,"errorMessage":": Inconsistent u2b/b2u arrays.","messagePattern":": Inconsistent u2b/b2u arrays\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/international/arabic/Buckwalter.java","lineNumber":135,"sourceCode":"  private boolean unicode2Buckwalter = false;\n  private final Map<Character,Character> u2bMap;\n  private final Map<Character,Character> b2uMap;\n  private ClassicCounter<String> unmappable;\n\n  private static boolean DEBUG = false;\n  private static final boolean PASS_ASCII_IN_UNICODE = true;\n  private static boolean SUPPRESS_DIGIT_MAPPING_IN_B2A = true;\n  private static boolean SUPPRESS_PUNC_MAPPING_IN_B2A = true;\n\n  //wsg: I have included _ in this list, which actually maps to tatweel.\n  //In practice we strip tatweel as part of orthographic normalization,\n  //so any instances of _ in the Buckwalter should actually be treated as\n  //punctuation.\n  private static final Pattern latinPunc = Pattern.compile(\"[\\\"\\\\?%,-;\\\\._]+\");\n\n  public Buckwalter() {\n    if (arabicChars.length != buckChars.length)\n      throw new RuntimeException(this.getClass().getName() + \": Inconsistent u2b/b2u arrays.\");\n\n    u2bMap = Generics.newHashMap(arabicChars.length);\n    b2uMap = Generics.newHashMap(buckChars.length);\n    for (int i = 0; i < arabicChars.length; i++) {\n      Character charU = Character.valueOf(arabicChars[i]);\n      Character charB = Character.valueOf(buckChars[i]);\n      u2bMap.put(charU, charB);\n      b2uMap.put(charB, charU);\n    }\n\n    if (DEBUG) unmappable = new ClassicCounter<>();\n  }\n\n  public Buckwalter(boolean unicodeToBuckwalter) {\n    this();\n    unicode2Buckwalter = unicodeToBuckwalter;\n  }\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/arabic/Buckwalter.java#L117-L153","documentation":"The Buckwalter transliteration utility keeps two parallel static character arrays (arabicChars and buckChars) that must be the same length to build the u2b/b2u maps. Its constructor throws this RuntimeException if the arrays drift out of sync — a build-time/initialization invariant that indicates corrupted source data, not user input.","triggerScenarios":"Instantiating new Buckwalter() when the class's arabicChars and buckChars arrays differ in length — only possible if the class source/constants were modified, patched, or bundled from mismatched versions.","commonSituations":"Manually edited or partially copied Buckwalter.java (adding a Buckwalter char without the Arabic counterpart); merging forks of CoreNLP with divergent transliteration tables; source corruption during vendoring of the library.","solutions":["Compare arabicChars and buckChars array lengths in Buckwalter.java and re-align them one-to-one.","Restore the original Buckwalter.java from the official CoreNLP source for your version.","If adding a new mapping, add both the Arabic character and its Buckwalter counterpart at the same index.","Check that no stale patched class file shadows the corrected source in your classpath."],"exampleFix":"// before (Buckwalter.java)\nprivate static final char[] arabicChars = {'\\u0621', '\\u0622', '\\u0623'};\nprivate static final char[] buckChars   = {'\\'', '|', '>', '<'};\n// after (equal lengths)\nprivate static final char[] arabicChars = {'\\u0621', '\\u0622', '\\u0623', '\\u0624'};\nprivate static final char[] buckChars   = {'\\'', '|', '>', '<'};","handlingStrategy":"try-catch","validationCode":"// java: fail fast at startup if transliteration tables are inconsistent\ntry { new Buckwalter(); }\ncatch (RuntimeException e) {\n  throw new IllegalStateException(\"Buckwalter class corrupted: \" + e.getMessage());\n}","typeGuard":null,"tryCatchPattern":"static final Buckwalter BW;\nstatic {\n  try { BW = new Buckwalter(); }\n  catch (RuntimeException e) {\n    throw new ExceptionInInitializerError(\"Buckwalter tables inconsistent - restore original class: \" + e.getMessage());\n  }\n}","preventionTips":["Never modify the arabicChars/buckChars arrays independently; always add mappings pairwise.","Use an unmodified Buckwalter.java from the official CoreNLP release.","Add a startup smoke test that instantiates Buckwalter to catch vendoring/merge corruption early."],"tags":["java","arabic","transliteration","invariant"],"backgroundTag":"internal-invariant-violation","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"}