Revision: 52538 Author: daniel Date: 2009-06-29 11:29:14 +0000 (Mon, 29 Jun 2009)
Log Message: ----------- documenting filter architecture Modified Paths: -------------- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/AbstractIntegratorApp.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptAssociations.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptMappings.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredAssociationCursor.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredMappingCandidateCursor.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/BestMappingCandidateSelector.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFilter.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateMultiScorer.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateScorer.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelector.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelectorFilter.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateThresholdFilter.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/UniqueMappingCandidateSelector.java Added Paths: ----------- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFeatureScorer.java Removed Paths: ------------- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/ConceptAssociationFilter.java trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidatePropertyScorer.java Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/AbstractIntegratorApp.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/AbstractIntegratorApp.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/AbstractIntegratorApp.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -281,7 +281,9 @@ fsc = new TsvFeatureSetCursor(lines, chunker); - if (sourceDescriptor.getSkipBadRows()) ((TsvFeatureSetCursor)fsc).setParseErrorHandler( new LoggingErrorHandler<ChunkingCursor, ParseException, PersistenceException>(out)); + if (sourceDescriptor.getSkipBadRows()) { + ((TsvFeatureSetCursor)fsc).setParseErrorHandler( new LoggingErrorHandler<ChunkingCursor, ParseException, PersistenceException>(out)); + } if (fields!=null) { if (sourceDescriptor.getSkipHeader()) ((TsvFeatureSetCursor)fsc).readFields(); Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptAssociations.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptAssociations.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptAssociations.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -1,9 +1,9 @@ package de.brightbyte.wikiword.integrator; import de.brightbyte.data.cursor.DataCursor; +import de.brightbyte.data.filter.Filter; import de.brightbyte.wikiword.integrator.data.Association; import de.brightbyte.wikiword.integrator.data.FilteredAssociationCursor; -import de.brightbyte.wikiword.integrator.data.filter.ConceptAssociationFilter; import de.brightbyte.wikiword.integrator.store.AssociationFeatureStoreBuilder; public class FilterConceptAssociations extends BuildConceptAssociations { @@ -28,7 +28,7 @@ } - protected ConceptAssociationFilter createAssociationFilter(FeatureSetSourceDescriptor sourceDescriptor) { + protected Filter<Association> createAssociationFilter(FeatureSetSourceDescriptor sourceDescriptor) { throw new UnsupportedOperationException("no implementations of ConceptAssociationFilter are implemented yet."); //TODO: implement filters } Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptMappings.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptMappings.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/FilterConceptMappings.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -19,7 +19,7 @@ import de.brightbyte.wikiword.integrator.data.MappingCandidates; import de.brightbyte.wikiword.integrator.data.filter.BestMappingCandidateSelector; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateFilter; -import de.brightbyte.wikiword.integrator.data.filter.MappingCandidatePropertyScorer; +import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateFeatureScorer; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateScorer; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateSelector; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateSelectorFilter; @@ -78,7 +78,7 @@ } if (filter==null && selector==null && scorer==null && accessor!=null) { - scorer = new MappingCandidatePropertyScorer(accessor); + scorer = new MappingCandidateFeatureScorer(accessor); } if (filter==null && selector==null && scorer!=null) { Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredAssociationCursor.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredAssociationCursor.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredAssociationCursor.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -1,15 +1,15 @@ package de.brightbyte.wikiword.integrator.data; import de.brightbyte.data.cursor.DataCursor; +import de.brightbyte.data.filter.Filter; import de.brightbyte.util.PersistenceException; -import de.brightbyte.wikiword.integrator.data.filter.ConceptAssociationFilter; public class FilteredAssociationCursor implements DataCursor<Association> { protected DataCursor<Association> cursor; - protected ConceptAssociationFilter filter; + protected Filter<Association> filter; - public FilteredAssociationCursor(DataCursor<Association> cursor, ConceptAssociationFilter filter) { + public FilteredAssociationCursor(DataCursor<Association> cursor, Filter<Association> filter) { if (filter==null) throw new NullPointerException(); if (cursor==null) throw new NullPointerException(); @@ -26,7 +26,7 @@ while (true) { a = cursor.next(); if (a==null) return null; - if (!filter.acceptAssociation(a)) continue; + if (!filter.matches(a)) continue; break; } Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredMappingCandidateCursor.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredMappingCandidateCursor.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/FilteredMappingCandidateCursor.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -7,7 +7,7 @@ import de.brightbyte.util.PersistenceException; import de.brightbyte.wikiword.integrator.data.filter.BestMappingCandidateSelector; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateFilter; -import de.brightbyte.wikiword.integrator.data.filter.MappingCandidatePropertyScorer; +import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateFeatureScorer; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateScorer; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateSelector; import de.brightbyte.wikiword.integrator.data.filter.MappingCandidateSelectorFilter; @@ -27,11 +27,11 @@ } public FilteredMappingCandidateCursor(DataCursor<MappingCandidates> cursor, PropertyAccessor<FeatureSet, ? extends Number> accessor) { - this(cursor, new MappingCandidatePropertyScorer(accessor)); + this(cursor, new MappingCandidateFeatureScorer(accessor)); } public FilteredMappingCandidateCursor(DataCursor<MappingCandidates> cursor, PropertyAccessor<FeatureSet, ? extends Number> accessor, int threshold) { - this(cursor, new MappingCandidatePropertyScorer(accessor), threshold); + this(cursor, new MappingCandidateFeatureScorer(accessor), threshold); } public FilteredMappingCandidateCursor(DataCursor<MappingCandidates> cursor, MappingCandidateScorer scorer) { Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/BestMappingCandidateSelector.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/BestMappingCandidateSelector.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/BestMappingCandidateSelector.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -3,6 +3,12 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; import de.brightbyte.wikiword.integrator.data.MappingCandidates; +/** + * MappingCandidateSelector selecting the candidate with the highest score, as determined + * by a given MappingCandidateScorer. + * + * @author daniel + */ public class BestMappingCandidateSelector implements MappingCandidateSelector { protected MappingCandidateScorer scorer; Deleted: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/ConceptAssociationFilter.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/ConceptAssociationFilter.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/ConceptAssociationFilter.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -1,7 +0,0 @@ -package de.brightbyte.wikiword.integrator.data.filter; - -import de.brightbyte.wikiword.integrator.data.Association; - -public interface ConceptAssociationFilter { - public boolean acceptAssociation(Association assoc); -} Copied: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFeatureScorer.java (from rev 52334, trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidatePropertyScorer.java) =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFeatureScorer.java (rev 0) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFeatureScorer.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -0,0 +1,41 @@ +package de.brightbyte.wikiword.integrator.data.filter; + +import de.brightbyte.abstraction.PropertyAccessor; +import de.brightbyte.wikiword.integrator.data.FeatureSet; +import de.brightbyte.wikiword.integrator.data.FeatureSets; + +/** + * MappingCandidateScorer that determins the score directly from each FeatureSet's features, + * using a given accessor. + * + * @author daniel + */ +public class MappingCandidateFeatureScorer implements MappingCandidateScorer { + + protected PropertyAccessor<FeatureSet, ? extends Number> accessor; + + /** + * Creates a MappingCandidateFeatureScorer that uses the givenfeature's value as the + * candidate's score. + * + * @param field feature + */ + public MappingCandidateFeatureScorer(String feature) { + this(FeatureSets.fieldAccessor(feature, Number.class)); + } + + /** + * Creates a MappingCandidateFeatureScorer that determins the score using the given accessor. + * @param field accessor + */ + public MappingCandidateFeatureScorer(PropertyAccessor<FeatureSet, ? extends Number> accessor) { + if (accessor==null) throw new NullPointerException(); + this.accessor = accessor; + } + + public int getCandidateScore(FeatureSet subject, FeatureSet candidate) { + Number score = accessor.getValue(candidate); + return score.intValue(); + } + +} Property changes on: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFeatureScorer.java ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFilter.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFilter.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateFilter.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -5,6 +5,12 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; import de.brightbyte.wikiword.integrator.data.MappingCandidates; +/** + * Interface for filters that apply to the set of candidates in a MappingCandidates object. + * Can be used to reduce the number of possible mappings for a given subject. + * + * @author daniel + */ public interface MappingCandidateFilter { public Collection<FeatureSet> filterCandidates(MappingCandidates candidates); } Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateMultiScorer.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateMultiScorer.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateMultiScorer.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -6,6 +6,12 @@ import de.brightbyte.data.Functor2; import de.brightbyte.wikiword.integrator.data.FeatureSet; +/** + * MappingCandidateScorer that accumulates the scores from multiple MappingCandidateScorers into a single score, + * using a aggregator functor (usually the sum or maximum, as implemented by Functors.Integer.sum resp. Functors.Integer.max). + * + * @author daniel + */ public class MappingCandidateMultiScorer implements MappingCandidateScorer { protected Collection<MappingCandidateScorer> scorers = new ArrayList<MappingCandidateScorer>(); Deleted: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidatePropertyScorer.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidatePropertyScorer.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidatePropertyScorer.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -1,25 +0,0 @@ -package de.brightbyte.wikiword.integrator.data.filter; - -import de.brightbyte.abstraction.PropertyAccessor; -import de.brightbyte.wikiword.integrator.data.FeatureSet; -import de.brightbyte.wikiword.integrator.data.FeatureSets; - -public class MappingCandidatePropertyScorer implements MappingCandidateScorer { - - protected PropertyAccessor<FeatureSet, ? extends Number> accessor; - - public MappingCandidatePropertyScorer(String field) { - this(FeatureSets.fieldAccessor(field, Number.class)); - } - - public MappingCandidatePropertyScorer(PropertyAccessor<FeatureSet, ? extends Number> accessor) { - if (accessor==null) throw new NullPointerException(); - this.accessor = accessor; - } - - public int getCandidateScore(FeatureSet subject, FeatureSet candidate) { - Number score = accessor.getValue(candidate); - return score.intValue(); - } - -} Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateScorer.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateScorer.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateScorer.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -2,6 +2,12 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; +/** + * Determines a score value for a mapping between two given FeatureSets, the + * subject and the candidate (object). + * + * @author daniel + */ public interface MappingCandidateScorer { public int getCandidateScore(FeatureSet subject, FeatureSet candidate); } Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelector.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelector.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelector.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -3,6 +3,20 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; import de.brightbyte.wikiword.integrator.data.MappingCandidates; +/** + * Selects a candidate from a set of MappingCandidates. Used to determin the "best" mapping. + * + * @author daniel + */ public interface MappingCandidateSelector { + + /** + * returns the "best" candidate from the given MappingCandidates instance, according to + * whatever logic the implementation chooses. May also return null to indicate that no + * suitable candidate was found. + * + * @param candidates + * @return the best candidate, or null to indicate that no sufficiently good candidate was found. + */ public FeatureSet selectCandidate(MappingCandidates candidates); } Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelectorFilter.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelectorFilter.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateSelectorFilter.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -6,6 +6,12 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; import de.brightbyte.wikiword.integrator.data.MappingCandidates; +/** + * MappingCandidateFilter using a MappingCandidateSelector to reduce the set of + * candidate mappings to a single "best" candidate (or possibly none). + * + * @author daniel + */ public class MappingCandidateSelectorFilter implements MappingCandidateFilter { protected MappingCandidateSelector selector; Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateThresholdFilter.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateThresholdFilter.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/MappingCandidateThresholdFilter.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -6,6 +6,12 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; import de.brightbyte.wikiword.integrator.data.MappingCandidates; +/** + * MappingCandidateFilter using a MappingCandidateScorer to reduce the set of + * candidate mappings to those who's score pass a given threshold. + * + * @author daniel + */ public class MappingCandidateThresholdFilter implements MappingCandidateFilter { protected MappingCandidateScorer scorer; Modified: trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/UniqueMappingCandidateSelector.java =================================================================== --- trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/UniqueMappingCandidateSelector.java 2009-06-29 11:27:58 UTC (rev 52537) +++ trunk/WikiWord/WikiWordIntegrator/src/main/java/de/brightbyte/wikiword/integrator/data/filter/UniqueMappingCandidateSelector.java 2009-06-29 11:29:14 UTC (rev 52538) @@ -5,6 +5,12 @@ import de.brightbyte.wikiword.integrator.data.FeatureSet; import de.brightbyte.wikiword.integrator.data.MappingCandidates; +/** + * MappingCandidateSelector that only returns unique mapping candidates - that is, it returns null + * if there is more than once candidate. If there is only one, that candidate is returned. + * + * @author daniel + */ public class UniqueMappingCandidateSelector implements MappingCandidateSelector { public FeatureSet selectCandidate(MappingCandidates candidates) { _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs