public LevenshteinAutomata(int[] word,int alphaMax,boolean withTranspositions){
  this.word=word;
  this.alphaMax=alphaMax;
  SortedSet<Integer> set=new TreeSet<>();
  for (int i=0; i < word.length; i++) {
    int v=word[i];
    if (v > alphaMax) {
      throw new IllegalArgumentException("alphaMax exceeded by symbol " + v + " in word");
    }
    set.add(v);
  }
  alphabet=new int[set.size()];
  Iterator<Integer> iterator=set.iterator();
  for (int i=0; i < alphabet.length; i++)   alphabet[i]=iterator.next();
  rangeLower=new int[alphabet.length + 2];
  rangeUpper=new int[alphabet.length + 2];
  int lower=0;
  for (int i=0; i < alphabet.length; i++) {
    int higher=alphabet[i];
    if (higher > lower) {
      rangeLower[numRanges]=lower;
      rangeUpper[numRanges]=higher - 1;
      numRanges++;
    }
    lower=higher + 1;
  }
  if (lower <= alphaMax) {
    rangeLower[numRanges]=lower;
    rangeUpper[numRanges]=alphaMax;
    numRanges++;
  }
  descriptions=new ParametricDescription[]{null,withTranspositions ? new Lev1TParametricDescription(word.length) : new Lev1ParametricDescription(word.length),withTranspositions ? new Lev2TParametricDescription(word.length) : new Lev2ParametricDescription(word.length)};
}

public LevenshteinAutomata ( int [ ] word , int alphaMax , boolean withTranspositions ) { this . word = word ; this . alphaMax = alphaMax ; SortedSet < Integer > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < word . length ; i ++ ) { int v = word [ i ] ; if ( v > alphaMax ) { throw new IllegalArgumentException ( "alphaMax exceeded by symbol " + v + " in word" ) ; } set . add ( v ) ; } alphabet = new int [ set . size ( ) ] ; Iterator < Integer > iterator = set . iterator ( ) ; for ( int i = 0 ; i < alphabet . length ; i ++ ) alphabet [ i ] = iterator . next ( ) ; rangeLower = new int [ alphabet . length + 2 ] ; rangeUpper = new int [ alphabet . length + 2 ] ; int lower = 0 ; for ( int i = 0 ; i < alphabet . length ; i ++ ) { int higher = alphabet [ i ] ; if ( higher > lower ) { rangeLower [ numRanges ] = lower ; rangeUpper [ numRanges ] = higher - 1 ; numRanges ++ ; } lower = higher + 1 ; } if ( lower <= alphaMax ) { rangeLower [ numRanges ] = lower ; rangeUpper [ numRanges ] = alphaMax ; numRanges ++ ; } descriptions = new ParametricDescription [ ] { null , withTranspositions ? new Lev1TParametricDescription ( word . length ) : new Lev1ParametricDescription ( word . length ) , withTranspositions ? new Lev2TParametricDescription ( word . length ) : new Lev2ParametricDescription ( word . length ) } ; }
expert : specify a custom maximum possible symbol ( alphamax ) ; default is character . max_code_point .
