Revision 9

SRC/src/fr/triangle/hyperalign/kernel/DataManager.java (revision 9)
3 3
import java.io.BufferedOutputStream;
4 4
import java.io.BufferedReader;
5 5
import java.io.File;
6
import java.io.FileInputStream;
6 7
import java.io.FileNotFoundException;
7 8
import java.io.FileOutputStream;
8 9
import java.io.IOException;
......
20 21
import java.util.Iterator;
21 22
import java.util.LinkedHashMap;
22 23
import java.util.List;
24
import java.util.Properties;
23 25
import java.util.Set;
24 26
import java.util.StringTokenizer;
25 27
import java.util.TreeMap;
......
91 93
	private String userId;
92 94

  
93 95
	private DebugToFile debug;
96
	private Properties prop;
94 97
	
95 98
	public final static String SCRIPT_CORPUS_EXTRACTION = "faire une sélection du corpus";
96 99
	public final static String SCRIPT_REMOVE_ANNOTATION_ALONE = "enlever les annotations orphelines";
......
122 125
		Calendar calendar = Calendar.getInstance();
123 126
		String date = format.format(calendar.getTime());
124 127
		debug = new DebugToFile("Debug-"+date);
125
		//System.out.println("ANNOT MANAGER INITIALIZED!");
128
		debug.setStateDebug(true);
126 129
	}
127 130

  
128 131
	public DataManager () {
......
132 135
		equivalenceManager = new EquivalenceManager(this);
133 136
		dictionaryManager = new DictionaryManager(this);
134 137

  
135
		//System.out.println("ANNOT MANAGER INITIALIZED!");
138
		SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd");
139
		Calendar calendar = Calendar.getInstance();
140
		String date = format.format(calendar.getTime());
141
		debug = new DebugToFile("Debug-"+date);
142
		debug.setStateDebug(true);
136 143
	}
