private void senseFiltering(IContext context) throws SenseMatcherException {
        HashMap<IAtomicConceptOfLabel, List<ISense>> refinedSenses = new HashMap<IAtomicConceptOfLabel, List<ISense>>();

        for (Iterator<INode> i = context.getNodes(); i.hasNext(); ) {
            INode sourceNode = i.next();
            // if node is complex
            if (1 < sourceNode.getNodeData().getACoLCount()) {
                // for each ACoL in the node
                for (Iterator<IAtomicConceptOfLabel> j = sourceNode.getNodeData().getACoLs(); j.hasNext(); ) {
                    IAtomicConceptOfLabel sourceACoL = j.next();
                    // compare with all the other ACoLs in the node
                    for (Iterator<IAtomicConceptOfLabel> k = sourceNode.getNodeData().getACoLs(); k.hasNext(); ) {
                        IAtomicConceptOfLabel targetACoL = k.next();
                        if (!targetACoL.equals(sourceACoL)) {
                            // for each sense in source ACoL
                            for (Iterator<ISense> s = sourceACoL.getSenses(); s.hasNext(); ) {
                                ISense sourceSense = s.next();
                                // for each sense in target ACoL
                                for (Iterator<ISense> t = targetACoL.getSenses(); t.hasNext(); ) {
                                    ISense targetSense = t.next();
                                    if (senseMatcher.isSourceSynonymTarget(sourceSense, targetSense) ||
                                            senseMatcher.isSourceLessGeneralThanTarget(sourceSense, targetSense) ||
                                            senseMatcher.isSourceMoreGeneralThanTarget(sourceSense, targetSense)) {
                                        addToRefinedSenses(refinedSenses, sourceACoL, sourceSense);
                                        addToRefinedSenses(refinedSenses, targetACoL, targetSense);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // sense disambiguation within the context structure
            // for all ACoLs in the source node
            for (Iterator<IAtomicConceptOfLabel> j = sourceNode.getNodeData().getACoLs(); j.hasNext(); ) {
                IAtomicConceptOfLabel sourceACoL = j.next();
                if (!refinedSenses.containsKey(sourceACoL)) {
                    for (Iterator<ISense> s = sourceACoL.getSenses(); s.hasNext(); ) {
                        ISense sourceSense = s.next();
                        // for all target nodes (ancestors and descendants)
                        senseFilteringAmong(sourceNode.getDescendants(), sourceSense, sourceACoL, refinedSenses);
                        senseFilteringAmong(sourceNode.getAncestors(), sourceSense, sourceACoL, refinedSenses);
                    }
                }
            }
        }

        // Loop on senses of the all concepts and assign to them
        // senses mark as refined on the previous step
        // If there are no refined senses save the original ones
        for (Iterator<INode> i = context.getNodes(); i.hasNext(); ) {
            for (Iterator<IAtomicConceptOfLabel> j = i.next().getNodeData().getACoLs(); j.hasNext(); ) {
                IAtomicConceptOfLabel acol = j.next();
                List<ISense> refined = refinedSenses.get(acol);
                if (null != refined) {
                    while (0 < acol.getSenseCount()) {
                        acol.removeSense(0);
                    }
                    for (ISense sense : refined) {
                        acol.addSense(sense);
                    }
                }
            }
        }
    }
private void senseFiltering ( IContext context ) throws SenseMatcherException { HashMap < IAtomicConceptOfLabel , List < ISense > > refinedSenses = new HashMap < IAtomicConceptOfLabel , List < ISense > > ( ) ; for ( Iterator < INode > i = context . getNodes ( ) ; i . hasNext ( ) ; ) { INode sourceNode = i . next ( ) ; if ( 1 < sourceNode . getNodeData ( ) . getACoLCount ( ) ) { for ( Iterator < IAtomicConceptOfLabel > j = sourceNode . getNodeData ( ) . getACoLs ( ) ; j . hasNext ( ) ; ) { IAtomicConceptOfLabel sourceACoL = j . next ( ) ; for ( Iterator < IAtomicConceptOfLabel > k = sourceNode . getNodeData ( ) . getACoLs ( ) ; k . hasNext ( ) ; ) { IAtomicConceptOfLabel targetACoL = k . next ( ) ; if ( ! targetACoL . equals ( sourceACoL ) ) { for ( Iterator < ISense > s = sourceACoL . getSenses ( ) ; s . hasNext ( ) ; ) { ISense sourceSense = s . next ( ) ; for ( Iterator < ISense > t = targetACoL . getSenses ( ) ; t . hasNext ( ) ; ) { ISense targetSense = t . next ( ) ; if ( senseMatcher . isSourceSynonymTarget ( sourceSense , targetSense ) || senseMatcher . isSourceLessGeneralThanTarget ( sourceSense , targetSense ) || senseMatcher . isSourceMoreGeneralThanTarget ( sourceSense , targetSense ) ) { addToRefinedSenses ( refinedSenses , sourceACoL , sourceSense ) ; addToRefinedSenses ( refinedSenses , targetACoL , targetSense ) ; } } } } } } } for ( Iterator < IAtomicConceptOfLabel > j = sourceNode . getNodeData ( ) . getACoLs ( ) ; j . hasNext ( ) ; ) { IAtomicConceptOfLabel sourceACoL = j . next ( ) ; if ( ! refinedSenses . containsKey ( sourceACoL ) ) { for ( Iterator < ISense > s = sourceACoL . getSenses ( ) ; s . hasNext ( ) ; ) { ISense sourceSense = s . next ( ) ; senseFilteringAmong ( sourceNode . getDescendants ( ) , sourceSense , sourceACoL , refinedSenses ) ; senseFilteringAmong ( sourceNode . getAncestors ( ) , sourceSense , sourceACoL , refinedSenses ) ; } } } } for ( Iterator < INode > i = context . getNodes ( ) ; i . hasNext ( ) ; ) { for ( Iterator < IAtomicConceptOfLabel > j = i . next ( ) . getNodeData ( ) . getACoLs ( ) ; j . hasNext ( ) ; ) { IAtomicConceptOfLabel acol = j . next ( ) ; List < ISense > refined = refinedSenses . get ( acol ) ; if ( null != refined ) { while ( 0 < acol . getSenseCount ( ) ) { acol . removeSense ( 0 ) ; } for ( ISense sense : refined ) { acol . addSense ( sense ) ; } } } } }
Eliminates the senses which do not suit to overall context meaning. Filters senses in two steps:
- filtering within node label
- filtering within context

@param context context to perform sense filtering
@throws SenseMatcherException SenseMatcherException