Mercurial > hg > anteater
view src/de/mpiwg/anteater/results/filter/ApplicantLocWithoutApplicantFilter.java @ 0:036535fcd179
anteater
author | jdamerow |
---|---|
date | Fri, 14 Sep 2012 10:30:43 +0200 |
parents | |
children |
line wrap: on
line source
package de.mpiwg.anteater.results.filter; import java.util.ArrayList; import java.util.List; import de.mpiwg.anteater.ml.PlaceClasses; import de.mpiwg.anteater.persons.APerson; import de.mpiwg.anteater.places.PlaceInformation; import de.mpiwg.anteater.results.ApplicantResult; import de.mpiwg.anteater.results.LocationResult; import de.mpiwg.anteater.results.SpeciesScientificResult; import de.mpiwg.anteater.text.Paragraph; import de.mpiwg.anteater.text.TextInformation; import de.mpiwg.anteater.text.TextPart; import de.mpiwg.anteater.text.TextType; /** * This filter removes all applicant location that are not in a paragraph where * there is also an applicant. * * @author Julia Damerow * */ public class ApplicantLocWithoutApplicantFilter implements IResultFilter { @Override public void filterElements(TextInformation info, List<ApplicantResult> applicantResults, List<SpeciesScientificResult> speciesResults, List<LocationResult> locationResults) { List<TextPart> summaries = info.getSummaries(); List<TextPart> suppleInfs = info.getSupplInfos(); List<LocationResult> toBeRemoved = new ArrayList<LocationResult>(); LocationLoop: for (LocationResult locResult : locationResults) { PlaceInformation placeCandidate = locResult.getFinding(); if (locResult.getPrediction() != PlaceClasses.APPLICANT_LOCATION) continue; TextPart text = null; if (locResult.getResult().getType() == TextType.TYPE_SUMMARY) { text = summaries.get(locResult.getResult().getTextIdx()); } else text = suppleInfs.get(locResult.getResult().getTextIdx()); Paragraph paragraphOfLocation = text .getParagraphOfIndex(placeCandidate.getStart()); for (ApplicantResult appResult : applicantResults) { APerson applicant = appResult.getFinding(); if (appResult.getResult().getType() == locResult.getResult() .getType() && appResult.getResult().getTextIdx() == locResult .getResult().getTextIdx()) { // if the paragraph where the applicant is in is the same as // the paragraph of the location // all good if (paragraphOfLocation == text .getParagraphOfIndex(applicant.getStart())) continue LocationLoop; } } // if there can be no applicant found in same paragraph remove // applicant location toBeRemoved.add(locResult); } locationResults.removeAll(toBeRemoved); } }