0
|
1 package de.mpiwg.anteater.results.impl;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.List;
|
|
5
|
|
6 import de.mpiwg.anteater.AnteaterConfiguration;
|
|
7 import de.mpiwg.anteater.results.AResultManager;
|
|
8 import de.mpiwg.anteater.results.AnnotationTag;
|
|
9 import de.mpiwg.anteater.results.SpeciesScientificResult;
|
|
10 import de.mpiwg.anteater.text.TextType;
|
|
11
|
|
12 public class ScientificNameResultManager extends AResultManager<SpeciesScientificResult> {
|
|
13
|
|
14 public final static String SCIENTIFIC_NAME_TAG_Start = "<species_scientific name=\"";
|
7
|
15 public final static String SCIENTIFIC_NAME_ID_ATTR = "\" ncbiID=\"";
|
|
16 public final static String SCIENTIFIC_NAME_TAG_End = "\" >";
|
0
|
17 public final static String SCIENTIFIC_NAME_TAG_CLOSE = "</species_scientific>";
|
|
18 public final static String TAG_TYPE = "scientific_name";
|
|
19
|
|
20 public ScientificNameResultManager(AnteaterConfiguration configuration) {
|
|
21 super(configuration);
|
|
22 }
|
|
23
|
|
24 @Override
|
|
25 protected List<AnnotationTag> getSpecificSummaryTags(
|
|
26 List<SpeciesScientificResult> results, int textIndex) {
|
|
27 return getTags(results, textIndex, TextType.TYPE_SUMMARY);
|
|
28 }
|
|
29
|
|
30 @Override
|
|
31 protected List<AnnotationTag> getSpecificSuppleInfTags(
|
|
32 List<SpeciesScientificResult> results, int textIndex) {
|
|
33 return getTags(results, textIndex, TextType.TYPE_SUPLINF);
|
|
34 }
|
|
35
|
|
36 protected List<AnnotationTag> getTags(List<SpeciesScientificResult> results, int textIndex, int type) {
|
|
37 List<AnnotationTag> tags = new ArrayList<AnnotationTag>();
|
|
38
|
|
39 // get applicants for text
|
|
40 List<SpeciesScientificResult> namesOfSum = new ArrayList<SpeciesScientificResult>();
|
|
41 for (SpeciesScientificResult r : results) {
|
|
42 if (r.getResult().getType() == type
|
|
43 && r.getResult().getTextIdx() == textIndex)
|
|
44 namesOfSum.add(r);
|
|
45 }
|
|
46
|
|
47
|
|
48 for (SpeciesScientificResult name : namesOfSum) {
|
7
|
49 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()
|
0
|
50 + name.getFinding().getLength(), TAG_TYPE));
|
|
51 }
|
|
52
|
|
53 return tags;
|
|
54 }
|
|
55
|
|
56 }
|