Mercurial > hg > anteater
view src/de/mpiwg/anteater/results/impl/ScientificNameResultManager.java @ 7:0c7cf517ff2d
linnaeus results
author | jdamerow |
---|---|
date | Fri, 09 Nov 2012 16:11:08 -0700 |
parents | 036535fcd179 |
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.results.AResultManager; import de.mpiwg.anteater.results.AnnotationTag; import de.mpiwg.anteater.results.SpeciesScientificResult; import de.mpiwg.anteater.text.TextType; public class ScientificNameResultManager extends AResultManager<SpeciesScientificResult> { public final static String SCIENTIFIC_NAME_TAG_Start = "<species_scientific name=\""; public final static String SCIENTIFIC_NAME_ID_ATTR = "\" ncbiID=\""; public final static String SCIENTIFIC_NAME_TAG_End = "\" >"; public final static String SCIENTIFIC_NAME_TAG_CLOSE = "</species_scientific>"; public final static String TAG_TYPE = "scientific_name"; public ScientificNameResultManager(AnteaterConfiguration configuration) { super(configuration); } @Override protected List<AnnotationTag> getSpecificSummaryTags( List<SpeciesScientificResult> results, int textIndex) { return getTags(results, textIndex, TextType.TYPE_SUMMARY); } @Override protected List<AnnotationTag> getSpecificSuppleInfTags( List<SpeciesScientificResult> results, int textIndex) { return getTags(results, textIndex, TextType.TYPE_SUPLINF); } protected List<AnnotationTag> getTags(List<SpeciesScientificResult> results, int textIndex, int type) { List<AnnotationTag> tags = new ArrayList<AnnotationTag>(); // get applicants for text List<SpeciesScientificResult> namesOfSum = new ArrayList<SpeciesScientificResult>(); for (SpeciesScientificResult r : results) { if (r.getResult().getType() == type && r.getResult().getTextIdx() == textIndex) namesOfSum.add(r); } for (SpeciesScientificResult name : namesOfSum) { tags.add(new AnnotationTag(SCIENTIFIC_NAME_TAG_Start + name.getFinding().getScientificName() + SCIENTIFIC_NAME_ID_ATTR + (name.getFinding().getNcbiId() != null ? name.getFinding().getNcbiId() : "") + SCIENTIFIC_NAME_TAG_End, name.getFinding().getStart(), SCIENTIFIC_NAME_TAG_CLOSE, name.getFinding().getStart() + name.getFinding().getLength(), TAG_TYPE)); } return tags; } }