Bonsoir à tous,
J'ai fait une méthode utilisant gate pour découper un document
en phrases et la sortie ça sera un fichier XML contenant le document
annoté par les phrases. voila la méthode utilsée
Le problème est que le fichier en sortie ne peut pas être affiché
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 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(); }}
même j'ai essayé avec une chaine vide et ça marche pas. L'erreur affiché
est comme suit
Si quelqu'un a une idée qu'il n'hésite pas de m'aider j'enai vraiment très
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2Le document XML doit contenir un élément de niveau supérieur. Erreur de traitement de la ressource file:///C:/Documents and...
besoin
Je vous attends.
Cordialement
Partager