137 144

  
138 145
	public void setProjectDirectory(String nameDirectory){
......
148 155
	public String[] getProjectName(){
149 156
		if(nameDirectory!=null){
150 157
			int indx = nameDirectory.lastIndexOf("/");
151
			//System.out.println("getProjectName() --- NAME ["+nameDirectory+"]");
158
			//manager.writeToDebug("getProjectName() --- NAME ["+nameDirectory+"]");
152 159
			String fileDirectory = nameDirectory.substring(0,indx);
153 160
			String nameProjectFile = nameDirectory.substring(indx+1, nameDirectory.length());
154 161
			if(nameProjectFile.contains(".align")){
......
220 227
		return debug;
221 228
	}
222 229
	
230
	public void writeToDebug(String in){
231
		if(debug.isDebug()){
232
			debug.addToFileForDebug(in);
233
		}
234
	}
235
	
236
	/*
237
	 * http://www.mkyong.com/java/java-properties-file-examples/
238
	 */
239
	public void setProperties(){
240
		prop = new Properties();
241
    	try {
242
    		//set the properties value
243
    		prop.setProperty("debug", "true");
244
    		//save properties to project root folder
245
    		prop.store(new FileOutputStream("config.properties"), null);
246
    	} catch (IOException ex) {
247
    		ex.printStackTrace();
248
        }
249
	}
250
	
251
	public void loadProperties(){
252
		prop = new Properties();
253
    	try {
254
               //load a properties file
255
    			prop.load(new FileInputStream("config.properties"));
256
    			//get the property value and print it out
257
    			//manager.writeToDebug(prop.getProperty("debug"));
258
    	} catch (IOException ex) {
259
    		ex.printStackTrace();
260
        }	
261
	}
262
	
263
	
223 264
	public String[] getCategories(String lang){
224 265
		if(corpusManager!=null){
225 266
			boolean isTokenizedByTreeTagger = corpusManager.getCorpus().getParameters().isOption(ParallelCorpusParameters.CORPUS_TREETAGGER);
......
238 279

  
239 280
	public Vector<HyperalignText> initCorpusManager(URL urlCorpusData, String name, boolean isToIndex, boolean isParallelCorpus, 
240 281
			boolean isHyperalignModel, boolean taggedByTT, HashMap<HyperalignText, URL> textsToParallelize){
241
		System.out.println("DataManager.initCorpusManager() - NEW CORPUS - nbTexts to align ["+textsToParallelize.size()+"]");
282
		this.writeToDebug("DataManager.initCorpusManager() - NEW CORPUS - nbTexts to align ["+textsToParallelize.size()+"]");
242 283
		HashMap<String, Parameter> parameters = new HashMap<String, Parameter>();
243 284
		parameters.put(ParallelCorpusParameters.CORPUS_ANNOTATED, new Parameter(ParallelCorpusParameters.CORPUS_ANNOTATED,false));
244 285
		parameters.put(ParallelCorpusParameters.CORPUS_INDEX, new Parameter(ParallelCorpusParameters.CORPUS_INDEX,isToIndex));
......
255 296

  
256 297
	public Vector<HyperalignText> initCorpusManager(URL urlCorpusData, String name, boolean isToIndex, boolean isParallelCorpus, 
257 298
			boolean isHyperalignModel, boolean taggedByTT, String idPath, String langPath, String textPathName){
258
		//System.out.println("DataManager.initCorpusManager() - CORPUS - path["+idPath+"]");
299
		//manager.writeToDebug("DataManager.initCorpusManager() - CORPUS - path["+idPath+"]");
259 300
		HashMap<String, Parameter> parameters = new HashMap<String, Parameter>();
260 301
		parameters.put(ParallelCorpusParameters.CORPUS_ANNOTATED, new Parameter(ParallelCorpusParameters.CORPUS_ANNOTATED,false));
261 302
		parameters.put(ParallelCorpusParameters.CORPUS_INDEX, new Parameter(ParallelCorpusParameters.CORPUS_INDEX,isToIndex));
......
440 481

  
441 482
		public void searchCooccurrence(Dictionary lang, HyperalignText text, int window){
442 483
			Vector<String> lexicalList = null;
443
			System.out.println("NeighbourManager.searchCooccurrence() in "+lang+" for "+text);
484
			manager.writeToDebug("NeighbourManager.searchCooccurrence() in "+lang+" for "+text);
444 485

  
445 486
			//File f = new File("dict_temp", "LexicalEntries_"+text.getId()+".csv");
446 487
			//if(!f.exists()){
......
477 518
						String w1 = lexicalList.get(i);
478 519
						///WORD 
479 520
						out.write(w1+";");
480
						System.out.println("w1 = "+w1);
521
						manager.writeToDebug("w1 = "+w1);
481 522

  
482 523
						for (int j = 0; j < duplicateList.size(); j++) {//duplicateList.size()
483 524
							String w2 = duplicateList.get(j);
484 525
							int coocsNbForW1 = IndexManager.getInstance(manager.getAnnotationManager()).getCooccurrence(w1, w2, window);
485 526
							if(coocsNbForW1!=0){
486
								System.out.println("w2 = "+w2+"; "+coocsNbForW1);
527
								manager.writeToDebug("w2 = "+w2+"; "+coocsNbForW1);
487 528
							}
488 529

  
489 530
							if(j==duplicateList.size()-1){
......
494 535
							}
495 536

  
496 537
						}
497
						System.out.println("============================END =================== w1 = "+w1);
538
						manager.writeToDebug("============================END =================== w1 = "+w1);
498 539
					}
499 540
					out.flush();
500 541
					out.close();
......
542 583
			}
543 584
			for (int i = 0; i < query.length; i++) {
544 585
				String word = query[i];
545
				Vector<OccurrenceSet> occsResults = searcher.searchWord(text, word, null);
586
				Vector<OccurrenceSet> occsResults = searcher.searchWord(text, word, null, new Vector<OccurrenceSet>());
546 587
				int distance = dist;
547 588
				int level = 1;
548 589
				NeighbourElement neighbour = new NeighbourElement(word, occsResults, isRoot, rightElement, level);
......
569 610

  
570 611
		private void findNextNeighbour(boolean[] options, int dist, HyperalignText text, NeighbourElement neighbourParent, boolean rightElement, int level){
571 612
			HashMap<String, Vector<OccurrenceSet>> neighbours = neighbourParent.getNeighboursOcc();
572
			//System.out.println("NeighbourManager.findNextNeighbour() DIST /"+dist+"/ for "+neighbour.getName()+" and "+neighbours.size()+" neighbours");
613
			//manager.writeToDebug("NeighbourManager.findNextNeighbour() DIST /"+dist+"/ for "+neighbour.getName()+" and "+neighbours.size()+" neighbours");
573 614
			HashMap<NeighbourElement, Integer> nextNeighbours = new HashMap<NeighbourElement, Integer>();
574 615

  
575 616
			Set keys = neighbours.keySet();
......
578 619
				String nextNeighbour = (String) it.next();
579 620
				Vector<OccurrenceSet> occsNextResults = neighbours.get(nextNeighbour);
580 621

  
581
				//System.out.println("OccurrenceSet.findNextNeighbour() VECT OCCS ? "+occsNextResults.size());
622
				//manager.writeToDebug("OccurrenceSet.findNextNeighbour() VECT OCCS ? "+occsNextResults.size());
582 623
				NeighbourElement neighbourOfNeighbour = new NeighbourElement(neighbourParent, nextNeighbour,occsNextResults, false, rightElement, level);
583 624
				addToNeighboursByName(neighbourParent);
584 625
				nextNeighbours.put(neighbourOfNeighbour, occsNextResults.size());
......
627 668
						occsByTermino.put(idEquOcc, occs.get(idEquOcc));
628 669
					}else {
629 670

  
630
						System.out.println("AnnotationManager.setEquivalences() - IS THERE AN OVERLAP IN EQUIVALENCES ["+idEquOcc+"] in "+dico.getName());
671
						manager.writeToDebug("AnnotationManager.setEquivalences() - IS THERE AN OVERLAP IN EQUIVALENCES ["+idEquOcc+"] in "+dico.getName());
631 672
					}
632 673
				}
633 674
			}
......
664 705
					Division div = newRoot.getDivision(text);
665 706
					Vector<String> forms = new Vector<String>();
666 707
					forms.add(form);
667
					Vector<OccurrenceSet> occs = IndexManager.getInstance(this).buildOccurrences(div, forms, -1, dico, null, null);
708
					Vector<OccurrenceSet> occs = IndexManager.getInstance(this).buildOccurrences(div, forms, -1, dico, null, null, null);
668 709
					occsToReturn = merge(occs, occsToReturn);
669 710
					return findOccurrences(text, newRoot, form, dico, occsToReturn);
670 711
				}
......
684 725
						Division div = newRoot.getDivision(text);
685 726
						Vector<String> forms = new Vector<String>();
686 727
						forms.add(form);
687
						Vector<OccurrenceSet> occs = IndexManager.getInstance(this).buildOccurrences(div, forms, -1, dico, null, null);
728
						Vector<OccurrenceSet> occs = IndexManager.getInstance(this).buildOccurrences(div, forms, -1, dico, null, null, null);
688 729
						occsToReturn = merge(occs, occsToReturn);
689 730
						return findOccurrences(text, newRoot, form, dico, occsToReturn);
690 731
					}
......
701 742
		 * @param div is the division to look into for annotations
702 743
		 * @return a group of OccurrenceSet that have the corresponding string, in the corresponding division 
703 744
		 */
704
		public Vector<OccurrenceSet> findOccurrences(String nameOcc, Division div, int start, 
705
				Dictionary dico, String idLemme){
706
			boolean found = false;
707
			Vector<OccurrenceSet> annotsToReturn = new Vector<OccurrenceSet>();
708
			String idAnnot = DatabaseManager.getAnnotation(nameOcc, start, div);
709
			if(idAnnot!=null){
710
				OccurrenceSet occ = annots.get(idAnnot);
711
				annotsToReturn.add(occ);
712
				found = true;
745
		public Vector<OccurrenceSet> findOccurrences(String nameOcc, Division div, int start, Dictionary dico, String idLemme, Vector<OccurrenceSet> annotsToReturn){
746
			//boolean found = false;
747
			ArrayList<String> idsAnnot = DatabaseManager.getAnnotations(nameOcc, div);
748
			if(idsAnnot!=null){
749
				for(String id : idsAnnot){
750
					OccurrenceSet occ = annots.get(id);
751
					if(occ!=null){
752
						if(!annotsToReturn.contains(occ)){
753
							annotsToReturn.add(occ);
754
						}
755
					}
756
				}
757
				
713 758
			}
714
			if(!found){
715
				//System.out.println("AnnotationManager.findOccurrences() AT "+div.computeName()+" WITH ID LEMME ? "+idLemme);
759
			//if(!found){
760
				//manager.writeToDebug("AnnotationManager.findOccurrences() AT "+div.computeName()+" WITH ID LEMME ? "+idLemme);
716 761

  
717 762
				if(idLemme==null){
718 763
					Vector<String> forms = new Vector<String>();
719 764
					forms.add(nameOcc);
720
					annotsToReturn = IndexManager.getInstance(this).buildOccurrences(div, forms, start, dico, null, null);
765
					annotsToReturn = IndexManager.getInstance(this).buildOccurrences(div, forms, start, dico, null, null, annotsToReturn);
721 766
				}else {
722 767
					annotsToReturn = IndexManager.getInstance(this).buildOccurrencesWithLemma(div, dico, idLemme);
723 768
				}
724
			}
725
			//System.out.println("AnnotationManager.findOccurrences() : "+annotsToReturn.size()+" OCCS");
769
			//}
770
			//manager.writeToDebug("AnnotationManager.findOccurrences() : "+annotsToReturn.size()+" OCCS");
726 771
			return annotsToReturn;
727 772
		}
728 773

  
......
731 776
			for(int k = 0 ; k < texts.size() ; ++k){
732 777
				HyperalignText text = texts.get(k);
733 778
				HashMap<String, HashMap<Division, Integer>> occurrences = text.getOccurrencesByDivision();
734
				System.out.println("AnnotationManager.modifyLemmeReferenceFromOccurrences() - [" + word+"]");
779
				manager.writeToDebug("AnnotationManager.modifyLemmeReferenceFromOccurrences() - [" + word+"]");
735 780
				Set<String> keys = occurrences.keySet();
736 781
				Iterator<String> it = keys.iterator();
737 782
				while(it.hasNext()){
......
741 786

  
742 787
					boolean found = matcher.find();
743 788
					if(found){
744
						System.out.println("\tFound a match: " + matcher.group()+" for KEY ["+key+"]");
789
						manager.writeToDebug("\tFound a match: " + matcher.group()+" for KEY ["+key+"]");
745 790
						HashMap<Division, Integer> occurrencesFound = occurrences.get(key);
746 791
						Set<Division> keyDiv = occurrencesFound.keySet();
747 792
						Iterator<Division> it2 = keyDiv.iterator();
......
759 804
			for(int k = 0 ; k < texts.size() ; ++k){
760 805
				HyperalignText text = texts.get(k);
761 806
				HashMap<String, HashMap<Division, Integer>> occurrences = text.getOccurrencesByDivision();
762
				System.out.println("AnnotationManager.modifyLemmeReferenceFromOccurrences() - [" + word+"]");
807
				manager.writeToDebug("AnnotationManager.modifyLemmeReferenceFromOccurrences() - [" + word+"]");
763 808
				Set<String> keys = occurrences.keySet();
764 809
				Iterator<String> it = keys.iterator();
765 810
				while(it.hasNext()){
......
769 814

  
770 815
					boolean found = matcher.find();
771 816
					if(found){
772
						System.out.println("Found a match: " + matcher.group()+" for KEY ["+key+"]");
817
						manager.writeToDebug("Found a match: " + matcher.group()+" for KEY ["+key+"]");
773 818
						HashMap<Division, Integer> occurrencesFound = occurrences.get(key);
774 819
						Set<Division> keyDiv = occurrencesFound.keySet();
775 820
						Iterator<Division> it2 = keyDiv.iterator();
......
805 850

  
806 851
				for(Vector<OccurrenceSet> vals : homonymes.values()){
807 852
					if(vals.size()>1){
808
						System.out.println("findHomonymes in DIV["+div.getXmlId()+"] : "+vals.size());
853
						manager.writeToDebug("findHomonymes in DIV["+div.getXmlId()+"] : "+vals.size());
809 854
						for (int i = 0; i < vals.size(); i++) {
810 855
							OccurrenceSet val = vals.get(i);
811 856
							EquivalenceElement equi = val.getEquivalence();
......
818 863
					}
819 864
				}
820 865
			}*/
821
			System.out.println("AnnotationManager.findHomonymesInAnnotations() - FONCTION TO REDO !!");
866
			manager.writeToDebug("AnnotationManager.findHomonymesInAnnotations() - FONCTION TO REDO !!");
822 867
			return equivalences;
823 868
		}
824 869

  
......
830 875
			for(String id : ids){
831 876
				annotsToReturn.add(annots.get(id));
832 877
			}
833
			/*System.out.println("AnnotationManager.findAnnotations() FOR "+occSet.getValue());
878
			/*manager.writeToDebug("AnnotationManager.findAnnotations() FOR "+occSet.getValue());
834 879
			Division div = occSet.getDivision();
835 880

  
836 881
			if(div!=null){
......
845 890
						for(int i = 0 ; i < annotationsVect.size() ; ++i ){
846 891
							OccurrenceSet annotation = annotationsVect.get(i);
847 892
							if(containsOccurrence(dico, annotation, occSet)){
848
								System.out.println("AnnotationManager.findAnnotations() "+annotation.getValue());
893
								manager.writeToDebug("AnnotationManager.findAnnotations() "+annotation.getValue());
849 894
								annotsToReturn.add(annotation);
850 895
							}
851 896
						}
......
868 913
		public void modifyAnnotation(OccurrenceSet occ, int newDeb, int newEnd){
869 914
			if(annots.containsKey(occ.getIdentification())){
870 915
				DatabaseManager.updateAnnotation(occ, newDeb, newEnd);
871
				//System.out.println("AnnotationManager.modifyAnnotation() - "+occ.getIdentification()+" /"+occ.getValue()+"/ ["+occ.getIndexes()[0]+"-"+occ.getIndexes()[1]+"] with NEW INDEXES ["+newDeb+"-"+newEnd+"] ");
916
				//manager.writeToDebug("AnnotationManager.modifyAnnotation() - "+occ.getIdentification()+" /"+occ.getValue()+"/ ["+occ.getIndexes()[0]+"-"+occ.getIndexes()[1]+"] with NEW INDEXES ["+newDeb+"-"+newEnd+"] ");
872 917

  
873 918
				String str = DatabaseManager.getAnnotation(occ.getValue(), newDeb, occ.getDivision());
874 919
				if(str==null){
875
					System.out.println("\tMODIF HAS GONE WRONG !!!");
920
					manager.writeToDebug("\tMODIF HAS GONE WRONG !!!");
876 921
					DatabaseManager.getAnnotation(occ.getIdentification());
877 922
				}
878 923
			}
......
880 925

  
881 926
		public void modifyAnnotation(OccurrenceSet occ, String idLemma){
882 927
			if(annots.containsKey(occ.getIdentification())){
883
				System.out.println("AnnotationManager.modifyAnnotation() "+occ.getIdentification()+" /"+occ.getValue()+"/ - modif LEMMA !! ");
928
				manager.writeToDebug("AnnotationManager.modifyAnnotation() "+occ.getIdentification()+" /"+occ.getValue()+"/ - modif LEMMA !! ");
884 929
				DatabaseManager.updateAnnotation(occ, idLemma);
885 930
				occ.setLemmaId(idLemma)	;	
886 931
				CorpusWriter writer = new CorpusWriter(manager.getCorpusManager().getCorpus());
......
890 935

  
891 936
		public OccurrenceSet checkAnnotation(int debIndex, String sequence, Division div){
892 937
			if(!sequence.equals(" ")){
893
				//System.out.println("AnnotationManager.checkAnnotation() - "+sequence+" @ "+debIndex);
938
				//manager.writeToDebug("AnnotationManager.checkAnnotation() - "+sequence+" @ "+debIndex);
894 939
			}
895 940
			Vector<OccurrenceSet> annots = getAnnotations(debIndex, sequence, div);
896 941
			if(annots.size()>0){
......
901 946
		}
902 947

  
903 948
		public OccurrenceSet isAnnotation(String sequence, int debIndex, Division div){
904
			//System.out.println("AnnotationManager.isAnnotation() - "+sequence+" @ "+debIndex +" in "+div.getXmlId());
949
			//manager.writeToDebug("AnnotationManager.isAnnotation() - "+sequence+" @ "+debIndex +" in "+div.getXmlId());
905 950
			OccurrenceSet annotToReturn = null;
906 951
			String idAnnot = DatabaseManager.getAnnotation(sequence, debIndex, div);
907 952
			if(idAnnot!=null){
......
947 992
					int debIndex = occSet.getIndexes()[0]+occSet.getValue().indexOf(str);
948 993
					OccurrenceSet annot = isAnnotation(str, debIndex, occSet.getDivision());
949 994
					if(annot!=null){
950
						System.out.println("\t/"+str+"/ is also an Annotation ? ("+annot+") start at "+debIndex+" / Is in EQUI ?");
995
						manager.writeToDebug("\t/"+str+"/ is also an Annotation ? ("+annot+") start at "+debIndex+" / Is in EQUI ?");
951 996
						if(annot.getEquivalence()!=null){
952 997
							return annot;
953 998
						}
......
983 1028
					if(annots.size()>0){
984 1029
						for (int j = 0; j < annots.size(); j++) {
985 1030
							OccurrenceSet annot = annots.get(j);
986
							System.out.println("\t/"+str+"/ is also an Annotation ? ("+annot+") start at "+debIndex+" / Is in EQUI ?");
1031
							manager.writeToDebug("\t/"+str+"/ is also an Annotation ? ("+annot+") start at "+debIndex+" / Is in EQUI ?");
987 1032
							if(annot!=occSet){
988 1033
								if(annot.getEquivalence()!=null){
989 1034
									return annot;
......
1001 1046
			if(occs!=null){
1002 1047
				occToReturn = new OccurrenceSet(occs, selection, "Annot_"+nbAnnots, div, indexes);
1003 1048
				//Test.insertOccurrence(occToReturn);
1004
				System.out.println("AnnotationManager.createAnnotation() [1] - "+occToReturn+" ("+occToReturn.getIdentification()+") starts at /"+occToReturn.getIndexes()[0]+"/ and ends at /"+occToReturn.getIndexes()[1]+"/");
1049
				manager.writeToDebug("AnnotationManager.createAnnotation() [1] - "+occToReturn+" ("+occToReturn.getIdentification()+") starts at /"+occToReturn.getIndexes()[0]+"/ and ends at /"+occToReturn.getIndexes()[1]+"/");
1005 1050
				++nbAnnots;
1006 1051
			}
1007 1052
			return occToReturn;
......
1014 1059
				if(occ!=null){
1015 1060
					++nbAnnots;
1016 1061
					occToReturn = new OccurrenceSet(occ, div, indexes, order, isPonctuation, isIndexed, lemmaId, pos, "Annot_"+nbAnnots);
1017
					System.out.println("AnnotationManager.createOccurrence() [2] - "+occToReturn+" LEMMA : "+lemmaId+" ("+occToReturn.getIdentification()+") starts at /"+occToReturn.getIndexes()[0]+"/ and ends at /"+occToReturn.getIndexes()[1]+"/");
1062
					manager.writeToDebug("AnnotationManager.createOccurrence() [2] - "+occToReturn+" LEMMA : "+lemmaId+" ("+occToReturn.getIdentification()+") starts at /"+occToReturn.getIndexes()[0]+"/ and ends at /"+occToReturn.getIndexes()[1]+"/");
1018 1063
					ProjectWriter writer = new ProjectWriter(manager);
1019 1064
					writer.modifyNbAnnotations(nbAnnots);
1020 1065
				}
......
1026 1071
				String lemmaId, String pos, int order, String id){
1027 1072
			OccurrenceSet occToReturn = isAnnotation(occ, indexes[0], div);
1028 1073
			if(occToReturn==null){
1074
				
1029 1075
				if(occ!=null){
1030 1076
					occToReturn = new OccurrenceSet(occ, div, indexes, order, isPonctuation, isIndexed, lemmaId, pos, id);
1031 1077
					//Test.insertOccurrence(occToReturn);
1032
					System.out.println("AnnotationManager.createOccurrence() [3] - "+occToReturn+" | LEMMA : "+lemmaId+" ("+occToReturn.getIdentification()+") starts at /"+occToReturn.getIndexes()[0]+"/ and ends at /"+occToReturn.getIndexes()[1]+"/");
1078
					manager.writeToDebug("AnnotationManager.createOccurrence() [3] - "+occToReturn+" | LEMMA : "+lemmaId+" ("+occToReturn.getIdentification()+") starts at /"+occToReturn.getIndexes()[0]+"/ and ends at /"+occToReturn.getIndexes()[1]+"/");
1033 1079
				}
1034 1080
			}
1035 1081
			return occToReturn;
......
1060 1106
						}
1061 1107
					}else {
1062 1108
						//WRITE ALSO IN FILE DICTIONARY and ADD ATTRIBUTE
1063
						System.out.println("AnnotationManager.addAnnotation() - MUST CREATE LEMME AND FORM for "+annotation.getIdentification());
1109
						manager.writeToDebug("AnnotationManager.addAnnotation() - MUST CREATE LEMME AND FORM for "+annotation.getIdentification());
1064 1110
						DictionaryElement lemme = dictionaryManager.addLemmeAndForm(dico, annotation.getValue(), annotation.getValue(), annotation, annotation.getDivision().getText(), "", annotation.getIndexes(),"");
1065 1111
						annotation.setLemmaId(lemme.getId());
1066 1112
						dictionaryManager.modifyLemme(lemme);
......
1069 1115
			}
1070 1116
			////////////////////////////////////////////
1071 1117

  
1072
			System.out.println("AnnotationManager.addAnnotation() "+annotation.getIdentification()+" "+annotation.getValue()+" ["+debIndex+"-"+endIndex+"] in DIV "+annotation.getDivision().getXmlId());
1118
			manager.writeToDebug("AnnotationManager.addAnnotation() "+annotation.getIdentification()+" "+annotation.getValue()+" ["+debIndex+"-"+endIndex+"] in DIV "+annotation.getDivision().getXmlId());
1073 1119

  
1074 1120
			if(annotation.getOccurrences()!=null){
1075 1121
				removeOverlap(annotation, debIndex, endIndex);
......
1100 1146
		private void removeOverlap(OccurrenceSet annot, int debIndex, int endIndex){
1101 1147
			ArrayList<String> overlaps = DatabaseManager.isOverlap(annot, debIndex, endIndex);
1102 1148
			if(overlaps.size()!=0){
1103
				System.out.println("Annotation "+annot.getIdentification()+" has overlapes : "+overlaps.size());
1149
				manager.writeToDebug("Annotation "+annot.getIdentification()+" has overlapes : "+overlaps.size());
1104 1150
			}
1105 1151
			for(String overlap : overlaps){
1106
				System.out.println("AnnotationManager.removeOverlap ["+overlap+"]");
1152
				manager.writeToDebug("AnnotationManager.removeOverlap ["+overlap+"]");
1107 1153
				removeAnnotationFromOverlap(annots.get(overlap));
1108 1154
			}
1109 1155
		}
......
1120 1166
		private OccurrenceSet isOverlap(OccurrenceSet annot, int debIndex, int endIndex){
1121 1167
			ArrayList<String> overlaps = DatabaseManager.isOverlap(annot, debIndex, endIndex);
1122 1168
			if(overlaps.size()>0){
1123
				System.out.println("NB OVERLAPS : "+overlaps.size());
1169
				manager.writeToDebug("NB OVERLAPS : "+overlaps.size());
1124 1170
				return annots.get(overlaps.get(0));
1125 1171

  
1126 1172
			}else {
1127
				System.out.println("NO OVERLAPS !");
1173
				manager.writeToDebug("NO OVERLAPS !");
1128 1174
				return null;
1129 1175
			}
1130 1176
		}
......
1132 1178

  
1133 1179

  
1134 1180
		public void removeAnnotation(OccurrenceSet occ) {
1135
			System.out.println("AnnotationManager.removeAnnotation() - "+occ.getIdentification());
1181
			manager.writeToDebug("AnnotationManager.removeAnnotation() - "+occ.getIdentification());
1136 1182
			DatabaseManager.deleteAnnotation(occ.getIdentification());
1137 1183
			if(annots.containsKey(occ.getIdentification())){
1138 1184
				//OccurrenceSet annot = annots.get(occ.getIdentification());
......
1163 1209

  
1164 1210

  
1165 1211
		public void moveAnnotations(Division div, int pos, int newPos){
1166
			System.out.println("AnnotationManager.moveAnnotations() - from deb index ="+pos+" | with "+newPos+" added");
1212
			manager.writeToDebug("AnnotationManager.moveAnnotations() - from deb index ="+pos+" | with "+newPos+" added");
1167 1213
			//HashMap<String, String[]> ids = DatabaseManager.moveAnnotations(div, pos, newPos);
1168 1214
			HashMap<Integer, Vector<OccurrenceSet>> annots = getAnnotations(div);
1169 1215
			for(Integer integ : annots.keySet()){
......
1235 1281
						occs.add(annot);
1236 1282
						annotations.put(deb, occs);
1237 1283
					}
1238
					//System.out.println("\t\t------------ ANNOT in ["+div.getXmlId()+"] - "+annot.getIdentification()+" /"+annot.getIndexes()[0]+"-"+annot.getIndexes()[1]+"/");
1284
					//manager.writeToDebug("\t\t------------ ANNOT in ["+div.getXmlId()+"] - "+annot.getIdentification()+" /"+annot.getIndexes()[0]+"-"+annot.getIndexes()[1]+"/");
1239 1285

  
1240 1286
				}else {
1241
					System.out.println("AnnotationManager.getAnnotations() -  /"+id+"/ is INEXISTENT in annots but EXISTENT in db !");
1287
					manager.writeToDebug("AnnotationManager.getAnnotations() -  /"+id+"/ is INEXISTENT in annots but EXISTENT in db !");
1242 1288
					Dictionary dico = manager.getDictionaryManager().getDictionary(div.getText().getMainLang());
1243 1289
					OccurrenceSet occSet = DatabaseManager.getAnnotationOccurrence(this, dico, div, id);
1244 1290
					if(occSet!=null){
......
1256 1302
							annotations.put(deb, occs);
1257 1303
						}
1258 1304
					}else {
1259
						System.out.println("AnnotationManager.getAnnotations() - CANNOT GET OCCURRENCE FROM /"+id+"/ in DB");	
1305
						manager.writeToDebug("AnnotationManager.getAnnotations() - CANNOT GET OCCURRENCE FROM /"+id+"/ in DB");	
1260 1306
					}
1261 1307
				}
1262 1308
			}
......
1266 1312

  
1267 1313
		public void removeAnnotations(Division div, int deb, int end){
1268 1314
			ArrayList<String> ids = DatabaseManager.getAnnotations(div, deb, end);
1269
			System.out.println("AnnotationManager.removeAnnotations BTW ["+deb+"-"+end+"] => Nb annots ? "+ids.size());
1315
			manager.writeToDebug("AnnotationManager.removeAnnotations BTW ["+deb+"-"+end+"] => Nb annots ? "+ids.size());
1270 1316
			/*if(ids.size()==0){
1271
				System.out.println("\t PROBLEM - NO ANNOTS BTW ["+deb+"-"+end+"] for DIV "+div.getXmlId());
1317
				manager.writeToDebug("\t PROBLEM - NO ANNOTS BTW ["+deb+"-"+end+"] for DIV "+div.getXmlId());
1272 1318
			}*/
1273 1319
			for(String id : ids){
1274 1320
				if(annots.containsKey(id)){
......
1324 1370
				newTerminology = new Terminology(null, lang, manager);
1325 1371
				//ADD TO THE TEXT/TERMINO MAP without any texts
1326 1372
				textsByTerminology.put(newTerminology, new Vector<HyperalignText>());
1327
				System.out.println("TerminologyManager.createTerminology("+newTerminology.getName()+")");
1373
				manager.writeToDebug("TerminologyManager.createTerminology("+newTerminology.getName()+")");
1328 1374
				terminos[terminoDatas.length]= newTerminology;
1329 1375
				terminoDatas = terminos;
1330 1376
			}			
......
1341 1387
			for (int i = 0; i < terminos.size(); i++) {
1342 1388
				Terminology termino = terminos.get(i);
1343 1389
				text.addTerminology(termino);
1344
				System.out.println("TerminologyManager.addTerminologiesToText() T."+termino.getName()+" added to "+text.getName());
1390
				manager.writeToDebug("TerminologyManager.addTerminologiesToText() T."+termino.getName()+" added to "+text.getName());
1345 1391
				Vector<HyperalignText> textsForTermino = textsByTerminology.get(termino);
1346 1392
				if(!textsForTermino.contains(text)){
1347 1393
					textsForTermino.add(text);
......
1360 1406
				texts.add(text);
1361 1407
				textsByTerminology.put(terminology, texts);
1362 1408
			}
1363
			System.out.println("		 => TerminologyManager.addTextToTerminology() -  TEXT is "+text.getName()+" /// ADD termino ["+terminology.getName()+"]");
1409
			manager.writeToDebug("		 => TerminologyManager.addTextToTerminology() -  TEXT is "+text.getName()+" /// ADD termino ["+terminology.getName()+"]");
1364 1410

  
1365 1411
		}
1366 1412

  
......
1406 1452
				TerminologyElement occEl = checkOccurrence(occurrenceSet, term, occurrenceSet.getIndexes());
1407 1453
				if(occEl==null){					
1408 1454
					int nbOcc = termino.getNbOccs();
1409
					//System.out.println("TerminologyManager.addOcc() [1] "+"O_"+nbOcc+" T="+term);
1455
					//manager.writeToDebug("TerminologyManager.addOcc() [1] "+"O_"+nbOcc+" T="+term);
1410 1456
					occEl = new TerminologyElement (term, Terminology.TERMINOLOGY_OCC, "O_"+nbOcc, "", occurrenceSet);
1411 1457
					++nbOcc;
1412 1458
					termino.setNbOccs(nbOcc);
......
1415 1461
				return occEl;
1416 1462
			}
1417 1463
			else {
1418
				System.out.println("TerminologyManager.addOcc => term est NULL, pas d'ajout de occurrence !");
1464
				manager.writeToDebug("TerminologyManager.addOcc => term est NULL, pas d'ajout de occurrence !");
1419 1465
			}
1420 1466
			return null;
1421 1467
		}
......
1424 1470
			if(term!=null){
1425 1471
				Terminology termino = term.getTerminology();
1426 1472
				String loc = occSet.getLocalisation();
1427
				//System.out.println("TerminologyManager.addOcc() [1] => "+loc+" id:"+idOcc);
1473
				//manager.writeToDebug("TerminologyManager.addOcc() [1] => "+loc+" id:"+idOcc);
1428 1474

  
1429 1475
				TerminologyElement occEl = termino.checkElementAsChild(loc, term);
1430 1476
				if(occEl==null){
......
1451 1497
				return occEl;
1452 1498
			}
1453 1499
			else {
1454
				System.out.println("TerminologyManager.addOcc => term est NULL, pas d'ajout de occurrence !");
1500
				manager.writeToDebug("TerminologyManager.addOcc => term est NULL, pas d'ajout de occurrence !");
1455 1501
			}
1456 1502
			return null;
1457 1503
		}
1458 1504

  
1459 1505
		public TerminologyElement addTermToConcept(TerminologyElement term, TerminologyElement concept){
1460
			//System.out.println("TerminologyManager.addTerm() [3]");
1506
			//manager.writeToDebug("TerminologyManager.addTerm() [3]");
1461 1507
			boolean found = false;
1462 1508
			TerminologyElement newTerm = null;
1463 1509
			if(concept!=null){
......
1479 1525
					}
1480 1526
				}
1481 1527
				if(!found){
1482
					System.out.println("TerminologyManager - add as new term");
1528
					manager.writeToDebug("TerminologyManager - add as new term");
1483 1529
					concept.addChild(term);
1484 1530
					term.setParent(concept);
1485 1531
					term.setCategory(concept.getCategory());	
1486 1532
					termino.setNewlyAddedElement(term);
1487 1533
				}else {
1488
					System.out.println("TerminologyManager - no new term, just add occurrences");
1534
					manager.writeToDebug("TerminologyManager - no new term, just add occurrences");
1489 1535
					termino.setNewlyAddedElement(newTerm);
1490 1536
				}
1491 1537

  
1492 1538
				return term;
1493 1539
			}
1494 1540
			else {
1495
				System.out.println("TerminologyManager.addTerm => concept est NULL, pas d'ajout de terme !");
1541
				manager.writeToDebug("TerminologyManager.addTerm => concept est NULL, pas d'ajout de terme !");
1496 1542
			}
1497 1543
			return null;
1498 1544
		}
......
1523 1569
							category/*, ancestors, descendants*/, definition);
1524 1570
					termino.setNewlyAddedElement(concept);
1525 1571
					termino.setNbConcepts(++nbConcept);
1526
					//System.out.println(termino.getRoot().getName()+" - ADD CONCEPT [1] => "+concept.getName()+" with id #"+ concept.getId()+" / both terms ? ["+newConcept+"/"+newTerm+"]");
1572
					//manager.writeToDebug(termino.getRoot().getName()+" - ADD CONCEPT [1] => "+concept.getName()+" with id #"+ concept.getId()+" / both terms ? ["+newConcept+"/"+newTerm+"]");
1527 1573
				}
1528 1574

  
1529 1575

  
......
1535 1581
				return concept;
1536 1582
			}
1537 1583
			else {
1538
				System.out.println("TerminologyManager.addConcept => terminology racine est NULL !");
1584
				manager.writeToDebug("TerminologyManager.addConcept => terminology racine est NULL !");
1539 1585
			}
1540 1586
			return null;
1541 1587
		}
......
1548 1594
				if(term==null){
1549 1595
					int nbTerm = termino.getNbTerms();
1550 1596
					term = new TerminologyElement (concept, newTerm, Terminology.TERMINOLOGY_TERM, "T_"+nbTerm);
1551
					//System.out.println("TerminologyManager.addTerm() [1] "+term.getName());
1597
					//manager.writeToDebug("TerminologyManager.addTerm() [1] "+term.getName());
1552 1598
					termino.setNewlyAddedElement(term);
1553 1599
					termino.setNbTerms(++nbTerm);
1554 1600
				}
......
1556 1602
				return term;
1557 1603
			}
1558 1604
			else {
1559
				System.out.println("TerminologyManager.addTerm => concept est NULL, pas d'ajout de terme !");
1605
				manager.writeToDebug("TerminologyManager.addTerm => concept est NULL, pas d'ajout de terme !");
1560 1606
			}
1561 1607
			return null;
1562 1608
		}
......
1569 1615
				if(term==null){
1570 1616
					int nbTerm = termino.getNbTerms();
1571 1617
					term = new TerminologyElement (concept, newTerm, Terminology.TERMINOLOGY_TERM, "T_"+nbTerm);
1572
					//System.out.println("Terminology.addTerm() [2] "+term.getName());
1618
					//manager.writeToDebug("Terminology.addTerm() [2] "+term.getName());
1573 1619
					termino.setNewlyAddedElement(term);
1574 1620
					termino.setNbTerms(++nbTerm);
1575 1621
				}
1576 1622
				return term;
1577 1623
			}
1578 1624
			else {
1579
				System.out.println("TerminologyManager.addTerm => concept est NULL, pas d'ajout de terme !");
1625
				manager.writeToDebug("TerminologyManager.addTerm => concept est NULL, pas d'ajout de terme !");
1580 1626
			}
1581 1627
			return null;
1582 1628
		}
