src/main/java/pt/it/av/tnav/ml/tm/ngrams/NGram.java
public int levenshtein(NGram ngram) {
    int rv = 0;
    String first[], second[];
    if (array.length < ngram.array.length) {
      second = array;
      first = ngram.array;
    } else {
      first = array;
      second = ngram.array;
    }

    for (int i = 0; i < second.length; i++)
      rv += StringUtils.levenshtein(first[i], second[i]);

    for (int i = second.length; i < first.length; i++)
      rv += StringUtils.levenshtein(first[i], "");

    return rv;
  }
/**
   * Returns the Levenshtein distance between two NGrams.
   *
   * @param ngram the second NGram
   * @return Levenshtein distance between two NGrams
   */
Returns the Levenshtein distance between two NGrams.
@param ngram the second NGram
@return Levenshtein distance between two NGrams
Returns the Levenshtein distance between two NGrams . @param ngram the second NGram @return Levenshtein distance between two NGrams
public int levenshtein(NGram ngram) {
    int rv = 0;
    String first[], second[];
    if (array.length < ngram.array.length) {
      second = array;
      first = ngram.array;
    } else {
      first = array;
      second = ngram.array;
    }
    for (int i = 0; i < second.length; i++)
      rv += StringUtils.levenshtein(first[i], second[i]);
    for (int i = second.length; i < first.length; i++)
      rv += StringUtils.levenshtein(first[i], "");
    return rv;
  }
public int levenshtein ( NGram ngram ) { int rv = 0 ; String first [ ] , second [ ] ; if ( array . length < ngram . array . length ) { second = array ; first = ngram . array ; } else { first = array ; second = ngram . array ; } for ( int i = 0 ; i < second . length ; i ++ ) rv += StringUtils . levenshtein ( first [ i ] , second [ i ] ) ; for ( int i = second . length ; i < first . length ; i ++ ) rv += StringUtils . levenshtein ( first [ i ] , "" ) ; return rv ; }
Returns the Levenshtein distance between two NGrams.
Returns the Levenshtein distance between two NGrams .