File: Ambiguity.java

package info (click to toggle)
natbraille 2.0rc3-14
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,080 kB
  • sloc: java: 31,266; xml: 7,747; sh: 165; haskell: 50; makefile: 32
file content (86 lines) | stat: -rw-r--r-- 2,434 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Trace assistant
 * Copyright (C) 2008 Bruno Mascret
 * Contact: bmascret@free.fr
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package nat.transcodeur;

import java.util.ArrayList;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Représente une ambiguité
 * @author bruno
 *
 */
public class Ambiguity
{
	/** chaine de description de l'ambiguïté */
	private String description ="";
	/** liste des solutions possibles en braille*/
	private ArrayList<String> solutions = new ArrayList<String>();
	/** liste des descriptions des solutions */
	private ArrayList<String> descSolution = new ArrayList<String>();
	
	/**
     * @param ambXML le noeud ambiguité d'un fichier transcrit
     */
    public Ambiguity(Node ambXML)
    {
	    NodeList fils = ambXML.getChildNodes();
	    for(int i = 0; i< fils.getLength(); i++)
	    {
	    	Node f = fils.item(i);
	    	if (f.getNodeName().equals("description"))
	    	{
	    		description = f.getTextContent();
	    	}
	    	else if(f.getNodeName().equals("proposition"))
	    	{
	    		Node p = f.getChildNodes().item(0);
	    		Node d = f.getChildNodes().item(1);
	    		if(p.getNodeName().equals("desc"))
	    		{
	    			descSolution.add(p.getTextContent());
	    			solutions.add(d.getTextContent());
	    		}
	    		else
	    		{
	    			descSolution.add(d.getTextContent());
	    			solutions.add(p.getTextContent());
	    		}
	    	}
	    }
    }
    
    /**
     * Pour les tests
     * Affiche une ambiguité dans la console
     */
    public void afficheAmbiguity()
    {
    	System.out.println("Ambiguité:" + description + "\nPropositions:");
    	for(int i=0; i<solutions.size();i++)
    	{
    		System.out.println(" - "+descSolution.get(i));
    		System.out.println(" * "+solutions.get(i));
    	}
    }

}