code: private void checkCell(int start, int end) {
          if (start > nplus - 1 || end > nplus || start < 0 || end < 1) {
              throw new IllegalStateException(String.format("Invalid cell: start=%d end=%d", start, end));
          }
      }
docs: Checks that start \in [0, n-1] and end \in [1, n], where nplus is the sentence length plus 1.