docs: private static String wordShapeChris2Long(String s, boolean omitIfInBoundary, int len, Collection<String> knownLCWords) {
      final char[] beginChars = new char[BOUNDARY_SIZE];
      final char[] endChars = new char[BOUNDARY_SIZE];
      int beginUpto = 0;
      int endUpto = 0;
      final Set<Character> seenSet = new TreeSet<Character>();  // TreeSet guarantees stable ordering; has no size parameter
  
      boolean nonLetters = false;
  
      for (int i = 0; i < len; i++) {
        int iIncr = 0;
        char c = s.charAt(i);
        char m = c;
        if (Character.isDigit(c)) {
          m = 'd';
        } else if (Character.isLowerCase(c)) {
          m = 'x';
        } else if (Character.isUpperCase(c) || Character.isTitleCase(c)) {
          m = 'X';
        }
        for (String gr : greek) {
          if (s.startsWith(gr, i)) {
            m = 'g';
            //System.out.println(s + "  ::  " + s.substring(i+1));
            iIncr = gr.length() - 1;
            break;
          }
        }
        if (m != 'x' && m != 'X') {
          nonLetters = true;
        }
  
        if (i < BOUNDARY_SIZE) {
          beginChars[beginUpto++] = m;
        } else if (i < len - BOUNDARY_SIZE) {
          seenSet.add(Character.valueOf(m));
        } else {
          endChars[endUpto++] = m;
        }
        i += iIncr;
        // System.out.println("Position skips to " + i);
      }
  
      // Calculate size. This may be an upperbound, but is often correct
      int sbSize = beginUpto + endUpto + seenSet.size();
      if (knownLCWords != null) { sbSize++; }
      final StringBuilder sb = new StringBuilder(sbSize);
      // put in the beginning chars
      sb.append(beginChars, 0, beginUpto);
      // put in the stored ones sorted
      if (omitIfInBoundary) {
        for (Character chr : seenSet) {
          char ch = chr.charValue();
          boolean insert = true;
          for (int i = 0; i < beginUpto; i++) {
            if (beginChars[i] == ch) {
              insert = false;
              break;
            }
          }
          for (int i = 0; i < endUpto; i++) {
            if (endChars[i] == ch) {
              insert = false;
              break;
            }
          }
          if (insert) {
            sb.append(ch);
          }
        }
      } else {
        for (Character chr : seenSet) {
          sb.append(chr.charValue());
        }
      }
      // and add end ones
      sb.append(endChars, 0, endUpto);
  
      if (knownLCWords != null) {
        if (!nonLetters && knownLCWords.contains(s.toLowerCase())) {
          sb.append('k');
        }
      }
      // System.out.println(s + " became " + sb);
      return sb.toString();
    }