Révision 3930

TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 3930)
42 42
	private KnowledgeRepository defaultKR;
43 43
	
44 44
	public AnnotationWriter(MainCorpus corpus) throws BackingStoreException {
45
		
45 46
		this.corpus = corpus;
46 47
		List<String> krnames = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus);
47 48
		if (krnames.size() == 0) {
......
280 281
	protected boolean writeAnnotationsInFile(File xmlFile, int text_start_position,
281 282
			ArrayList<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, File tmpXMLTXMDirectory, File previousXMLTXMDirectory) throws CqiClientException, IOException,
282 283
			CqiServerError, InvalidCqpIdException, XMLStreamException {
284
		
283 285
		Log.fine("Writing annotations for text " + xmlFile + " segment annotations=" + segmentAnnotations.size() + " token annotations=" + tokenAnnotations.size()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
284 286
		if (debug) System.out.println(segmentAnnotations);
285 287
		if (debug) System.out.println(tokenAnnotations);
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationInjector.java (revision 3930)
81 81
	 * @throws XMLStreamException
82 82
	 * @throws IOException
83 83
	 */
84
	public AnnotationInjector(File xmlFile, List<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, int corpus_start_position, boolean debug) throws IOException,
85
			XMLStreamException {
84
	public AnnotationInjector(File xmlFile, List<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, int corpus_start_position, boolean debug)
85
			throws IOException, XMLStreamException {
86 86
		super(xmlFile.toURI().toURL()); // init reader and writer
87 87
		
88 88
		this.user = System.getProperty("user.name"); //$NON-NLS-1$
89 89
		
90
		this.debug = debug;
90
		//this.debug = debug;
91 91
		this.xmlFile = xmlFile;
92 92
		this.n = 0;
93 93
		// println ""+records.size()+" lines to process..."
......
99 99
		annotationsToAddByEndPos = new HashMap<>();
100 100
		
101 101
		for (Annotation a : segmentAnnotations) {
102
			
102 103
			if (!annotationsToAddByStartPos.containsKey(a.getStart()))
103 104
				annotationsToAddByStartPos.put(a.getStart(), new ArrayList<Annotation>());
105
			
104 106
			if (!annotationsToAddByEndPos.containsKey(a.getEnd()))
105 107
				annotationsToAddByEndPos.put(a.getEnd(), new ArrayList<Annotation>());
106 108
			
......
111 113
		for (int i : annotationsToAddByStartPos.keySet()) {
112 114
			List<Annotation> a = annotationsToAddByStartPos.get(i);
113 115
			Collections.sort(a, new Comparator<Annotation>() { // reverse sort
114
				// annotation ->
115
				// write the
116
				// smaller in
117
				// the bigger
116
				// annotation -> write the smaller in the bigger
118 117
				
119 118
				@Override
120 119
				public int compare(Annotation arg0, Annotation arg1) {
......
125 124
		for (int i : annotationsToAddByEndPos.keySet()) {
126 125
			List<Annotation> a = annotationsToAddByEndPos.get(i);
127 126
			Collections.sort(a, new Comparator<Annotation>() { // reverse sort
128
				// annotation ->
129
				// write the
130
				// smaller in
131
				// the bigger
127
				// annotation -> write the smaller in the bigger
132 128
				
133 129
				@Override
134 130
				public int compare(Annotation arg0, Annotation arg1) {
......
169 165
		currentStartAnnotations = annotationsToAddByStartPos.get(position_counter);
170 166
		currentEndAnnotations = annotationsToAddByEndPos.get(position_counter);
171 167
		// System.out.println("A Starts: "+currentStartAnnotations+" "+currentEndAnnotations);
172
		if (debug) System.out.println("----- "+localname+"@"+position_counter+" START ANNOT = "+currentStartAnnotations);
168
		if (debug) System.out.println("----- "+localname+"@"+position_counter+" START ANNOT = "+currentStartAnnotations.size());
173 169
		if ("teiHeader".equals(localname)) { //$NON-NLS-1$
174 170
			super.processStartElement();
175 171
			goToEnd("teiHeader"); //$NON-NLS-1$ // skip teiHeader // will be closed in processEndElement()
......
314 310
				
315 311
				for (int i = 0; i < currentStartAnnotations.size(); i++) {
316 312
					Annotation a = currentStartAnnotations.get(i);
317
					if (debug)  System.out.println("=============== Start annot : "+a);
313
					// if (debug) System.out.println("=============== Start annot : "+a);
318 314
					if (a.getType().equals(localname)) { // force delete, will be  written in the "w"  case
319 315
						
320
						if (a.getStart() == start && a.getEnd() == end && a.getAnnotator().equals(s_author)) { // this is the right annotation to process
316
						if (a.getStart() == start && a.getEnd() == end) { // this is the right annotation to process
321 317
							// updated = true;
322 318
							// if (debug)
323 319
							// System.out.println(" found existing annotation "+a);
TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 3930)
47 47
	}
48 48
	
49 49
	public static AnnotationManager getAnnotationManager(CQPCorpus corpus) throws Exception {
50
		
50 51
		return getAnnotationManager(corpus.getMainCorpus());
51 52
	}
52 53
	
......
58 59
	 * @throws Exception
59 60
	 */
60 61
	public static AnnotationManager getAnnotationManager(MainCorpus corpus) throws Exception {
62
		
61 63
		AnnotationManager am = ams.get(corpus);
62 64
		if (am == null) {
63 65
			am = new AnnotationManager(corpus);
......
87 89
	 * @throws BackingStoreException
88 90
	 */
89 91
	public static KnowledgeRepository getKnowledgeRepository(CQPCorpus corpus, String name) throws BackingStoreException {
92
		
90 93
		return KnowledgeRepositoryManager.getKnowledgeRepository(name, corpus.getMainCorpus());
91 94
	}
92 95
	
......
97 100
	 * @return the KR configuration map
98 101
	 */
99 102
	public static HashMap<String, HashMap<String, ?>> getKnowledgeRepositoryConfiguration(String name, Element e) {
103
		
100 104
		HashMap<String, HashMap<String, ?>> repConfiguration = new HashMap<>();
101 105
		
102 106
		HashMap<String, String> access = new HashMap<>();

Formats disponibles : Unified diff