src/test/java/eu/digitisation/distance/OcrOpWeightTest.java
@Test
    public void testSub() {
        System.out.println("sub");
        char[] c1 = {'Á', 'Á', 'Á', 'Á', 'Á'};
        char[] c2 = {'Á', 'A', 'á', 'a', ' '};
        int[] w1 = {0, 1, 1, 1, 2};
        OcrOpWeight W1 = new OcrOpWeight(); // fully-sensitive
        for (int n = 0; n < w1.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), false, false, false);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), false, false, false);
            int d = EditDistance.charDistance(s1, s2, W1, 10);
            assertEquals(w1[n], d);
        }
        OcrOpWeight W2 = new OcrOpWeight(true); //ignore everything
        int[] w2 = {0, 0, 0, 0, 2};
        for (int n = 0; n < w2.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), true, true, true);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), true, true, true);
            int d = EditDistance.charDistance(s1, s2, W2, 10);
            assertEquals(w2[n], d);
        }
        OcrOpWeight W3 = new OcrOpWeight(false); //ignore diacritics
        int[] w3 = {0, 0, 1, 1, 2};
        for (int n = 0; n < w3.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), false, true, true);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), false, true, true);
            int d = EditDistance.charDistance(s1, s2, W3, 10);
            assertEquals(w3[n], d);
        }

        OcrOpWeight W4 = new OcrOpWeight(true); //ignore case
        int[] w4 = {0, 1, 0, 1, 2};
        for (int n = 0; n < w4.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), true, false, true);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), true, false, true);
            int d = EditDistance.charDistance(s1, s2, W4, 10);
            assertEquals(w4[n], d);
        }
    }
/**
     * Test of sub method, of class OcrWeights.
     */
Test of sub method, of class OcrWeights.
Test of sub method of class OcrWeights .
@Test
    public void testSub() {
        System.out.println("sub");
        char[] c1 = {'Á', 'Á', 'Á', 'Á', 'Á'};
        char[] c2 = {'Á', 'A', 'á', 'a', ' '};
        int[] w1 = {0, 1, 1, 1, 2};
        OcrOpWeight W1 = new OcrOpWeight(); 
        for (int n = 0; n < w1.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), false, false, false);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), false, false, false);
            int d = EditDistance.charDistance(s1, s2, W1, 10);
            assertEquals(w1[n], d);
        }
        OcrOpWeight W2 = new OcrOpWeight(true); 
        int[] w2 = {0, 0, 0, 0, 2};
        for (int n = 0; n < w2.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), true, true, true);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), true, true, true);
            int d = EditDistance.charDistance(s1, s2, W2, 10);
            assertEquals(w2[n], d);
        }
        OcrOpWeight W3 = new OcrOpWeight(false); 
        int[] w3 = {0, 0, 1, 1, 2};
        for (int n = 0; n < w3.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), false, true, true);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), false, true, true);
            int d = EditDistance.charDistance(s1, s2, W3, 10);
            assertEquals(w3[n], d);
        }
        OcrOpWeight W4 = new OcrOpWeight(true); 
        int[] w4 = {0, 1, 0, 1, 2};
        for (int n = 0; n < w4.length; ++n) {
            String s1 = StringNormalizer.canonical(String.valueOf(c1[n]), true, false, true);
            String s2 = StringNormalizer.canonical(String.valueOf(c2[n]), true, false, true);
            int d = EditDistance.charDistance(s1, s2, W4, 10);
            assertEquals(w4[n], d);
        }
    }
@ Test public void testSub ( ) { System . out . println ( "sub" ) ; char [ ] c1 = { 'Á', Á',  ' ', ' Á , 'Á ' ; char [ ] c2 = { 'Á', A', á',  ' ',  ' '}; int [ ] w1 = { 0 , 1 , 1 , 1 , 2 } ; OcrOpWeight W1 = new OcrOpWeight ( ) ; for ( int n = 0 ; n < w1 . length ; ++ n ) { String s1 = StringNormalizer . canonical ( String . valueOf ( c1 [ n ] ) , false , false , false ) ; String s2 = StringNormalizer . canonical ( String . valueOf ( c2 [ n ] ) , false , false , false ) ; int d = EditDistance . charDistance ( s1 , s2 , W1 , 10 ) ; assertEquals ( w1 [ n ] , d ) ; } OcrOpWeight W2 = new OcrOpWeight ( true ) ; int [ ] w2 = { 0 , 0 , 0 , 0 , 2 } ; for ( int n = 0 ; n < w2 . length ; ++ n ) { String s1 = StringNormalizer . canonical ( String . valueOf ( c1 [ n ] ) , true , true , true ) ; String s2 = StringNormalizer . canonical ( String . valueOf ( c2 [ n ] ) , true , true , true ) ; int d = EditDistance . charDistance ( s1 , s2 , W2 , 10 ) ; assertEquals ( w2 [ n ] , d ) ; } OcrOpWeight W3 = new OcrOpWeight ( false ) ; int [ ] w3 = { 0 , 0 , 1 , 1 , 2 } ; for ( int n = 0 ; n < w3 . length ; ++ n ) { String s1 = StringNormalizer . canonical ( String . valueOf ( c1 [ n ] ) , false , true , true ) ; String s2 = StringNormalizer . canonical ( String . valueOf ( c2 [ n ] ) , false , true , true ) ; int d = EditDistance . charDistance ( s1 , s2 , W3 , 10 ) ; assertEquals ( w3 [ n ] , d ) ; } OcrOpWeight W4 = new OcrOpWeight ( true ) ; int [ ] w4 = { 0 , 1 , 0 , 1 , 2 } ; for ( int n = 0 ; n < w4 . length ; ++ n ) { String s1 = StringNormalizer . canonical ( String . valueOf ( c1 [ n ] ) , true , false , true ) ; String s2 = StringNormalizer . canonical ( String . valueOf ( c2 [ n ] ) , true , false , true ) ; int d = EditDistance . charDistance ( s1 , s2 , W4 , 10 ) ; assertEquals ( w4 [ n ] , d ) ; } }
Test of sub method, of class OcrWeights.
Test of sub method of class OcrWeights .
// fully-sensitive //ignore everything //ignore diacritics //ignore case