
it.unitn.disi.smatch.matchers.structure.tree.def.DefaultTreeMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of s-match Show documentation
Show all versions of s-match Show documentation
A version of S-Match semantic matching framework for Open Data
The newest version!
package it.unitn.disi.smatch.matchers.structure.tree.def;
import it.unitn.disi.smatch.SMatchConstants;
import it.unitn.disi.smatch.data.ling.IAtomicConceptOfLabel;
import it.unitn.disi.smatch.data.mappings.IContextMapping;
import it.unitn.disi.smatch.data.trees.IContext;
import it.unitn.disi.smatch.data.trees.INode;
import it.unitn.disi.smatch.matchers.structure.tree.BaseTreeMatcher;
import it.unitn.disi.smatch.matchers.structure.tree.ITreeMatcher;
import it.unitn.disi.smatch.matchers.structure.tree.TreeMatcherException;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Matches all nodes of the source context with all nodes of the target context.
*
* @author Mikalai Yatskevich [email protected]
* @author Aliaksandr Autayeu
*/
public class DefaultTreeMatcher extends BaseTreeMatcher implements ITreeMatcher {
private static final Logger log = Logger.getLogger(DefaultTreeMatcher.class);
public IContextMapping treeMatch(IContext sourceContext, IContext targetContext, IContextMapping acolMapping) throws TreeMatcherException {
IContextMapping mapping = mappingFactory.getContextMappingInstance(sourceContext, targetContext);
// semantic relation for particular node matching task
char relation;
long counter = 0;
long total = (long) sourceContext.getNodesList().size() * (long) targetContext.getNodesList().size();
long reportInt = (total / 20) + 1;//i.e. report every 5%
Map sourceAcols = new HashMap();
Map targetAcols = new HashMap();
Map> nmtAcols = new HashMap>();
for (INode sourceNode : sourceContext.getNodesList()) {
for (INode targetNode : targetContext.getNodesList()) {
relation = nodeMatcher.nodeMatch(acolMapping, nmtAcols, sourceAcols, targetAcols, sourceNode, targetNode);
mapping.setRelation(sourceNode, targetNode, relation);
counter++;
if ((SMatchConstants.LARGE_TASK < total) && (0 == (counter % reportInt)) && log.isEnabledFor(Level.INFO)) {
log.info(100 * counter / total + "%");
}
}
}
return mapping;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy