-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the filtering of markings for the D2KB and Entity Typing class …
…into an EvaluationDecorator to handle the problem not only for experiment tasks but for experiment sub tasks in the same way.
- Loading branch information
1 parent
eead8c5
commit 2f70646
Showing
7 changed files
with
97 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...main/java/org/aksw/gerbil/evaluate/impl/filter/SearcherBasedNotMatchingMarkingFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.aksw.gerbil.evaluate.impl.filter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.aksw.gerbil.evaluate.AbstractEvaluatorDecorator; | ||
import org.aksw.gerbil.evaluate.EvaluationResultContainer; | ||
import org.aksw.gerbil.evaluate.Evaluator; | ||
import org.aksw.gerbil.matching.MatchingsSearcher; | ||
import org.aksw.gerbil.transfer.nif.Marking; | ||
|
||
import com.carrotsearch.hppc.BitSet; | ||
|
||
/** | ||
* This evaluator decorator removes every marking from the given list that does | ||
* not match the given gold standard list based on a given | ||
* {@link MatchingsSearcher} instance. | ||
* | ||
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
public class SearcherBasedNotMatchingMarkingFilter<T extends Marking> extends AbstractEvaluatorDecorator<T> { | ||
|
||
protected MatchingsSearcher<T> searcher; | ||
|
||
public SearcherBasedNotMatchingMarkingFilter(MatchingsSearcher<T> searcher, Evaluator<T> evaluator) { | ||
super(evaluator); | ||
this.searcher = searcher; | ||
} | ||
|
||
protected List<List<T>> filterListOfMarkings(List<List<T>> markings, List<List<T>> goldStandard) { | ||
List<List<T>> filteredMarkings = new ArrayList<List<T>>(markings.size()); | ||
for (int i = 0; i < markings.size(); ++i) { | ||
filteredMarkings.add(filterMarkings(markings.get(i), goldStandard.get(i))); | ||
} | ||
return filteredMarkings; | ||
} | ||
|
||
protected List<T> filterMarkings(List<T> markings, List<T> goldStandard) { | ||
BitSet matchingElements; | ||
BitSet alreadyUsedResults = new BitSet(goldStandard.size()); | ||
List<T> filteredMarkings = new ArrayList<T>(markings.size()); | ||
for (T marking : markings) { | ||
matchingElements = searcher.findMatchings(marking, goldStandard, alreadyUsedResults); | ||
if (!matchingElements.isEmpty()) { | ||
filteredMarkings.add(marking); | ||
alreadyUsedResults.set(matchingElements.nextSetBit(0)); | ||
} | ||
} | ||
return filteredMarkings; | ||
} | ||
|
||
@Override | ||
public void evaluate(List<List<T>> annotatorResults, List<List<T>> goldStandard, | ||
EvaluationResultContainer results) { | ||
evaluator.evaluate(filterListOfMarkings(annotatorResults, goldStandard), goldStandard, results); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
src/main/java/org/aksw/gerbil/matching/filter/NotMatchingMarkingFilter.java
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
src/main/java/org/aksw/gerbil/matching/filter/SearcherBasedNotMatchingMarkingFilter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters