Mercurial > hg > anteater
view src/de/mpiwg/anteater/results/impl/LocationResultManager.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.impl; import java.util.ArrayList; import java.util.List; import de.mpiwg.anteater.AnteaterConfiguration; import de.mpiwg.anteater.ml.PlaceClasses; import de.mpiwg.anteater.results.AResultManager; import de.mpiwg.anteater.results.AnnotationTag; import de.mpiwg.anteater.results.LocationResult; import de.mpiwg.anteater.text.TextType; public class LocationResultManager extends AResultManager<LocationResult> { public final static String APPLICANT_LOCATION_TAG_Start = "<applicant_location woeId=\""; public final static String TAG_End = "\">"; public final static String APPLICANT_LOCATION_TAG_CLOSE = "</applicant_location>"; public final static String APPLICANT_TAG_TYPE = "applicant_location"; public final static String RESEARCH_LOCATION_TAG_Start = "<research_location woeId=\""; public final static String RESEARCH_LOCATION_TAG_CLOSE = "</research_location>"; public final static String RESEARCH_TAG_TYPE = "research_location"; public final static String APPLICANT_INSTITUTION_TAG_Start = "<applicant_institution woeId=\""; public final static String APPLICANT_INSTITUTION_TAG_CLOSE = "</applicant_institution>"; public final static String APPLICANT_INSTITUTION_TAG_TYPE = "applicant_institution"; public final static String TYPE_ATTRIBUTE = "\" type=\""; public final static String NAME_ATTRIBUTE = "\" name=\""; public LocationResultManager(AnteaterConfiguration configuration) { super(configuration); } public List<AnnotationTag> getSummaryTags(List<LocationResult> results, int textIndex) { // go through all results and only take those with prediction 1.0 List<LocationResult> predictedResults = new ArrayList<LocationResult>(); for (LocationResult r : results) { if (r.getPrediction() != 0) predictedResults.add(r); } return getSpecificSummaryTags(predictedResults, textIndex); } public List<AnnotationTag> getSuppleInfTags(List<LocationResult> results, int textIndex) { // go through all results and only take those with prediction 1.0 List<LocationResult> predictedResults = new ArrayList<LocationResult>(); for (LocationResult r : results) { if (r.getPrediction() != 0) predictedResults.add(r); } return getSpecificSuppleInfTags(predictedResults, textIndex); } @Override protected List<AnnotationTag> getSpecificSummaryTags( List<LocationResult> locations, int textIndex) { return getTags(locations, textIndex, TextType.TYPE_SUMMARY); } @Override protected List<AnnotationTag> getSpecificSuppleInfTags( List<LocationResult> locations, int textIndex) { return getTags(locations, textIndex, TextType.TYPE_SUPLINF); } protected List<AnnotationTag> getTags(List<LocationResult> results, int textIndex, int type) { List<AnnotationTag> tags = new ArrayList<AnnotationTag>(); // get applicants for text List<LocationResult> locations = new ArrayList<LocationResult>(); for (LocationResult r : results) { if (r.getResult().getType() == type && r.getResult().getTextIdx() == textIndex) locations.add(r); } for (LocationResult loc : locations) { if (loc.getPrediction() == PlaceClasses.APPLICANT_LOCATION) { tags.add(new AnnotationTag(APPLICANT_LOCATION_TAG_Start + loc.getPlace().getWoeId() + TYPE_ATTRIBUTE + loc.getPlace().getType() + NAME_ATTRIBUTE + loc.getPlace().getName() + TAG_End, loc.getFinding().getStart(), APPLICANT_LOCATION_TAG_CLOSE, loc.getFinding().getStart() + loc.getFinding().getLength(), APPLICANT_TAG_TYPE)); } if (loc.getPrediction() == PlaceClasses.RESEARCH_LOCATION) { tags.add(new AnnotationTag(RESEARCH_LOCATION_TAG_Start + loc.getPlace().getWoeId() + TYPE_ATTRIBUTE + loc.getPlace().getType() + NAME_ATTRIBUTE + loc.getPlace().getName() + TAG_End, loc.getFinding().getStart(), RESEARCH_LOCATION_TAG_CLOSE, loc.getFinding().getStart() + loc.getFinding().getLength(), RESEARCH_TAG_TYPE)); } if (loc.getPrediction() == PlaceClasses.APPLICANT_INSTITUTION) { tags.add(new AnnotationTag(APPLICANT_INSTITUTION_TAG_Start + loc.getPlace().getWoeId() + TYPE_ATTRIBUTE + loc.getPlace().getType() + NAME_ATTRIBUTE + loc.getPlace().getName() + TAG_End, loc.getFinding().getStart(), APPLICANT_INSTITUTION_TAG_CLOSE, loc.getFinding().getStart() + loc.getFinding().getLength(), APPLICANT_INSTITUTION_TAG_TYPE)); } } return tags; } }