01: /**
02: * LibreSource
03: * Copyright (C) 2004-2008 Artenum SARL / INRIA
04: * http://www.libresource.org - contact@artenum.com
05: *
06: * This file is part of the LibreSource software,
07: * which can be used and distributed under license conditions.
08: * The license conditions are provided in the LICENSE.TXT file
09: * at the root path of the packaging that enclose this file.
10: * More information can be found at
11: * - http://dev.libresource.org/home/license
12: *
13: * Initial authors :
14: *
15: * Guillaume Bort / INRIA
16: * Francois Charoy / Universite Nancy 2
17: * Julien Forest / Artenum
18: * Claude Godart / Universite Henry Poincare
19: * Florent Jouille / INRIA
20: * Sebastien Jourdain / INRIA / Artenum
21: * Yves Lerumeur / Artenum
22: * Pascal Molli / Universite Henry Poincare
23: * Gerald Oster / INRIA
24: * Mariarosa Penzi / Artenum
25: * Gerard Sookahet / Artenum
26: * Raphael Tani / INRIA
27: *
28: * Contributors :
29: *
30: * Stephane Bagnier / Artenum
31: * Amadou Dia / Artenum-IUP Blois
32: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33: */package org.libresource.search;
34:
35: public class StringHelper {
36: private final static String[] A_KO = new String[] { "\u00e0",
37: "\u00e1", "\u00e2", "\u00e3", "\u00e4", "\u00e5", "\u00e6" };
38: private final static String A_OK = "a";
39: private final static String[] E_KO = new String[] { "\u00e8",
40: "\u00e9", "\u00ea", "\u00eb" };
41: private final static String E_OK = "e";
42: private final static String[] C_KO = new String[] { "\u00e7" };
43: private final static String C_OK = "c";
44: private final static String[] I_KO = new String[] { "\u00ec",
45: "\u00ed", "\u00ee", "\u00ef" };
46: private final static String I_OK = "i";
47: private final static String[] O_KO = new String[] { "\u00f2",
48: "\u00f3", "\u00f4", "\u00f5", "\u00f6" };
49: private final static String O_OK = "o";
50: private final static String[] N_KO = new String[] { "\u00f1" };
51: private final static String N_OK = "n";
52: private final static String[] U_KO = new String[] { "\u00f9",
53: "\u00fa", "\u00fb", "\u00fc" };
54: private final static String U_OK = "u";
55:
56: public static String clarify(String input) {
57: String result = input.toLowerCase();
58:
59: // Manage A
60: for (int i = 0; i < A_KO.length; i++)
61: result = result.replaceAll(A_KO[i], A_OK);
62:
63: // Manage E
64: for (int i = 0; i < E_KO.length; i++)
65: result = result.replaceAll(E_KO[i], E_OK);
66:
67: // Manage C
68: for (int i = 0; i < C_KO.length; i++)
69: result = result.replaceAll(C_KO[i], C_OK);
70:
71: // Manage I
72: for (int i = 0; i < I_KO.length; i++)
73: result = result.replaceAll(I_KO[i], I_OK);
74:
75: // Manage O
76: for (int i = 0; i < O_KO.length; i++)
77: result = result.replaceAll(O_KO[i], O_OK);
78:
79: // Manage N
80: for (int i = 0; i < N_KO.length; i++)
81: result = result.replaceAll(N_KO[i], N_OK);
82:
83: // Manage U
84: for (int i = 0; i < U_KO.length; i++)
85: result = result.replaceAll(U_KO[i], U_OK);
86:
87: return result;
88: }
89: }
|