| 12
 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
 
 |  
public  void ecrireAnn(Corpus corpus) throws IOException {
		// On crée un iterateur sur les documents du corpus
		Iterator iter = corpus.iterator();
		// Parcours de tous les documents du corpus
		while (iter.hasNext()) {
			Document currDoc = (Document) iter.next();
 
			String docXMLString = null;
			// Les annotations à conserver
			Set annotationsToWrite = new HashSet();
 
			// Seul l'AnnotationSet par défaut (unnamed) est utilisé ici
			AnnotationSet annotations = currDoc.getAnnotations();
			for (int i = 0; i < annotations.size(); i++) {
				Annotation annotation = annotations.get(i);
				// On ne conserve que les prénoms
				// (Lookup->majorType = prenoms
				if (annotation != null) {
					annotationsToWrite.add(annotation);
				}
			}
        docXMLString = currDoc.toXml(annotationsToWrite);
 
			// Création du XML avc les annotations récupérées
			//docXMLString = currDoc.toXml(annotationsToWrite);
            //String xmlOutput = DocumentStaxUtils.toXml(currDoc);
            FileWriter writer = new FileWriter("C:\\Documents and Settings\\Administrateur\\Bureau\\fichier.xml");
           //writer.write(xmlOutput, 0, xmlOutput.length());
            writer.write( docXMLString);
            writer.flush();
            writer.close();
	}} | 
Partager