2 * Copyright (C) 2007 Universitat d'Alacant / Universidad de Alicante
3 * Author: Enrique Benimeli Bofarull
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 import dics
.elements
.dtd
.DictionaryElement
;
22 import dics
.elements
.dtd
.EElement
;
23 import dics
.elements
.dtd
.SElement
;
24 import dics
.elements
.utils
.DicSet
;
25 import dics
.elements
.utils
.SElementList
;
26 import dictools
.DicCross
;
27 import dictools
.DicTools
;
28 import dictools
.DictionaryReader
;
33 * @author Enrique Benimeli Bofarull
41 public static void main(final String
[] args
) {
43 // HOW TO READ A DICTIONARY
46 final DictionaryReader monAReader
= new DictionaryReader(
47 "dics/apertium-es-ca.ca.dix");
48 final DictionaryReader monCReader
= new DictionaryReader(
49 "dics/apertium-es-pt.pt.dix");
50 final DictionaryReader bilABReader
= new DictionaryReader(
51 "dics/apertium-es-ca.es-ca.dix");
52 final DictionaryReader bilBCReader
= new DictionaryReader(
53 "dics/apertium-es-pt.es-pt.dix");
56 final DictionaryElement monA
= monAReader
.readDic();
57 final DictionaryElement monC
= monCReader
.readDic();
58 final DictionaryElement bilAB
= bilABReader
.readDic();
59 final DictionaryElement bilBC
= bilBCReader
.readDic();
60 final DicSet dicSet
= new DicSet(monA
, bilAB
, monC
, bilBC
);
62 // HOW TO CROSS DICTIONARIES
63 final DicCross dc
= new DicCross();
64 final DictionaryElement
[] bils
= dc
.crossDictionaries(dicSet
);
65 final DictionaryElement bilACcrossed
= bils
[0];
67 // Morfological dictionaries (consistent with bilingual)
68 final DicSet solDicSet
= DicTools
.makeConsistentBilAndMonols(
69 bilACcrossed
, monA
, monC
);
70 final DictionaryElement monAcrossed
= solDicSet
.getMon1();
71 final DictionaryElement monCcrossed
= solDicSet
.getMon2();
73 // HOW TO PRINT TO FILE
74 bilACcrossed
.printXML("dix/apertium-ca-pt.ca-pt-crossed.dix");
76 // HOW TO REVERSE A DICTIONARY
77 bilACcrossed
.reverse();
78 bilACcrossed
.printXML("dix/apertium-pt-ca.pt-ca-crossed.dix");
80 monAcrossed
.printXML("dix/apertium-ca-pt.ca-crossed.dix");
81 monCcrossed
.printXML("dix/apertium-ca-pt.pt-crossed.dix");
83 // How to iterate over the elements in 'bilACcrossed'
85 for (final EElement e
: bilACcrossed
.getEntries()) {
86 // 'r' attribute in <e>
87 final String r
= e
.getRestriction();
89 System
.out
.println("R: " + r
);
92 // Left side (<l> tag)
93 System
.out
.print(e
.getValue("L") + " / ");
95 final SElementList sList
= e
.getSElements("L");
96 for (final SElement s
: sList
) {
99 System
.out
.println("");
101 // Right side (<r> tag)
102 System
.out
.print(e
.getValue("R") + " / ");
104 final SElementList sList2
= e
.getSElements("R");
105 for (final SElement s
: sList2
) {
108 System
.out
.println("\n");