......
1603 1649
		}
1604 1650

  
1605 1651
		private void mergeConcepts(TerminologyElement conceptToMerge, TerminologyElement concept){
1606
			System.out.println("TerminologyManager.mergeConcepts [from "+concept+"  to "+conceptToMerge+"]");
1652
			manager.writeToDebug("TerminologyManager.mergeConcepts [from "+concept+"  to "+conceptToMerge+"]");
1607 1653
			Terminology termino = conceptToMerge.getTerminology();
1608 1654
			Vector<TerminologyElement> terms = concept.children();
1609 1655
			for(int i = 0 ; i < terms.size() ; ++i){
......
1623 1669
					concept = new TerminologyElement (termino.getRoot(), newConcept, Terminology.TERMINOLOGY_CONCEPT, "C_"+nbConcept, 
1624 1670
							category/*, ancestors, descendants*/, definition);
1625 1671
					termino.setNewlyAddedElement(concept);
1626
					//System.out.println("ADD CONCEPT [2] => "+concept.getName()+" with id #"+ concept.getId());
1672
					//manager.writeToDebug("ADD CONCEPT [2] => "+concept.getName()+" with id #"+ concept.getId());
1627 1673
					termino.setNbConcepts(++nbConcept);
1628 1674
				}
1629 1675
				addTerm(newTerm, concept);
......
1631 1677
				return concept;
1632 1678
			}
1633 1679
			else {
1634
				System.out.println("TerminologyManager.addConcept => terminology racine est NULL !");
1680
				manager.writeToDebug("TerminologyManager.addConcept => terminology racine est NULL !");
1635 1681
			}
1636 1682
			return null;
1637 1683
		}
......
1646 1692
					concept = new TerminologyElement (termino.getRoot(), newConcept, Terminology.TERMINOLOGY_CONCEPT, id, 
1647 1693
							category, definition);
1648 1694
					termino.setNewlyAddedElement(concept);
1649
					//System.out.println("ADD CONCEPT [3] => "+concept.getName()+" with id #"+ concept.getId());
1695
					//manager.writeToDebug("ADD CONCEPT [3] => "+concept.getName()+" with id #"+ concept.getId());
1650 1696
					termino.setNbConcepts(++nbConcept);
1651 1697
				}
1652 1698
				addTerm(newTerm, concept);
......
1654 1700
				return concept;
1655 1701
			}
1656 1702
			else {
1657
				System.out.println("TerminologyManager.addConcept => terminology racine est NULL !");
1703
				manager.writeToDebug("TerminologyManager.addConcept => terminology racine est NULL !");
1658 1704
			}
1659 1705
			return null;
1660 1706
		}
......
1675 1721
						TerminologyElement occEl = termino.getOccurrence(element, occurrenceSet);
1676 1722
						if(occEl==null){
1677 1723
							occEl = addOccToTerm(element, occurrenceSet);
1678
							System.out.println("addOccurrenceWithElement "+i+" ["+occurrenceSet.getValue()+"] to TERM ["+element+"]");
1724
							manager.writeToDebug("addOccurrenceWithElement "+i+" ["+occurrenceSet.getValue()+"] to TERM ["+element+"]");
1679 1725

  
1680 1726
							if(occEl==null){
1681 1727
								occSetDuplicate.add(occurrenceSet);
......
1684 1730
					}
1685 1731
				}
1686 1732
			}
1687
			//System.out.println("How many occs left ? "+occSetDuplicate.size());
1733
			//manager.writeToDebug("How many occs left ? "+occSetDuplicate.size());
1688 1734
			return occSetDuplicate;
1689 1735
		} 
1690 1736

  
......
1700 1746
			int nbOccAdded = 0;
1701 1747
			int nbTotalOcc = occurrencesSet.size();
1702 1748
			DictionaryElement newlyAddedOcc = null;
1703
			System.out.println("TerminologyManager.addOccurrences() => NB "+occurrencesSet.size());
1749
			manager.writeToDebug("TerminologyManager.addOccurrences() => NB "+occurrencesSet.size());
