Class UnicodeBlockRanges

java.lang.Object
org.apache.tika.ml.junkdetect.UnicodeBlockRanges

public final class UnicodeBlockRanges extends Object
Static codepoint-range → bucket-index lookup table used by Feature 2 (block-transition log-probability). Replaces Character.UnicodeBlock.of(int) so that the model's block semantics are fully decoupled from the JVM's Unicode-data release — training on one JDK and serving on another produces identical scores by construction.

The 338 named blocks are a snapshot from JDK 25's Character.UnicodeBlock (Unicode 16.x). Codepoints in gaps between named blocks resolve to the UNASSIGNED bucket (338). The total bucket count is bucketCount() = 339.

If the block list is ever updated, bump SCHEME_VERSION — the model file's block_scheme_version byte must match. This forces a clean retrain rather than silent re-mapping.

Lookup cost: O(log N) binary search. Thread-safe, immutable.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Bumped whenever the static range table below changes.
    static final int
    Bucket index returned for codepoints in no named block.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Total number of buckets (named blocks + 1 unassigned).
    static int
    bucketOf(int cp)
    Returns the bucket id for the given codepoint, or UNASSIGNED if the codepoint falls outside every named block range.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SCHEME_VERSION

      public static final int SCHEME_VERSION
      Bumped whenever the static range table below changes. A model trained against scheme version X cannot be served by code at version Y ≠ X — the loader rejects the mismatch.
      See Also:
    • UNASSIGNED

      public static final int UNASSIGNED
      Bucket index returned for codepoints in no named block.
      See Also:
  • Method Details

    • bucketCount

      public static int bucketCount()
      Total number of buckets (named blocks + 1 unassigned).
    • bucketOf

      public static int bucketOf(int cp)
      Returns the bucket id for the given codepoint, or UNASSIGNED if the codepoint falls outside every named block range.

      Binary search over the sorted-by-start_cp range list: O(log N) where N = 338 (the number of named blocks).