Method alignNodesOneByOne

From AgreementMakerWiki

Jump to: navigation, search

Here is the code for align nodes one by one:

protected AlignmentMatrix alignNodesOneByOne(ArrayList<Node> sourceList, ArrayList<Node> targetList, alignType typeOfNodes) throws Exception {
    	
    	if(optimized && inputMatchers.size() > 0){ 
    		//run in optimized mode by mapping only concepts that have not been mapped in the input matcher
    		if(typeOfNodes.equals(alignType.aligningClasses)){
    			return alignUnmappedNodes(sourceList, targetList, inputMatchers.get(0).getClassesMatrix(), inputMatchers.get(0).getClassAlignmentSet(), alignType.aligningClasses);
    		}
    		else{
    			return alignUnmappedNodes(sourceList, targetList, inputMatchers.get(0).getPropertiesMatrix(), inputMatchers.get(0).getPropertyAlignmentSet(), alignType.aligningProperties);
    		}
		}
    	
    	else{
    		//run as a generic matcher who maps all concepts by doing a quadratic number of comparisons
	    	AlignmentMatrix matrix = new AlignmentMatrix(sourceList.size(), targetList.size(), typeOfNodes, relation);
			Node source;
			Node target;
			Alignment alignment = null; //Temp structure to keep sim and relation between two nodes, shouldn't be used for this purpose but is ok
			for(int i = 0; i < sourceList.size(); i++) {
				source = sourceList.get(i);
				for(int j = 0; j < targetList.size(); j++) {
					target = targetList.get(j);
					
					if( !this.isCancelled() ) { alignment = alignTwoNodes(source, target, typeOfNodes); }
					else { return matrix; }
					
					matrix.set(i,j,alignment);
					if( isProgressDisplayed() ) stepDone(); // we have completed one step
				}
				if( isProgressDisplayed() ) updateProgress(); // update the progress dialog, to keep the user informed.
			}
			return matrix;
    	}
}

Personal tools
Namespaces
Variants
Actions
Site
Navigation
Toolbox