src/main/java/eu/digitisation/distance/EditSequence.java
public int cost(String s1, String s2, EdOpWeight w) {
        int added = 0;
        int n1 = 0;
        int n2 = 0;
        for (EdOp op : ops) {
            switch (op) {
                case INSERT:
                    added += w.ins(s2.charAt(n2));
                    ++n2;
                    break;
                case SUBSTITUTE:
                    added += w.sub(s1.charAt(n1), s2.charAt(n2));
                    ++n1;
                    ++n2;
                    break;
                case DELETE:
                    added += w.del(s1.charAt(n1));
                    ++n1;
                    break;
                case KEEP:
                    ++n1;
                    ++n2;
                    break;
            }
        }
        return added;
    }
/**
     * Compute cost of the transformation
     *
     * @param s1 the source string
     * @param s2 the target string
     * @param w the cost of basic edit operations
     * @return the added cost of the edit operations (not identical to length
     * because some operation may be free)
     */
Compute cost of the transformation
@param s1 the source string
@param s2 the target string
@param w the cost of basic edit operations
@return the added cost of the edit operations (not identical to length
because some operation may be free)
Compute cost of the transformation @param s1 the source string @param s2 the target string @param w the cost of basic edit operations @return the added cost of the edit operations ( not identical to length because some operation may be free )
public int cost(String s1, String s2, EdOpWeight w) {
        int added = 0;
        int n1 = 0;
        int n2 = 0;
        for (EdOp op : ops) {
            switch (op) {
                case INSERT:
                    added += w.ins(s2.charAt(n2));
                    ++n2;
                    break;
                case SUBSTITUTE:
                    added += w.sub(s1.charAt(n1), s2.charAt(n2));
                    ++n1;
                    ++n2;
                    break;
                case DELETE:
                    added += w.del(s1.charAt(n1));
                    ++n1;
                    break;
                case KEEP:
                    ++n1;
                    ++n2;
                    break;
            }
        }
        return added;
    }
public int cost ( String s1 , String s2 , EdOpWeight w ) { int added = 0 ; int n1 = 0 ; int n2 = 0 ; for ( EdOp op : ops ) { switch ( op ) { case INSERT : added += w . ins ( s2 . charAt ( n2 ) ) ; ++ n2 ; break ; case SUBSTITUTE : added += w . sub ( s1 . charAt ( n1 ) , s2 . charAt ( n2 ) ) ; ++ n1 ; ++ n2 ; break ; case DELETE : added += w . del ( s1 . charAt ( n1 ) ) ; ++ n1 ; break ; case KEEP : ++ n1 ; ++ n2 ; break ; } } return added ; }
Compute cost of the transformation
 @param s1 the source string
 @param s2 the target string
 @param w the cost of basic edit operations
 @return the added cost of the edit operations (not identical to length
 because some operation may be free)
Compute cost of the transformation @param s1 the source string @param s2 the target string @param w the cost of basic edit operations @return the added cost of the edit operations ( not identical to length because some operation may be free )