1704 1750
			if(elements!=null){
1705 1751
				if(elements.size()!=0){
1706 1752
					TerminologyElement el = elements.get(0);
......
1726 1772
						if(term==null){
1727 1773
							term = addTerm(occurrenceSet.getValue(), element);
1728 1774
						}
1729
						//System.out.println("ADD OCC to ["+term+"]");
1775
						//manager.writeToDebug("ADD OCC to ["+term+"]");
1730 1776
						TerminologyElement newlyAddedOcc = termino.getOccurrence(term, occurrenceSet);
1731 1777
						if(newlyAddedOcc==null){
1732 1778
							newlyAddedOcc = addOccToTerm(term, occurrenceSet);
......
1742 1788
							StringDistance strDist = new StringDistance();
1743 1789
							int dist = strDist.computeDistance(occurrenceSet.getValue(), element.getName());
1744 1790
							if(dist<2){
1745
								//System.out.println("CONCEPT strDist.computeDistance ("+dist+") BTW "+occurrenceSet.getValue()+" <=> "+element.getElement());
1791
								//manager.writeToDebug("CONCEPT strDist.computeDistance ("+dist+") BTW "+occurrenceSet.getValue()+" <=> "+element.getElement());
1746 1792

  
1747 1793
								TerminologyElement term = termino.getTermWithConcept(element,occurrenceSet.getValue());
1748 1794
								if(term==null){
1749 1795
									term = addTerm(occurrenceSet.getValue(), element);
1750 1796
								}
1751
								//System.out.println("ADD OCC to ["+term+"]");
1797
								//manager.writeToDebug("ADD OCC to ["+term+"]");
1752 1798

  
1753 1799
								TerminologyElement newlyAddedOcc = termino.getOccurrence(term, occurrenceSet);
1754 1800
								if(newlyAddedOcc==null){
......
1783 1829
						Terminology termino = element.getTerminology();
1784 1830
						StringDistance strDist = new StringDistance();
1785 1831
						int dist = strDist.computeDistance(occurrenceSet.getValue(), element.getName());
1786
						//System.out.println("computeDistance ("+dist+") BTW "+occurrenceSet.getValue()+" <=> "+element.getElement());
1832
						//manager.writeToDebug("computeDistance ("+dist+") BTW "+occurrenceSet.getValue()+" <=> "+element.getElement());
1787 1833
						if(dist<2){
1788 1834
							TerminologyElement concept = element.getParent();
1789 1835
							TerminologyElement term = termino.getTermWithConcept(concept,occurrenceSet.getValue());
1790 1836
							if(term==null){
1791
								//System.out.println("ADD NEW TERM ["+occurrenceSet.getValue()+"]");
1837
								//manager.writeToDebug("ADD NEW TERM ["+occurrenceSet.getValue()+"]");
1792 1838
								term = addTerm(occurrenceSet.getValue(), concept);
1793 1839
							}
1794
							//System.out.println("ADD OCC ["+occurrenceSet.getValue()+"] to TERM ["+term+"]");
1840
							//manager.writeToDebug("ADD OCC ["+occurrenceSet.getValue()+"] to TERM ["+term+"]");
1795 1841
							TerminologyElement newlyAddedOcc = termino.getOccurrence(term, occurrenceSet);
1796 1842
							if(newlyAddedOcc==null){
1797 1843
								newlyAddedOcc = addOccToTerm(term, occurrenceSet);
......
1844 1890
				if(concept!=null){
1845 1891
					TerminologyElement oldParent = term.getParent();
1846 1892
					if(concept!=oldParent){
1847
						System.out.println("TemrinologyManager.modifyTerm() with C /"+concept+"/");
1893
						manager.writeToDebug("TemrinologyManager.modifyTerm() with C /"+concept+"/");
1848 1894
						addTermToConcept(term, concept);//LANG = this.getParameters().getLang()
1849 1895
						oldParent.removeChild(term, false);
1850 1896
					}
......
1858 1904
			int [] annotIndexes = {startAnnot, endAnnot};
1859 1905
			//Occurrence occurrence = occSet.getOccurrence(0);
1860 1906
			//String localisation = occurrence.getLocalisationInText();
1861
			//System.out.println("#### Terminology.buildOcc() - OCCURRENCE is ["+occurrence+"] -> localisation ["+localisation+"]");
1907
			//manager.writeToDebug("#### Terminology.buildOcc() - OCCURRENCE is ["+occurrence+"] -> localisation ["+localisation+"]");
1862 1908

  
1863 1909
			//GET TERM -------------------
1864 1910
			TerminologyElement concept = termino.getConcept(idConcept);
1865 1911
			TerminologyElement term = termino.checkAndAddTerm(content, concept);
1866 1912

  
1867 1913
			if(term==null && concept!=null){
1868
				System.out.println("\t TerminologyManager.buildOcc() - ADD TERM "+content+" to CONCEPT '"+concept+"' ("+idConcept+") in "+termino.getName());
1914
				manager.writeToDebug("\t TerminologyManager.buildOcc() - ADD TERM "+content+" to CONCEPT '"+concept+"' ("+idConcept+") in "+termino.getName());
1869 1915

  
1870 1916
				term = addTerm(content, concept);
1871 1917
			}else{
1872 1918
				if(concept==null){
1873
					System.out.println("GRAVE PROBLEME \t TerminologyManager.buildOcc() - ADD TERM "+content+" to CONCEPT '"+concept+"' ("+idConcept+") in "+termino.getName());
1919
					manager.writeToDebug("GRAVE PROBLEME \t TerminologyManager.buildOcc() - ADD TERM "+content+" to CONCEPT '"+concept+"' ("+idConcept+") in "+termino.getName());
1874 1920
				}
1875 1921
			}
1876 1922

  
......
1889 1935
			int [] annotIndexes = {occSet.getIndexes()[0], endAnnot};
1890 1936
			//Occurrence occurrence = occSet.getOccurrence(0);
1891 1937
			//String localisation = occurrence.getLocalisationInText();
1892
			//System.out.println("#### TerminologyManager.buildOcc() - OCCURRENCE is ["+occurrence+"] -> localisation ["+localisation+"]");
1938
			//manager.writeToDebug("#### TerminologyManager.buildOcc() - OCCURRENCE is ["+occurrence+"] -> localisation ["+localisation+"]");
1893 1939

  
1894 1940
			//GET CONCEPT ----------------
1895 1941
			String idConcept = occ.getParent().getParent().getId();
......
1911 1957
			if(!occ.isIndex()){
1912 1958
				if(element.getReference().equals(Terminology.TERMINOLOGY_TERM)){
1913 1959
					TerminologyElement occEl = addOccToTerm(element, occ);
1914
					System.out.println("TerminologyManager.getAddOccurrence() - NOT INDEXED & TERM is : "+element+ " & OCC is : "+occEl);
1960
					manager.writeToDebug("TerminologyManager.getAddOccurrence() - NOT INDEXED & TERM is : "+element+ " & OCC is : "+occEl);
1915 1961
					return occEl;
1916 1962
				}
1917 1963
				if(element.getReference().equals(Terminology.TERMINOLOGY_CONCEPT)){
1918 1964
					TerminologyElement term = termino.getTermWithConcept(element, element.getName());
1919 1965
					TerminologyElement occEl = addOccToTerm(term, occ);
1920
					System.out.println("TerminologyManager.getAddOccurrence() - NOT INDEXED & CONCEPT is : "+element+ " & OCC is : "+occEl);
1966
					manager.writeToDebug("TerminologyManager.getAddOccurrence() - NOT INDEXED & CONCEPT is : "+element+ " & OCC is : "+occEl);
1921 1967
					return occEl;
1922 1968
				}	
1923 1969
			}else {
......
1933 1979
			if(!occ.isIndex()){
1934 1980
				if(element.getReference().equals(Terminology.TERMINOLOGY_TERM)){
1935 1981
					TerminologyElement occEl = termino.getOccurrence(element, occ);
1936
					System.out.println("TerminologyManager.getOccurrence() - NOT INDEXED & TERM is : "+element+ " & OCC is : "+occEl);
1982
					manager.writeToDebug("TerminologyManager.getOccurrence() - NOT INDEXED & TERM is : "+element+ " & OCC is : "+occEl);
1937 1983
					return occEl;
1938 1984
				}
1939 1985
				if(element.getReference().equals(Terminology.TERMINOLOGY_CONCEPT)){
1940 1986
					TerminologyElement occEl = termino.getOccurrence(element, occ);
1941
					System.out.println("TerminologyManager.getOccurrence() - NOT INDEXED & CONCEPT is : "+element+ " & OCC is : "+occEl);
1987
					manager.writeToDebug("TerminologyManager.getOccurrence() - NOT INDEXED & CONCEPT is : "+element+ " & OCC is : "+occEl);
1942 1988
					return occEl;
1943 1989
				}	
1944 1990
			}else {
......
1991 2037

  
1992 2038

  
1993 2039
		public Terminology getTerminology(String name){
1994
			//System.out.println("TerminologyManager.getTerminology() "+name+" among nb = "+terminoDatas.length);
2040
			//manager.writeToDebug("TerminologyManager.getTerminology() "+name+" among nb = "+terminoDatas.length);
1995 2041
			Terminology termino = null;
1996 2042
			for (int i = 0 ; i<terminoDatas.length;++i) {
1997 2043
				if(terminoDatas[i].getName().equals(name)){
......
2006 2052

  
2007 2053
		public void setTerminologies(Terminology [] terminos){
2008 2054
			terminoDatas = terminos;
2009
			System.out.println("TerminologyManager.setTerminologies() - nb = "+terminoDatas.length);
2055
			manager.writeToDebug("TerminologyManager.setTerminologies() - nb = "+terminoDatas.length);
2010 2056
		}
2011 2057

  
2012 2058

  
......
2070 2116
					if(occs.size()!=0){
2071 2117
						for(int i = 0 ; i< occs.size(); ++i){
2072 2118
							TerminologyElement occOfTerm = occs.get(i);
2073
							//System.out.println("CheckOccurrence for terms ("+term.getElement()+") child ? "+occOfTerm);
2119
							//manager.writeToDebug("CheckOccurrence for terms ("+term.getElement()+") child ? "+occOfTerm);
2074 2120
							if(occOfTerm.getOccurrence()==occ){
2075 2121
								return occOfTerm;
2076 2122
							}
......
2134 2180

  
2135 2181
		public void setEquivalence(Equivalence equiv){
2136 2182
			this.equivData = equiv;
2137
			//System.out.println("EquivalenceManager.setEquivalence()");
2183
			//manager.writeToDebug("EquivalenceManager.setEquivalence()");
2138 2184
		}
2139 2185

  
2140 2186
		public Equivalence getEquivalence(){
......
2229 2275
					concept = new EquivalenceElement(equiv, term, EquivalenceTree.EQUIVALENCE_CONCEPT,"C_"+nbConcept);
2230 2276

  
2231 2277
					equiv.setNewlyAddedElement(concept);
2232
					System.out.println("ADD EQUIVALENCE CONCEPT => "+concept.getName()+" with id #"+ concept.getId());
2278
					manager.writeToDebug("ADD EQUIVALENCE CONCEPT => "+concept.getName()+" with id #"+ concept.getId());
2233 2279
					equiv.setNbConcepts(++nbConcept);
2234 2280
				}
2235 2281
			}
......
2237 2283
		}*/
2238 2284

  
2239 2285
		public EquivalenceElement addEquivalenceElement(OccurrenceSet annot, String comment, ParallelTextElement localisation){
2240
			//System.out.println("EquivalenceManager.addEquivalenceElement() TO EQUIVALENCES (nb="+equivData.getEquivalences().size()+")");
2286
			//manager.writeToDebug("EquivalenceManager.addEquivalenceElement() TO EQUIVALENCES (nb="+equivData.getEquivalences().size()+")");
2241 2287
			if(equivData!=null){
2242 2288
				EquivalenceElement occEl = equivData.checkElementAsChild(equivData.getRoot(), localisation, annot);
2243
				//System.out.println("\tEQUIVALENCE ALREADY EXISTS ? "+occEl);
2289
				//manager.writeToDebug("\tEQUIVALENCE ALREADY EXISTS ? "+occEl);
2244 2290
				if(occEl==null){
2245 2291
					if(annot.getEquivalence()==null){
2246 2292
						int nbSeqs = equivData.getNbSeqs();
......
2261 2307
		public EquivalenceElement addEquivalence(String idEqui, Vector<OccurrenceSet> annots, 
2262 2308
				String comment, ParallelTextElement localisation){
2263 2309
			if(equivData!=null){
2264
				System.out.println("EquivalenceManager.addEquivalence() TO EQUIVALENCE n°"+idEqui+" from "+equivData.getRoot().getId());
2310
				
2311
				manager.writeToDebug("EquivalenceManager.addEquivalence() TO EQUIVALENCE n°"+idEqui+" from "+equivData.getRoot().getId());
2312
				
2313
				
2265 2314
				int nbSeqs = equivData.getNbSeqs();
2266 2315
				Integer nb = new Integer(idEqui.substring(2, idEqui.length()));//
2267 2316

  
2268 2317
				EquivalenceElement equiEl = null;
2269 2318
				for (int i = 0; i < annots.size(); i++) {
2270 2319
					OccurrenceSet annot = annots.get(i);
2271
					//System.out.println("/"+annot.getIdentification()+"/ IN "+localisation);
2320
					//manager.writeToDebug("/"+annot.getIdentification()+"/ IN "+localisation);
2272 2321
					equiEl = equivData.checkElementAsChild(equivData.getRoot(), localisation, idEqui);
2273 2322
					if(equiEl==null){
2274 2323
						equiEl = new EquivalenceElement(equivData.getRoot(), Equivalence.EQUIVALENCE_SEQUENCE, idEqui, annot, comment, localisation);
......
2313 2362
				if(occEl==null){
2314 2363
					int nbSeqs = equiv.getNbSeqs();
2315 2364
					occEl = new EquivalenceElement (concept, EquivalenceTree.EQUIVALENCE_SEQUENCE, "I_"+nbSeqs, occSet, comment, localisation);
2316
					System.out.println("ADD EQUIVALENCE OCC => "+occEl.getName()+" with id #"+ occEl.getId());
2365
					manager.writeToDebug("ADD EQUIVALENCE OCC => "+occEl.getName()+" with id #"+ occEl.getId());
2317 2366
					manager.getAnnotationManager().addAnnotation(occSet, occSet.getIndexes()[0], occSet.getIndexes()[1]);
2318 2367
					equiv.setNbSeqs(++nbSeqs);
2319 2368
					equiv.setNewlyAddedElement(occEl);
......
2347 2396
			EquivalenceWriter writer = new EquivalenceWriter(equivData, manager);
2348 2397
			writer.modifyEquivalence(equivData, equivalence, comment, false);
2349 2398

  
2350
			//System.out.println("TranslationManager.validateEquivalence() as - "+equivalenceSet.size()+" equivalence -");
2399
			//manager.writeToDebug("TranslationManager.validateEquivalence() as - "+equivalenceSet.size()+" equivalence -");
2351 2400
			currentEquivalence = null;
2352 2401
		}
2353 2402

  
......
2498 2547
					}
2499 2548
					///////////////////////////////////////////
2500 2549
				}
2501
				//System.out.println("completeElementsWithEquivalence() - T="+textRef.getId()+" / O="+el);
2550
				//manager.writeToDebug("completeElementsWithEquivalence() - T="+textRef.getId()+" / O="+el);
2502 2551
			}
2503 2552
		}
2504 2553

  
......
2513 2562
					textsForEquivalence = new Vector<HyperalignText>();
2514 2563
					for(int i = 0 ; i < texts.size() ; ++i){
2515 2564
						HyperalignText text = (HyperalignText) texts.get(i);
2516
						//System.out.println("EquivalenceManager.setEquivalenceTexts() ADD ["+text.getId()+"]");
2565
						//manager.writeToDebug("EquivalenceManager.setEquivalenceTexts() ADD ["+text.getId()+"]");
2517 2566
						textsForEquivalence.add(text);
2518 2567
						String firstLangOfText = text.getMainLang();
2519 2568
						Dictionary termino = manager.getDictionaryManager().getDictionary(firstLangOfText);
......
2537 2586
			if(equivalenceSet!=null){
2538 2587
				for(int i= 0 ; i < equivalenceSet.size() ; ++i){
2539 2588
					EquivalenceElement equi = equivalenceSet.get(i);
2540
					//System.out.println("EquivalenceManager.updateEquivalencesSet() EQUIVALENCE "+i);
2589
					//manager.writeToDebug("EquivalenceManager.updateEquivalencesSet() EQUIVALENCE "+i);
2541 2590

  
2542 2591
					HashMap<HyperalignText, OccurrenceSet> els = equi.getElements();
2543 2592
					Set keys = els.keySet();
......
2545 2594
					Vector<HyperalignText> textsToRemove = new Vector<HyperalignText>();
2546 2595
					while(it.hasNext()){
2547 2596
						HyperalignText text = it.next();
2548
						//System.out.println("EquivalenceManager.updateEquivalencesSet() === text : "+text.getName());
2597
						//manager.writeToDebug("EquivalenceManager.updateEquivalencesSet() === text : "+text.getName());
2549 2598
						if(!textsForEquivalence.contains(text)){
2550 2599
							textsToRemove.add(text);
2551 2600

  
2552 2601
						}else {
2553
							//System.out.println("EquivalenceManager.updateEquivalencesSet() =2= KEEP equi from text : "+text.getName());
2602
							//manager.writeToDebug("EquivalenceManager.updateEquivalencesSet() =2= KEEP equi from text : "+text.getName());
2554 2603
						}
2555 2604
					}
2556 2605

  
......
2558 2607
						OccurrenceSet el = els.get(textsToRemove.get(j));
2559 2608
						if(el!=null){
2560 2609
							els.remove(textsToRemove.get(j));
2561
							System.out.println("EquivalenceManager.updateEquivalencesSet() =1= REMOVE equi from text : "+textsToRemove.get(j).getName());
2610
							manager.writeToDebug("EquivalenceManager.updateEquivalencesSet() =1= REMOVE equi from text : "+textsToRemove.get(j).getName());
2611
							
2562 2612
						}
2563 2613
					}
2564 2614
				}
......
2582 2632
		}
2583 2633

  
2584 2634
		public void modifyEquivalence(EquivalenceElement equiSet, OccurrenceSet occ, boolean toRemove){
2585
			System.out.println("EquivalenceManager.modifyEquivalence() - "+equiSet.getId()+" | Should remove ? "+toRemove+" | OCC => "+occ+" "+occ.getDivision().getXmlId());
2635
			manager.writeToDebug("EquivalenceManager.modifyEquivalence() - "+equiSet.getId()+" | Should remove ? "+toRemove+" | OCC => "+occ+" "+occ.getDivision().getXmlId());
2636
			
2586 2637
			if(toRemove){
2587 2638
				occ.removeEquivalence();
2588 2639
				equiSet.removeElement(occ);
......
2592 2643
				if(occSetInEqui!=occ){
2593 2644
					if(occSetInEqui!=null){
2594 2645
						//CAS DE REMPLACEMENT, il faut donc enlever la référence de l'équivalence sur l'ancienne annotation
2595
						System.out.println("\t "+occSetInEqui+" IS REPLACED BY "+occ+" in EQUIVALENCE n°"+equiSet.getId());
2646
						manager.writeToDebug("\t "+occSetInEqui+" IS REPLACED BY "+occ+" in EQUIVALENCE n°"+equiSet.getId());
2647
						
2596 2648
						occSetInEqui.removeEquivalence();
2597 2649
						equiSet.removeElement(occSetInEqui);
2598 2650
						annotManager.removeAnnotation(occSetInEqui);
......
2634 2686
				while(it.hasNext()){
2635 2687
					HyperalignText textRef = it.next();
2636 2688
					OccurrenceSet el = els.get(textRef);
2637
					System.out.println("\t\tREMOVE "+el+" n°"+el.getIdentification()+" of Text "+textRef.getName()+" from equivalence "+equiSet.getId());
2689
					manager.writeToDebug("\t\tREMOVE "+el+" n°"+el.getIdentification()+" of Text "+textRef.getName()+" from equivalence "+equiSet.getId());
2690
					
2638 2691
					if(el!=null){
2639 2692
						annotManager.removeAnnotation(el);
2640 2693
					}
......
2667 2720
			editEquivalence = EquivalenceManager.EQUIVALENCE_OCCURRENCE;
2668 2721
			EquivalenceElement equiElSet = annot.getEquivalence();
2669 2722
			if(equiElSet==null) {
2670
				System.out.println("EquivalenceManager.setEquivalenceCurrentState() ----- NEW EQUIVALENCE SET FOR : "+annot+" ----");
2723
				manager.writeToDebug("EquivalenceManager.setEquivalenceCurrentState() ----- NEW EQUIVALENCE SET FOR : "+annot+" ----");
2724
				
2671 2725
				CorpusManager corpusManager = manager.getCorpusManager();
2672 2726
				ParallelTextElement el = corpusManager.searchTextElement(annot.getDivision().getId(), corpusManager.getCorpus().getRoot());
2673 2727
				//manager.getCorpusManager().findTextElement(annot.getDivision());
2674 2728
				currentEquivalence = addEquivalenceElement(annot, "", el);
2675 2729
			}else {
2676 2730
				currentEquivalence = equiElSet;
2677
				System.out.println("EquivalenceManager.setEquivalenceCurrentState() ----- EQUIVALENCE EXISTS "+currentEquivalence.getId()+" WITH : "+annot+" ----");
2731
				manager.writeToDebug("EquivalenceManager.setEquivalenceCurrentState() ----- EQUIVALENCE EXISTS "+currentEquivalence.getId()+" WITH : "+annot+" ----");
2732
				
2678 2733
			}
2679 2734
			return true;
2680 2735
		}
......
2708 2763
			this.targetLangForGraph = targetLang;
2709 2764
			this.sourceLangForGraph = element.getDictionary();
2710 2765
			this.setSourceElement(element);
2711
			System.out.println("TranslationManager.viewEquivalence() with Element /"+element+"/");
2766
			manager.writeToDebug("TranslationManager.viewEquivalence() with Element /"+element+"/");
2767
			
2712 2768
			if(element!=null){
2713 2769
				String typeNode = element.getReference();
2714 2770
				/////////////// OCCURRENCE ///////////////
2715 2771
				if(typeNode.equals(Dictionary.DICO_OCC)){
2716
					System.out.println("-IN OCC-");
2772
					manager.writeToDebug("-IN OCC-");
2773
					
2717 2774
					EquivalenceElement equivalence = element.getOccurrence().getEquivalence();	
2718 2775
					//no equivalence, therefore we prepare one
2719 2776
					if(equivalence==null){
......
2728 2785
				}
2729 2786
				else {
2730 2787
					/////////////// CONCEPT OR TERM ///////////////
2731
					System.out.println("-IN "+typeNode+"-");
2788
					manager.writeToDebug("-IN "+typeNode+"-");
2789
					
2732 2790
					editEquivalence = EQUIVALENCE_CONCEPT;
2733 2791
				}
2734 2792
			}
......
2741 2799
			Vector<HyperalignText> authors = terminologyAndTextForEquivalences.get(targetLang);
2742 2800
			HashMap<HyperalignText, HashMap<Object, Integer>> results = new HashMap<HyperalignText, HashMap<Object, Integer>>();
2743 2801
			HashMap<HyperalignText, HashMap<Object, Integer>> equivalences = findEquivalencesForAuthor(lemmeElement, targetLang, results, authors);
2744
			System.out.println("EquivalenceManager.computeGraphEquivalencesByAuthor() - 3 - for LANG : "+targetLang+" NB TARGETS > "+equivalences.size());
2802
			
2803
			manager.writeToDebug("EquivalenceManager.computeGraphEquivalencesByAuthor() - 3 - for LANG : "+targetLang+" NB TARGETS > "+equivalences.size());
2745 2804

  
2746

  
2747 2805
			currentGraphUrls = new URL[equivalences.size()];
2748 2806
			Set keys = equivalences.keySet();
2749 2807
			Iterator it = keys.iterator();
......
2786 2844
			if(!allLemmes){
2787 2845
				HashMap<Object,Integer> results = new HashMap<Object, Integer>();
2788 2846
				HashMap<Object, Integer> equivalences = findEquivalences(lemmeElement, targetLang, results);
2789
				System.out.println("EquivalenceManager.computeGraphEquivalences() - 2 - for LANG : "+targetLang+" NB TARGETS > "+equivalences.size());
2847
				manager.writeToDebug("EquivalenceManager.computeGraphEquivalences() - 2 - for LANG : "+targetLang+" NB TARGETS > "+equivalences.size());
2848
				
2790 2849
				HashMap<Object,HashMap<Object, Integer>> equivalencesByLemme = new HashMap<Object, HashMap<Object,Integer>>();
2791 2850
				equivalencesByLemme.put(lemmeElement, equivalences);
2792 2851
				Integer level = new Integer(neighbourhWidth);
......
2795 2854
			}else {
2796 2855
				HashMap<Object, HashMap<Object,Integer>> results = new HashMap<Object, HashMap<Object,Integer>>();
2797 2856
				HashMap<Object, HashMap<Object,Integer>> equivalencesByLemme = groupEquivalencesByLemme(lemmeElement, targetLang, results);
2798
				System.out.println("EquivalenceManager.computeGraphEquivalences() - 1 - for ALL in : "+targetLang+" NB LEMMES > "+equivalencesByLemme.size());
2857
				manager.writeToDebug("EquivalenceManager.computeGraphEquivalences() - 1 - for ALL in : "+targetLang+" NB LEMMES > "+equivalencesByLemme.size());
2858
				
2799 2859
				Integer level = new Integer(neighbourhWidth);
2800 2860
				EquivalenceGraphWriter writer = new EquivalenceGraphWriter(this, equivalencesByLemme, level, null);	
2801 2861
				file = writer.getFile();
......
2827 2887
		/*public void computeGraphEquivalences(TerminologyElement conceptSource, 
2828 2888
				HashMap<HyperalignText,HashMap<TerminologyElement, Vector<EquivalenceElement>>> conceptTargetsByText, 
2829 2889
				String neighbourhoodWidth){
2830
			System.out.println("EquivalenceManager.computeGraphEquivalences() - 2 -");
2890
			manager.writeToDebug("EquivalenceManager.computeGraphEquivalences() - 2 -");
2831 2891

  
2832 2892
			int nbText = 0;
2833 2893
			currentGraphUrls = new URL[conceptTargetsByText.size()];
......
2888 2948
			String typeNode = element.getReference();
2889 2949

  
2890 2950
			if(filterByAuthor){
2891
				System.out.println("EquivalenceManager.buildGraph() - BY AUTHOR !");		
2951
				manager.writeToDebug("EquivalenceManager.buildGraph() - BY AUTHOR !");		
2952
				
2892 2953
				computeGraphEquivalencesByAuthor(element, targetLang, neighbourhoodWidth);
2893 2954

  
2894 2955
			}else {
2895 2956
				/////////////////////// DICO //////////////////// 
2896 2957
				if(typeNode.equals(Dictionary.DICO_DICO)){
2897
					System.out.println("EquivalenceManager.buildGraph() - ALL !");		
2958
					manager.writeToDebug("EquivalenceManager.buildGraph() - ALL !");		
2959
					
2898 2960
					computeGraphEquivalences(element, targetLang, "1", true);
2899 2961
					//computeGraphEquivalences(sourceElements, targetElements, neighbourhoodWidth, filterByAuthor);	
2900 2962
				}else {
2901
					System.out.println("EquivalenceManager.buildGraph() - FOR "+element+" [level "+element.getReference()+"]");		
2963
					manager.writeToDebug("EquivalenceManager.buildGraph() - FOR "+element+" [level "+element.getReference()+"]");		
2964
					
2902 2965
					computeGraphEquivalences(element, targetLang, neighbourhoodWidth, false);	
2903 2966
				}
2904 2967
			}
......
2916 2979
			Vector<ConceptEquivalenceElement> sourceElements = new Vector<ConceptEquivalenceElement>();
2917 2980
			Vector<EquivalenceElement> currentEquiElements = new Vector<EquivalenceElement>();
2918 2981
			equiElementsByLocalization = new HashMap<ParallelTextElement, Vector<EquivalenceElement>>();
2919
			System.out.println("EquivalenceManager.buildTerminoEquis() FOR "+dicoEl);
2982
			manager.writeToDebug("EquivalenceManager.buildTerminoEquis() FOR "+dicoEl);
2983
			
2920 2984
			String typeNode = dicoEl.getReference();
2921 2985
			////////////////////////////////TERMINOLOGY 
2922 2986
			if(typeNode.equals(Dictionary.DICO_DICO)){
......
2943 3007
					}	
2944 3008
				}
2945 3009
				sourceElements.add(conceptEquiEl);
2946
				System.out.println("EquivalenceManager.buildDicoEquis() - PUT LEMME ["+dicoEl+"]");
3010
				manager.writeToDebug("EquivalenceManager.buildDicoEquis() - PUT LEMME ["+dicoEl+"]");
3011
				
2947 3012
			}
2948 3013
			//////////////////////////////// TERM 
2949 3014
			if (typeNode.equals(Dictionary.DICO_FORM)){
......
2959 3024
					currentEquiElements = findOccurrencesInEquivalence(occEl.getDictionary(), currentEquiElements, conceptEquiEl, occSet, targetLang);
2960 3025
				}
2961 3026
				sourceElements.add(conceptEquiEl);
2962
				System.out.println("EquivalenceManager.buildDicoEquis() - PUT FORM ["+dicoEl+"]");
3027
				manager.writeToDebug("EquivalenceManager.buildDicoEquis() - PUT FORM ["+dicoEl+"]");
3028
				
2963 3029

  
2964 3030
			}	
2965 3031
			return sourceElements;
......
3042 3108

  
3043 3109
			if(str instanceof DictionaryElement){
3044 3110
				DictionaryElement el = (DictionaryElement) str;
3045
				System.out.println("EquivalenceManager.findEquivalences() FOR "+el.getName()+" Level ("+el.getReference()+") in TARGET LANG "+dicoTarget);
3111
				manager.writeToDebug("EquivalenceManager.findEquivalences() FOR "+el.getName()+" Level ("+el.getReference()+") in TARGET LANG "+dicoTarget);
3112
				
3046 3113

  
3047 3114
				if(el.getReference().equals(Dictionary.DICO_OCC)){
3048 3115
					OccurrenceSet occ = el.getOccurrence();
......
3054 3121
						Iterator<HyperalignText> it = keys.iterator();
3055 3122
						while(it.hasNext()){
3056 3123
							HyperalignText textOcc = it.next();
3057
							System.out.println("\tfindEquivalences ony occs from target lang => "+textOcc.getMainLang());
3124
							manager.writeToDebug("\tfindEquivalences ony occs from target lang => "+textOcc.getMainLang());
3125
							
3058 3126
							if(textOcc.getMainLang().equals(dicoTarget.getName())){
3059 3127
								OccurrenceSet occEqui = elements.get(textOcc);
3060 3128
								if(occEqui != occ){
......
3065 3133
											nbOccs = new Integer(nbOccs.intValue()+1);
3066 3134
										}else {
3067 3135
											results.put(lemme, new Integer(1));
3068
											System.out.println("\tPUT LEMME > "+lemme+ " from "+textOcc.getMainLang());										
3136
											manager.writeToDebug("\tPUT LEMME > "+lemme+ " from "+textOcc.getMainLang());										
3137
										
3069 3138
										}
3070 3139
										//PUT FORM TO THE EQUIVALENCE
3071 3140
									}else {
3072
										System.out.println("\tPUT STRING > "+occEqui.getValue()+ " from "+textOcc.getMainLang());
3141
										manager.writeToDebug("\tPUT STRING > "+occEqui.getValue()+ " from "+textOcc.getMainLang());
3142
										
3073 3143
										results.put(occEqui.getValue(), new Integer(1));
3074 3144
									}
3075 3145
								}
......
3092 3162

  
3093 3163
			if(str instanceof DictionaryElement){
3094 3164
				DictionaryElement el = (DictionaryElement) str;
3095
				System.out.println("EquivalenceManager.findEquivalences() FOR "+el.getName()+" Level ("+el.getReference()+") in TARGET LANG "+dicoTarget);
3165
				manager.writeToDebug("EquivalenceManager.findEquivalences() FOR "+el.getName()+" Level ("+el.getReference()+") in TARGET LANG "+dicoTarget);
3166
				
3096 3167

  
3097 3168
				if(el.getReference().equals(Dictionary.DICO_OCC)){
3098 3169
					OccurrenceSet occ = el.getOccurrence();
......
3104 3175
						Iterator<HyperalignText> it = keys.iterator();
3105 3176
						while(it.hasNext()){
3106 3177
							HyperalignText textOcc = it.next();
3107
							System.out.println("\tfindEquivalences ony occs from target lang => "+textOcc.getMainLang());
3178
							manager.writeToDebug("\tfindEquivalences ony occs from target lang => "+textOcc.getMainLang());
3179
							
3108 3180
							if(textOcc.getMainLang().equals(dicoTarget.getName()) && authors.contains(textOcc)){
3109 3181
								OccurrenceSet occEqui = elements.get(textOcc);
3110 3182
								if(occEqui != occ){
......
3122 3194
											HashMap<Object, Integer> resultsByAuthor = new HashMap<Object, Integer>();
3123 3195
											resultsByAuthor.put(lemme, new Integer(1));
3124 3196
											results.put(textOcc, resultsByAuthor);
3125
											System.out.println("\tPUT LEMME > "+lemme+ " from "+textOcc.getMainLang());										
3197
											manager.writeToDebug("\tPUT LEMME > "+lemme+ " from "+textOcc.getMainLang());										
3198
											
3126 3199
										}
3127 3200
										//PUT FORM TO THE EQUIVALENCE
3128 3201
									}else {
......
3135 3208
												resultsByAuthor.put(occEqui.getValue(), new Integer(1));
3136 3209
											}	
3137 3210
										}else {
3138
											System.out.println("\tPUT STRING > "+occEqui.getValue()+ " from "+textOcc.getMainLang());
3211
											manager.writeToDebug("\tPUT STRING > "+occEqui.getValue()+ " from "+textOcc.getMainLang());
3212
											
3139 3213
											HashMap<Object, Integer> resultsByAuthor = new HashMap<Object, Integer>();
3140 3214
											resultsByAuthor.put(occEqui.getValue(), new Integer(1));
3141 3215
											results.put(textOcc, resultsByAuthor);
......
3204 3278
			EquivalenceElement equivalence = occSet.getEquivalence();
3205 3279
			if(equivalence!=null){
3206 3280
				if(!equivalences.contains(equivalence)){
3207
					System.out.println("\t occSet /"+occSet+"/ has an equivalence "+equivalence.getId());
3281
					manager.writeToDebug("\t occSet /"+occSet+"/ has an equivalence "+equivalence.getId());
3282
					
3208 3283
					equivalences.add(equivalence);
3209 3284
				}
3210 3285
			}
......
3218 3293
						EquivalenceElement equi = occSetAnnot.getEquivalence();
3219 3294
						if(equi!=null){
3220 3295
							if(!equivalences.contains(equi)){
3221
								System.out.println("\t occSet annot /"+occSetAnnot+"/ has an equivalence "+equi.getId());
3296
								manager.writeToDebug("\t occSet annot /"+occSetAnnot+"/ has an equivalence "+equi.getId());
3297
								
3222 3298
								equivalences.add(equi);
3223 3299
							}
3224 3300
						}
......
3228 3304
				if(isExtendedGraph){
3229 3305
					//search equivalences annotation of each part (Occ) of the OccSet
3230 3306
					/*Vector<EquivalenceElement> equivalencesOfOccSet = findEquivalencesForOccSet(occSet);
3231
					System.out.println("\t occs of occSet have equivalences ? "+equivalencesOfOccSet.size());
3307
					manager.writeToDebug("\t occs of occSet have equivalences ? "+equivalencesOfOccSet.size());
3232 3308
					equivalences = merge(equivalencesOfOccSet, equivalences);*/
3233 3309
					System.out.println("findEquivalences() - TO DO WITH OPTION : isExtendedGraph");
3310
					
3234 3311
				}
3235 3312
			}
3236 3313
			return equivalences;
......
3253 3330
			this.manager = manager;
3254 3331

  
3255 3332
			if(textsToParallelize!=null){
3256
				//System.out.println("CorpusManager NEW with texts to align");
3333
				//manager.writeToDebug("CorpusManager NEW with texts to align");
3257 3334
				corpus =  new ParallelCorpus(this, urlCorpusData, corpusParameters, textsToParallelize);
3258 3335
			}else {
3259
				//System.out.println("CorpusManager NEW with one corpus of aligned texts");
3336
				//manager.writeToDebug("CorpusManager NEW with one corpus of aligned texts");
3260 3337
				corpus = new ParallelCorpus(this, urlCorpusData, corpusParameters);
3261 3338
			}
3262 3339
		}
......
3285 3362

  
3286 3363
		/*public void buildAnnotationsForDivision(Division div){
3287 3364
			if(!divisionsDisplayed.contains(div)){
3288
				System.out.println("CorpusManager.buildAnnotationsForDivision() - FOR "+div.getXmlId()+" - TO DO");
3365
				manager.writeToDebug("CorpusManager.buildAnnotationsForDivision() - FOR "+div.getXmlId()+" - TO DO");
3289 3366
				HyperalignBuilder builder = new HyperalignBuilder(manager, false);
3290 3367
				builder.buildAnnotations(corpus, div);
3291 3368
				divisionsDisplayed.add(div);
3292 3369
			}else {
3293
				System.out.println("CorpusManager.buildAnnotationsForDivision() - FOR "+div.getXmlId()+" - DONE");
3370
				manager.writeToDebug("CorpusManager.buildAnnotationsForDivision() - FOR "+div.getXmlId()+" - DONE");
3294 3371
			}
3295 3372
		}*/
3296 3373

  
......
3299 3376
		}
3300 3377

  
3301 3378
		public void setDivisionsDisplayed(HashMap<String, ParallelTextElement> divsDisplayed){
3302
			System.out.println("CorpusManager.setDivisionsDisplayed() - "+divsDisplayed.size());
3379
			manager.writeToDebug("CorpusManager.setDivisionsDisplayed() - "+divsDisplayed.size());
3380
			
3303 3381
			this.divisionsDisplayed = divsDisplayed;
3304 3382
		}
3305 3383

  
......
3320 3398

  
3321 3399
		public void buildAnnotationsForDivision(ParallelTextElement el){
3322 3400
			if(!divisionsDisplayed.containsKey(el.getId())){
3323
				System.out.println("CorpusManager.buildAnnotationsForDivision() - FOR ["+el.getId()+"] - "+el.computeName()+" - TO DO");
3401
				manager.writeToDebug("CorpusManager.buildAnnotationsForDivision() - FOR ["+el.getId()+"] - "+el.computeName()+" - TO DO");
3402
				
3324 3403
				HashMap<HyperalignText, Division> textsAndDivisions = el.getContents();
3325 3404
				for(HyperalignText text : textsAndDivisions.keySet()){
3326 3405
					Division div = textsAndDivisions.get(text);
......
3336 3415
				divsAdded.add(el.getId());
3337 3416
				writer.modifyProjectConfiguration(divsAdded, false);
3338 3417
			}else {
3339
				System.out.println("CorpusManager.buildAnnotationsForDivision() - FOR "+el.computeName()+" - DONE");	
3418
				manager.writeToDebug("CorpusManager.buildAnnotationsForDivision() - FOR "+el.computeName()+" - DONE");	
3419
				
3340 3420
				HashMap<HyperalignText, Division> divisions = el.getContents();
3341 3421
				currentAnnotationsForDivision = new HashMap<Division, HashMap<Integer,Vector<OccurrenceSet>>>();
3342 3422
				for(Division div : divisions.values()){
......
3360 3440
			Iterator<HyperalignText> it = textsToIndex.iterator();
3361 3441
			while(it.hasNext()){
3362 3442
				HyperalignText text = it.next();
3363
				System.out.println("TextManager.indexWithDictionary >>>>>>>>>>>> "+text.getName());
3443
				manager.writeToDebug("TextManager.indexWithDictionary >>>>>>>>>>>> "+text.getName());
3364 3444
				Vector<Dictionary> dicos = text.getDictionaries();
3365 3445
				for(int i = 0 ; i < dicos.size() ; ++i){
3366 3446
					Dictionary dico = dicos.get(i);
......
3379 3459
			Iterator<HyperalignText> it = textsToIndex.iterator();
3380 3460
			while(it.hasNext()){
3381 3461
				HyperalignText text = it.next();
3382
				System.out.println("CorpusManager.indexAll >>>>>>>>>>>> "+text.getName());
3462
				manager.writeToDebug("CorpusManager.indexAll >>>>>>>>>>>> "+text.getName());
3383 3463
				Vector<Dictionary> dicos = text.getDictionaries();
3384 3464
				for(int i = 0 ; i < dicos.size() ; ++i){
3385 3465
					Dictionary dico = dicos.get(i);
3386
					System.out.println("CorpusManager.indexAll() in dico "+dico);
3466
					manager.writeToDebug("CorpusManager.indexAll() in dico "+dico);
3387 3467
					ParallelTextElement textElement = corpus.getRoot();
3388 3468
					indexDivision(textElement, text, dico);
3389 3469
				}
......
3422 3502
		private ParallelTextElement findTextElement(String localisation, ParallelTextElement root){
3423 3503

  
3424 3504
			String stringOfElement = root.computeName();
3425
			//System.out.println("TextManager.findTextElement() = ROOT name ["+stringOfElement+"] // loc ["+localisation+"]");
3505
			//manager.writeToDebug("TextManager.findTextElement() = ROOT name ["+stringOfElement+"] // loc ["+localisation+"]");
3426 3506
			stringOfElement = stringOfElement.trim();
3427 3507
			boolean find = false;
3428 3508
			ParallelTextElement findElement = null;
......
3432 3512
				find = true;
3433 3513
			}
3434 3514
			if(find){
3435
				//System.out.println("FOUND !!!!!!!!!!!!");
3515
				//manager.writeToDebug("FOUND !!!!!!!!!!!!");
3436 3516
				return findElement;
3437 3517
			}
3438 3518
			else {
......
3464 3544
				find = true;
3465 3545
			}
3466 3546
			if(find){
3467
				//System.out.println("FOUND !!!!!!!!!!!!");
3547
				//manager.writeToDebug("FOUND !!!!!!!!!!!!");
3468 3548
				return findElement;
3469 3549
			}
3470 3550
			else {
......
3538 3618
		 * @return
3539 3619
		 */
3540 3620
		public ParallelTextElement findTextElementById(String id){
3541
			//System.out.println("ParallelCorpus.findTextElementById() <FOR> "+id);
3621
			//manager.writeToDebug("ParallelCorpus.findTextElementById() <FOR> "+id);
3542 3622
			ParallelTextElement root = corpus.getRoot();
3543 3623
			Vector<ParallelTextElement> children =  root.children();
3544 3624
			ParallelTextElement returnElement = null;
......
3562 3642
		 * @return
3563 3643
		 */
3564 3644
		public ParallelTextElement findTextElement(String localisation){
3565
			//System.out.println("ParallelCorpus.findTextElement() <FOR> "+localisation);
3645
			//manager.writeToDebug("ParallelCorpus.findTextElement() <FOR> "+localisation);
3566 3646
			ParallelTextElement root = corpus.getRoot();
3567 3647
			Vector<ParallelTextElement> children =  root.children();
3568 3648
			ParallelTextElement returnElement = null;
......
3582 3662

  
3583 3663
		public ParallelTextElement findTextElement(Division div){
3584 3664
			String localisation = div.computeNameWithoutTextRef();
3585
			//System.out.println("CorpusManager.findTextElement() - "+localisation);
3665
			//manager.writeToDebug("CorpusManager.findTextElement() - "+localisation);
3586 3666
			ParallelTextElement root = corpus.getRoot();
3587 3667
			Vector<ParallelTextElement> children =  root.children();
3588 3668
			ParallelTextElement returnElement = null;
......
3629 3709
		 * @return
3630 3710
		 */
3631 3711
		public String findRefText(String localisation){
3632
			//System.out.println("TextManager.findRefText() : "+localisation);
3712
			//manager.writeToDebug("TextManager.findRefText() : "+localisation);
3633 3713
			int index = localisation.indexOf(":");
3634 3714
			String refText = localisation.substring(index+1, localisation.length());
3635 3715
			return refText.trim();
......
3644 3724
		 * @return
3645 3725
		 */
3646 3726
		public ParallelTextElement findElement(ParallelTextElement root, String elementName){
3647
			//System.out.println("DataModelManager.findElement : "+elementName);
3727
			//manager.writeToDebug("DataModelManager.findElement : "+elementName);
3648 3728
			StringTokenizer tokens = new StringTokenizer(elementName, "-");
3649 3729
			String tokenLeft = ""; String tokenRight = "";
3650 3730
			if(tokens.countTokens()==2){
......
3663 3743
					if(tokens2.countTokens()==2){
3664 3744
						tokenLeft2 = tokens2.nextToken().trim();
3665 3745
						tokenRight2 = tokens2.nextToken().trim();
3666
						//System.out.println("REF ["+tokenLeft2+"|"+tokenRight2+"]");
3746
						//manager.writeToDebug("REF ["+tokenLeft2+"|"+tokenRight2+"]");
3667 3747
					}
3668 3748

  
3669 3749
					if (tokenLeft.equals(tokenLeft2) && tokenRight.equals(tokenRight2)){
......
3699 3779
				}
3700 3780
			}
3701 3781
			else {
3702
				System.out.println("Find terminé : PAS d'ENFANTS !");
3782
				manager.writeToDebug("Find terminé : PAS d'ENFANTS !");
3783
				
3703 3784
			}
3704 3785
			return returnElement;
3705 3786
		}
......
3712 3793
		 */
3713 3794
		public ParallelTextElement searchTextElement(String localisation, ParallelTextElement root){
3714 3795
			String stringOfElement = root.getId();
3715
			//System.out.println("ParallelCorpus.searchTextElement() ===> Localisation ("+localisation+") // Root Localisation ("+stringOfElement+")");
3796
			//manager.writeToDebug("ParallelCorpus.searchTextElement() ===> Localisation ("+localisation+") // Root Localisation ("+stringOfElement+")");
3716 3797
			boolean find = false;
3717 3798
			ParallelTextElement searchElement = null;
3718 3799

  
3719 3800
			if(stringOfElement.equals(localisation)){
3720
				//System.out.println("ParallelCorpus.searchTextElement() ===> GOT ELEMENT ! at "+stringOfElement);
3801
				//manager.writeToDebug("ParallelCorpus.searchTextElement() ===> GOT ELEMENT ! at "+stringOfElement);
3721 3802
				searchElement = root;
3722 3803
				find = true;
3723 3804
			}
......
3824 3905
				newDico = new Dictionary(null, lang, manager, true);
3825 3906
				//ADD TO THE TEXT/TERMINO MAP without any texts
3826 3907
				textsByDictionary.put(newDico, new Vector<HyperalignText>());
3827
				System.out.println("DictionaryManager.createDictionary("+newDico.getName()+")");
3908
				manager.writeToDebug("DictionaryManager.createDictionary("+newDico.getName()+")");
3909
				
3828 3910
				dicos[dicoDatas.length]= newDico;
3829 3911
				dicoDatas = dicos;
3830 3912
			}			
......
3889 3971
			for (int i = 0; i < dicos.size(); i++) {
3890 3972
				Dictionary dico = dicos.get(i);
3891 3973
				text.addDictionary(dico);
3892
				System.out.println("DictionaryManager.addDictionariesToText() T."+dico.getName()+" added to "+text.getName());
3974
				manager.writeToDebug("DictionaryManager.addDictionariesToText() T."+dico.getName()+" added to "+text.getName());
3975
				
3893 3976
				Vector<HyperalignText> textsForDico = textsByDictionary.get(dico);
3894 3977
				if(!textsForDico.contains(text)){
3895 3978
					textsForDico.add(text);
......
3908 3991
				texts.add(text);
3909 3992
				textsByDictionary.put(dico, texts);
3910 3993
			}
3911
			//System.out.println("		 => DictionaryManager.addTextToDictionary() -  TEXT is "+text.getName()+" /// ADD dico ["+dico.getName()+"]");
3994
			//manager.writeToDebug("		 => DictionaryManager.addTextToDictionary() -  TEXT is "+text.getName()+" /// ADD dico ["+dico.getName()+"]");
3912 3995
		}
3913 3996

  
3914 3997
		public Vector<HyperalignText> getTextsByLang(String lang){
......
3950 4033
				DictionaryElement occEl = checkOccurrence(occurrenceSet, form, occurrenceSet.getIndexes());
3951 4034
				if(occEl==null){					
3952 4035
					int nbOcc = dico.getNbOccs();
3953
					System.out.println("DictionaryManager.addOcc() [1] "+"O_"+nbOcc+" Form = "+form);
4036
					manager.writeToDebug("DictionaryManager.addOcc() [1] "+"O_"+nbOcc+" Form = "+form);
4037
					
3954 4038
					occEl = new DictionaryElement(form, Dictionary.DICO_OCC, "O_"+nbOcc, "", occurrenceSet);
3955 4039
					++nbOcc;
3956 4040
					dico.setNbOccs(nbOcc);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff