diff src/de/mpiwg/anteater/results/impl/ScientificNameResultManager.java @ 0:036535fcd179

anteater
author jdamerow
date Fri, 14 Sep 2012 10:30:43 +0200
parents
children 0c7cf517ff2d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/de/mpiwg/anteater/results/impl/ScientificNameResultManager.java	Fri Sep 14 10:30:43 2012 +0200
@@ -0,0 +1,55 @@
+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_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_TAG_End, name.getFinding().getStart(), SCIENTIFIC_NAME_TAG_CLOSE, name.getFinding().getStart()
+					+ name.getFinding().getLength(), TAG_TYPE));
+		}
+
+		return tags;
+	}
+
+}