### Question:
OcrOpWeight implements EdOpWeight { @Override public int sub(char c1, char c2) { return (Character.isSpaceChar(c1) ^ Character.isSpaceChar(c2)) ? 4 : 1; } OcrOpWeight(boolean ignorePunctuation);  OcrOpWeight(Parameters pars);  OcrOpWeight(); @Override int sub(char c1, char c2); @Override int ins(char c); @Override int del(char c);  }### Answer:
@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); } }